示例#1
0
        public void Evaluate()
        {
            Salomon function = new Salomon();
            Vector  v1       = new Vector(new double[] { 0, 0 });
            Vector  v2       = new Vector(new double[] { 1, 2 });

            Assert.AreEqual(0, function.Evaluate(v1));
            Assert.AreEqual(1.13618107303302, function.Evaluate(v2), 1e-10);
        }
示例#2
0
        public void TwoDim_EvaluatesCorrectValues(double[] values)
        {
            var evaluator = new Salomon(2);
            var ds        = evaluator.GetGlobalOptimum().GetDecisionSpace();
            var result    = evaluator.Evaluate(DecisionVector.CreateFromArray(ds, new[] { values[0], values[1] }));

            Assert.True(Math.Abs(values[2] - result.ElementAt(0)) < 0.001);
        }