Example #1
0
 static void TestObjective()
 {
   Console.WriteLine("Running TestObjective");
   Solver solver = new Solver("TestObjective", Solver.CLP_LINEAR_PROGRAMMING);
   Variable x = solver.MakeNumVar(0.0, 100.0, "x");
   Variable y = solver.MakeNumVar(0.0, 100.0, "y");
   solver.Maximize(x);
   CheckDoubleEq(0.0, solver.Objective().Offset(), "test1");
   CheckDoubleEq(1.0, solver.Objective().GetCoefficient(x), "test2");
   Check(solver.Objective().Maximization(), "test3");
   solver.Minimize(-x - 2 * y + 3);
   CheckDoubleEq(3.0, solver.Objective().Offset(), "test4");
   CheckDoubleEq(-1.0, solver.Objective().GetCoefficient(x), "test5");
   CheckDoubleEq(-2.0, solver.Objective().GetCoefficient(y), "test6");
   Check(solver.Objective().Minimization(), "test7");
 }