コード例 #1
0
        /// <summary>
        /// example for FrOG Single Objective. Not working? Check project: FrOG.vs
        /// </summary>
        /// <param name="args"></param>
        static void mmMain(string[] args)
        {
            int dvar = 5;

            double[] lb = new double[dvar];
            double[] ub = new double[dvar];
            for (int i = 0; i < dvar; i++)
            {
                lb[i] = -5;
                ub[i] = 5;
            }

            Func <List <decimal>, double> evalFunc = x =>
            {
                double[] dbl = new double[dvar];
                for (int i = 0; i < dvar; i++)
                {
                    dbl[i] = Convert.ToDouble(x[i]);
                }
                return(SO.L_Ackley(dbl));
            };


            List <Variable> thomasVariable = new List <Variable>();

            for (int i = 0; i < dvar; i++)
            {
                Variable var = new Variable(Convert.ToDecimal(lb[i]), Convert.ToDecimal(ub[i]), false);
                thomasVariable.Add(var);
            }

            HillclimberFROG hcFROG = new HillclimberFROG();
            bool            run    = hcFROG.RunSolver(thomasVariable, evalFunc, "don't know", "don't know");

            Console.WriteLine(hcFROG.GetErrorMessage());
            if (run)
            {
                Console.WriteLine("cost: {0}", hcFROG.get_fxoptimum());
            }
            Console.ReadKey();
        }