/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <double> NumInputs = new List <double>(); List <LinguisticVariable> InputVars = new List <LinguisticVariable>(); List <LinguisticVariable> OutputVars = new List <LinguisticVariable>(); List <string> Rules = new List <string>(); AForge.Fuzzy.InferenceSystem IS = null; string VarName = null; double FailsafeVal = double.NaN; if (!DA.GetData(0, ref IS)) { return; } if (!DA.GetData(1, ref VarName)) { return; } if (!DA.GetData(2, ref FailsafeVal)) { return; } try { double outVal = IS.Evaluate(VarName); DA.SetData(0, outVal); DA.SetData(1, false); } catch (Exception) { DA.SetData(0, FailsafeVal); DA.SetData(1, true); } }
private byte Modify(InferenceSystem system, int[] windowData, byte center) { for (int i = 0; i < windowSize*windowSize - 1; i++) { system.SetInput(String.Format("IN{0}", i), windowData[i]); } int x = center + (byte) system.Evaluate("OUT"); if (x < 0) { return 0; } if (x > 255) { return 255; } return (byte) x; }