private INonlinearSolution _perform_itr(Rational var1_initial, Rational var2_initial, out int vidRow, out int vidVariable1, out int vidVariable2, out int vidVariable3, out int vidVariable4)
        {
            var solver = new NelderMeadSolver();

            // By CQN solver convention, the vid for a row will always be 0
            solver.AddRow(null, out vidRow);
            solver.AddGoal(vidRow, 0, true);
            // By CQN solver convention, first (and in this case only) variable always has the vid of 1
            solver.AddVariable(null, out vidVariable1);
            solver.AddVariable(null, out vidVariable2);
            solver.AddVariable(null, out vidVariable3);
            solver.AddVariable(null, out vidVariable4);
            //solver.AddVariable(null, out vidVariable4);

            Rational rVariable1 = var1_initial; solver.SetValue(vidVariable1, rVariable1);
            Rational rVariable2 = var2_initial; solver.SetValue(vidVariable2, rVariable2);
            //Rational rVariable2 = 0.0001; solver.SetValue(vidVariable2, rVariable2);
            Rational rVariable3 = -0.2; solver.SetValue(vidVariable3, rVariable3);
            Rational rVariable4 = 0.0; solver.SetValue(vidVariable4, rVariable4);

            //Setting the evaluators
            //solver.FunctionEvaluator = ((m,r,v,n) => { return Math.Pow(v[1] + _decay[1], 2); });
            solver.FunctionEvaluator = this.SinxValue;
            //solver.GradientEvaluator = SinxGradient;

            var param = new NelderMeadSolverParams();

            //param.MaximumSearchPoints = 10;

            return(solver.Solve(param));
        }
예제 #2
0
        public NelderMeadSolver Init()
        {
            var solver = new NelderMeadSolver();

            int vidRow;

            solver.AddRow(null, out vidRow);
            solver.AddGoal(vidRow, 0, true);

            int[] vidVariables = new int[dimensions];
            for (int i = 0; i < dimensions; i++)
            {
                solver.AddVariable(null, out vidVariables[i]);
            }

            solver.FunctionEvaluator = DiffMapping;

            Solvers.Clear();
            Solvers.Add(solver);

            return(solver);
        }