示例#1
0
        public void CreateOutputVariables(VariableLine outputVariable, List <MemberFunction> memberFunctions)
        {
            double rangeStart = Convert.ToDouble(outputVariable.Range[0]);
            double rangeEnd   = Convert.ToDouble(outputVariable.Range[1]);

            var variable = new Variable(outputVariable.VariableName, rangeStart, rangeEnd);

            foreach (var memberFunction in memberFunctions)
            {
                var       fuzzySet = new FuzzySet(memberFunction.SetName);
                IFunction function;
                switch (memberFunction.FunctionType)
                {
                case FunctionType.TriangleMF:
                {
                    function = new TriMF(Convert.ToDouble(memberFunction.FunctionPoints[0]),
                                         Convert.ToDouble(memberFunction.FunctionPoints[1]),
                                         Convert.ToDouble(memberFunction.FunctionPoints[2]));
                    break;
                }

                default:
                {
                    function = new TriMF(Convert.ToDouble(memberFunction.FunctionPoints[0]),
                                         Convert.ToDouble(memberFunction.FunctionPoints[1]),
                                         Convert.ToDouble(memberFunction.FunctionPoints[2]));
                    break;
                }
                }

                variable.AddFuzzySet(fuzzySet, function);
            }

            Output = variable;
        }
示例#2
0
        public void CreateInputVariables(Dictionary <VariableLine, List <MemberFunction> > variableFunctions)
        {
            Inputs.Clear();
            foreach (var inputVariableLine in variableFunctions)
            {
                double rangeStart = Convert.ToDouble(inputVariableLine.Key.Range[0]);
                double rangeEnd   = Convert.ToDouble(inputVariableLine.Key.Range[1]);

                var variable = new Variable(inputVariableLine.Key.VariableName, rangeStart, rangeEnd);

                foreach (var memberFunction in inputVariableLine.Value)
                {
                    var       fuzzySet = new FuzzySet(memberFunction.SetName);
                    IFunction function;
                    switch (memberFunction.FunctionType)
                    {
                    case FunctionType.TriangleMF:
                    {
                        function = new TriMF(Convert.ToDouble(memberFunction.FunctionPoints[0]),
                                             Convert.ToDouble(memberFunction.FunctionPoints[1]),
                                             Convert.ToDouble(memberFunction.FunctionPoints[2]));
                        break;
                    }

                    default:
                    {
                        function = new TriMF(Convert.ToDouble(memberFunction.FunctionPoints[0]),
                                             Convert.ToDouble(memberFunction.FunctionPoints[1]),
                                             Convert.ToDouble(memberFunction.FunctionPoints[2]));
                        break;
                    }
                    }

                    variable.AddFuzzySet(fuzzySet, function);
                }

                Inputs.Add(variable);
            }
        }