예제 #1
0
 public OptimizerOutput(double[] FVr_bestmem_, OutputFunction S_bestval_, int I_nfeval_)
 {
     FVr_bestmem = new double[FVr_bestmem_.Length];
     DifferentialEvolution.Copy1DArrayL2R(FVr_bestmem_, ref FVr_bestmem);
     S_bestval = new OutputFunction(0, 1);
     DifferentialEvolution.Copy_outfunL2R(S_bestval_, ref S_bestval);
     I_nfeval = I_nfeval_;
 }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //S_Infun1 = new InputStructure();
            //S_Infun1.valueToReach = -100000; // Lower bound on the objective function

            //S_Infun1.numberOfParameterObjectiveFunction = 2; // number of parameters to optimize

            //S_Infun1.vectorLowerBound = new double[S_Infun1.numberOfParameterObjectiveFunction]; // lower limit
            //S_Infun1.vectorUpperbound = new double[S_Infun1.numberOfParameterObjectiveFunction];

            //for (int i = 0; i < S_Infun1.numberOfParameterObjectiveFunction; i++)
            //{
            //    S_Infun1.vectorLowerBound[i] = -100;
            //    S_Infun1.vectorUpperbound[i] = 100;
            //}

            //S_Infun1.useBoundConstraint = true; // bound by lower and upper limits
            //S_Infun1.numberOfPopulation = PopulationSize;
            //S_Infun1.maxIteration = NumberOfIterations;
            //S_Infun1.weight = 0.85;
            //S_Infun1.crossOverProbability = 1;
            //S_Infun1.strategy = Strategy;
            //S_Infun1.intermediateOutput = 1;

            //S_Infun1.vectorBest = new double[S_Infun1.numberOfParameterObjectiveFunction];
            //S_Infun1.population = new double[S_Infun1.numberOfParameterObjectiveFunction, S_Infun1.numberOfParameterObjectiveFunction];

            //OptimizerOutput Output = new OptimizerOutput();


            //DifferentialEvolution DE_optimizer = new DifferentialEvolution(new
            //    DifferentialEvolution.FunctionPointer(ObjectiveFunction));

            //Output = DE_optimizer.Optimizer(S_Infun1);
            //bestParam = Output.FVr_bestmem;

            //label10.Text = bestParam[0].ToString("0.000");
            //label11.Text = bestParam[1].ToString("0.000");

            //label13.Text = (-Output.S_bestval.FVr_oa[0]).ToString("0.000");
            //MessageBox.Show("Optimization Done");// Configuring Differential evolution optimizer
            S_Infun1       = new InputStructure();
            S_Infun1.F_VTR = -100000;                         // Lower bound on the objective function

            S_Infun1.I_D = NumberOfParameters;                // number of parameters to optimize

            S_Infun1.FVr_minbound = new double[S_Infun1.I_D]; // lower limit
            S_Infun1.FVr_maxbound = new double[S_Infun1.I_D];

            for (int i = 0; i < S_Infun1.I_D; i++)
            {
                S_Infun1.FVr_minbound[i] = -100;
                S_Infun1.FVr_maxbound[i] = 100;
            }

            S_Infun1.I_bnd_constr = true; // bound by lower and upper limits
            S_Infun1.I_NP         = PopulationSize;
            S_Infun1.I_itermax    = NumberOfIterations;
            S_Infun1.F_weight     = 0.85;
            S_Infun1.F_CR         = 1;
            S_Infun1.I_strategy   = Strategy;
            S_Infun1.I_refresh    = 1;

            S_Infun1.FVr_bestmem = new double[S_Infun1.I_D];
            S_Infun1.FM_pop      = new double[S_Infun1.I_NP, S_Infun1.I_D];

            OptimizerOutput Output = new OptimizerOutput();


            DifferentialEvolution DE_optimizer = new DifferentialEvolution(new
                                                                           DifferentialEvolution.FunctionPointer(ObjectiveFunction));

            Output    = DE_optimizer.Optimizer(S_Infun1);
            bestParam = Output.FVr_bestmem;

            MessageBox.Show(bestParam[0].ToString("0.000") + " " + bestParam[1].ToString("0.000"));
            MessageBox.Show((-Output.S_bestval.FVr_oa[0]).ToString("0.000"));
            //label10.Text = bestParam[0].ToString("0.000");
            //label11.Text = bestParam[1].ToString("0.000");

            //label13.Text = (-Output.S_bestval.FVr_oa[0]).ToString("0.000");
            MessageBox.Show("Optimization Done");
        }