Ejemplo n.º 1
0
 public void Init()
 {
     parser       = new TaskParser();
     testSections = new AllSections()
     {
         DimensionSection = new DimensionSection()
         {
             Dim = 2
         },
         ParametersSection = new ParametersSection()
         {
             Content = ""
         },
         CostFunctionSection = new CostFunctionSection(),
         ConstraintsSection  = new ConstraintsSection()
     };
 }
Ejemplo n.º 2
0
        public void GlobalSetup()
        {
            // prepare some functions
            AllSections sections = new AllSections()
            {
                DimensionSection  = new DimensionSection(),
                ParametersSection = new ParametersSection()
                {
                    Content = ""
                },
                CostFunctionSection = new CostFunctionSection(),
                ConstraintsSection  = new ConstraintsSection()
            };

            TaskParser parser = new TaskParser();

            sections.DimensionSection.Dim         = 1;
            sections.CostFunctionSection.Function = "pow2(x[0]) + 10";
            funcRank1Simple = parser.compileCostFunction(sections).Function;

            sections.DimensionSection.Dim         = 4;
            sections.CostFunctionSection.Function = "x[0] + x[1] + x[2] + x[3]";
            funcRank4Simple = parser.compileCostFunction(sections).Function;

            sections.DimensionSection.Dim         = 1;
            sections.CostFunctionSection.Function = "sin(x[0]) * exp(x[0]) + ln(x[0]) * x[0]";
            funcRank1Complex = parser.compileCostFunction(sections).Function;

            sections.DimensionSection.Dim         = 4;
            sections.CostFunctionSection.Function = "sin(x[0]) * exp(x[1]) + ln(x[2]) * x[3]";
            funcRank4Complex = parser.compileCostFunction(sections).Function;


            Random r = new Random();

            x0 = r.NextDouble();
            x1 = r.NextDouble();
            x2 = r.NextDouble();
            x3 = r.NextDouble();

            point = new DenseVector(new double[] { x0, x1, x2, x3 });
        }