Exemple #1
0
        static void TestHS71()
        {
            Console.WriteLine();
            Console.WriteLine("### Test Problem: Hock-Schittkowski #71");
            var problem = new OptimizationProblem();
            var x1      = new Variable("x1", 1, 1, 5);
            var x2      = new Variable("x2", 2, 1, 5);
            var x3      = new Variable("x3", 5, 1, 5);
            var x4      = new Variable("x4", 1, 1, 5);

            problem.AddVariables(x1, x2, x3, x4);

            problem.ObjectiveFunction = x1 * x4 * Sym.Par(x1 + x2 + x3) + x3;
            problem.AddInequalityConstraints(new Constraint(x1 * x2 * x3 * x4, ConstraintComparisonOperator.GreaterThanOrEqual, 25));
            problem.AddConstraints((Sym.Pow(x1, 2) + Sym.Pow(x2, 2) + Sym.Pow(x3, 2) + Sym.Pow(x4, 2)).IsEqualTo(40));

            //
            var solver = new IpoptSolver();

            solver.OnLog += Console.WriteLine;

            solver.Solve(problem);

            Console.WriteLine(x1.WriteReport());
            Console.WriteLine(x2.WriteReport());
            Console.WriteLine(x3.WriteReport());
            Console.WriteLine(x4.WriteReport());
        }
Exemple #2
0
 public OptimizationProblem Solve(OptimizationProblem problem)
 {
     ipopt.Solve(problem);
     return(problem);
 }