public void ConstructorTest6_0()
{
// This problem is taken from Fletcher's book Practical Methods of
// Optimization and has the equation number (9.1.15).
var function = new NonlinearObjectiveFunction(2, x => -x[0] - x[1]);
NonlinearConstraint[] constraints =
{
new NonlinearConstraint(2, x => x[1] - x[0] * x[0] >= 0),
new NonlinearConstraint(2, x => 1.0 - x[0] * x[0] - x[1] * x[1] >= 0),
};
Cobyla cobyla = new Cobyla(function, constraints);
bool success = cobyla.Minimize();
double minimum = cobyla.Value;
double[] solution = cobyla.Solution;
Assert.IsTrue(success);
double sqrthalf = Math.Sqrt(0.5);
Assert.AreEqual(-sqrthalf * 2, minimum, 1e-10);
Assert.AreEqual(sqrthalf, solution[0], 1e-5);
Assert.AreEqual(sqrthalf, solution[1], 1e-5);
double expectedMinimum = function.Function(cobyla.Solution);
Assert.AreEqual(expectedMinimum, minimum);
}