public void GoldfarbIdnaniConstructorTest8()
{
// Solve the following optimization problem:
//
// min f(x) = x² + 2xy + y² - y
//
// s.t. x >= 1
// y >= 1
//
double x = 0, y = 0;
// http://www.wolframalpha.com/input/?i=min+x%C2%B2+%2B+2xy+%2B+y%C2%B2+-+y%2C+x+%3E%3D+1%2C+y+%3E%3D+1
var f = new QuadraticObjectiveFunction(() => (x * x) + 2 * (x * y) + (y * y) - y);
List<LinearConstraint> constraints = new List<LinearConstraint>();
constraints.Add(new LinearConstraint(f, () => x >= 1));
constraints.Add(new LinearConstraint(f, () => y >= 1));
GoldfarbIdnani target = new GoldfarbIdnani(f, constraints);
double[,] A =
{
{ 1, 0 },
{ 0, 1 },
};
double[] b =
{
1,
1,
};
Assert.IsTrue(A.IsEqual(target.ConstraintMatrix));
Assert.IsTrue(b.IsEqual(target.ConstraintValues));
double[,] Q =
{
{ 2, 2 },
{ 2, 2 },
};
double[] d = { 0, -1 };
var actualQ = f.QuadraticTerms;
var actuald = f.LinearTerms;
Assert.IsTrue(Q.IsEqual(actualQ));
Assert.IsTrue(d.IsEqual(actuald));
bool success = target.Minimize();
Assert.IsFalse(success);
}