private double CalculateOutput(List <double> values, NormOperator norm) { switch (norm) { case NormOperator.PROD: { double returnVal = 1; values.Where(x => x != 0).Select(x => returnVal *= x); return(returnVal); break; } case NormOperator.MIN: { return(values.Min());; break; } default: { return(0); } } }
public Rule(RuleOperator ruleOperator, NormOperator normOperator, Tuple <Variable, FuzzySet> outputSet, Dictionary <Variable, FuzzySet> inputSet) { RuleOperator = ruleOperator; NormOperator = normOperator; OutputSet = outputSet; InputSet = inputSet; Valid = true; }
/// <summary> /// Sets the RadioButton norm operator. /// </summary> /// <param name="normOperator">The norm operator.</param> private void SetRadioButtonNormOperator(NormOperator normOperator) { switch (normOperator) { case NormOperator.MinMax: this.radioButtonCriteriaMimMax.Checked = true; break; case NormOperator.Prod: this.radioButtonCriteriaProd.Checked = true; break; case NormOperator.Mean: this.radioButtonCriteriaMean.Checked = true; break; } }
public void CreateRules(List <RuleLine> ruleLines, NormOperator normOperator) { Rules.Clear(); foreach (var ruleLine in ruleLines) { var inputSets = new Dictionary <Variable, FuzzySet>(); foreach (var variableFunction in ruleLine.VariableFunction) { var inputVariable = Inputs.FirstOrDefault(iv => iv.Name.Equals(variableFunction.Key.VariableName)); var inputFuzzySet = inputVariable.FuzzySets.FirstOrDefault(fs => fs.Key.Name.Equals(variableFunction.Value.SetName)); inputSets.Add(inputVariable, inputFuzzySet.Key); } var outputVariable = Output; var outputFuzzySet = Output.FuzzySets.Keys.FirstOrDefault(fs => fs.Name.Equals(ruleLine.OuputVariableFunction.Item2.SetName)); var outputSet = new Tuple <Variable, FuzzySet>(outputVariable, outputFuzzySet); var rule = new Rule(ruleLine.RuleOperator, normOperator, outputSet, inputSets); Rules.Add(rule); } }
/// <summary> /// Initializes a new instance of the <see cref="RuleBlockModel"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="inputFuzzyVariables">The input fuzzy variables.</param> /// <param name="outputFuzzyVariables">The output fuzzy variables.</param> /// <param name="normOperator">The norm operator.</param> public RuleBlockModel(string name, ObservableCollection <FuzzyVariableModel> inputFuzzyVariables, ObservableCollection <FuzzyVariableModel> outputFuzzyVariables, NormOperator normOperator, Deffuzification deffuzification) { this.Name = name; this.InputFuzzyVariables = inputFuzzyVariables; this.OutputFuzzyVariables = outputFuzzyVariables; this.NormOperator = normOperator; this.DeffuzificationMethod = deffuzification; }