public void GoldfarbIdnaniMaximizeTest1()
{
// Solve the following optimization problem:
//
// max f(x) = -2x² + xy - y² + 5y
//
// s.t. x + y <= 0
// y >= 0
//
// Create our objective function using a text string
var f = new QuadraticObjectiveFunction("-2x² + xy - y² + 5y");
// Now, create the constraints
List<LinearConstraint> constraints = new List<LinearConstraint>();
constraints.Add(new LinearConstraint(f, "x + y <= 0"));
constraints.Add(new LinearConstraint(f, " y >= 0"));
// Now we create the quadratic programming solver for 2 variables, using the constraints.
GoldfarbIdnani solver = new GoldfarbIdnani(f, constraints);
// And attempt to solve it.
Assert.IsTrue(solver.Maximize());
double maxValue = solver.Value;
Assert.AreEqual(25 / 16.0, maxValue);
Assert.AreEqual(-5 / 8.0, solver.Solution[0]);
Assert.AreEqual(5 / 8.0, solver.Solution[1]);
}