public BallnBenchmark(ExperimentParameters experimentParameters, ITermsFactory termsFactory)
        {
            var numberOfDimensions = experimentParameters.NumberOfDimensions;
            var ballnBoundaryValue = experimentParameters.BallnBoundaryValue;
            var numberOfTerms      = numberOfDimensions * 2;
            var terms         = new Term[numberOfTerms];
            var limitingValue = ballnBoundaryValue * ballnBoundaryValue;

            Constraints = new Constraint[1];
            Domains     = new Domain[numberOfDimensions];

            for (var i = 0; i < numberOfDimensions; i++)
            {
                var value = i + 1;
                terms[i] = termsFactory.Create((int)TermType.Quadratic, 1);

                Domains[i] = new Domain(value - 2 * ballnBoundaryValue, value + 2 * ballnBoundaryValue);

                //HACK TODO
                //Domains[i] = new Domain(value - 2 * ballnBoundaryValue + 100, value + 2 * ballnBoundaryValue + 100);
                //

                limitingValue -= value * value;
            }

            for (var i = numberOfDimensions; i < numberOfTerms; i++)
            {
                var value = i + 1 - numberOfDimensions;
                terms[i] = termsFactory.Create((int)TermType.Linear, -2 * value);
            }

            Constraints[0] = new QuadraticConstraint(terms, limitingValue);
        }
Ejemplo n.º 2
0
        public CubenBenchmark(ExperimentParameters experimentParameters, ITermsFactory termsFactory)
        {
            var numberOfDimensions = experimentParameters.NumberOfDimensions;
            var cubenBoundaryValue = experimentParameters.CubenBoundaryValue;
            var constraints        = new List <Constraint>(numberOfDimensions * 2);

            Domains = new Domain[numberOfDimensions];

            for (var i = 0; i < numberOfDimensions; i++)
            {
                var value = i + 1;

                var terms1 = new Term[numberOfDimensions];
                var terms2 = new Term[numberOfDimensions];

                for (var j = 0; j < numberOfDimensions; j++)
                {
                    terms1[j] = termsFactory.Create((int)TermType.Linear, 0);
                    terms2[j] = termsFactory.Create((int)TermType.Linear, 0);
                }

                terms1[i].Coefficient = -1;
                terms2[i].Coefficient = 1;

                constraints.Add(new LinearConstraint(terms1, -value));
                constraints.Add(new LinearConstraint(terms2, value + value * cubenBoundaryValue));

                Domains[i] = new Domain(value - value * cubenBoundaryValue, value + 2 * value * cubenBoundaryValue);
            }

            Constraints = constraints.ToArray();
        }
Ejemplo n.º 3
0
        public SimplexnBenchmark(ExperimentParameters experimentParameters, ITermsFactory termsFactory)
        {
            var numberOfDimensions    = experimentParameters.NumberOfDimensions;
            var simplexnBoundaryValue = experimentParameters.SimplexnBoundaryValue;
            var tanPi12     = Math.Tan(Math.PI / 12);
            var cotPi12     = 1 / tanPi12;
            var constraints = new List <Constraint>(4 * numberOfDimensions - 6 + 1);
            var terms1      = new Term[numberOfDimensions];
            var terms2      = new Term[numberOfDimensions];

            Domains = new Domain[numberOfDimensions];

            for (var i = 0; i < numberOfDimensions; i++)
            {
                Domains[i] = new Domain(-1, 2 + simplexnBoundaryValue);
            }

            for (var i = 0; i < numberOfDimensions; i++)
            {
                for (var j = i + 1; j < numberOfDimensions; j++)
                {
                    for (var k = 0; k < numberOfDimensions; k++)
                    {
                        terms1[k] = termsFactory.Create((int)TermType.Linear, 0);
                        terms2[k] = termsFactory.Create((int)TermType.Linear, 0);
                    }

                    terms1[i].Coefficient = -cotPi12;
                    terms1[j].Coefficient = tanPi12;
                    terms2[j].Coefficient = -cotPi12;
                    terms2[i].Coefficient = tanPi12;

                    constraints.Add(new LinearConstraint(terms1.DeepCopyByExpressionTree(), 0));
                    constraints.Add(new LinearConstraint(terms2.DeepCopyByExpressionTree(), 0));
                }
            }

            for (var i = 0; i < numberOfDimensions; i++)
            {
                terms1[i] = termsFactory.Create((int)TermType.Linear, 1);
            }

            constraints.Add(new LinearConstraint(terms1.DeepCopyByExpressionTree(), simplexnBoundaryValue));

            Constraints = constraints.ToArray();
        }