I want to maximize a function with constraints. When i use the following code i get: The index was outside the array
When i use the commented code it works, but what's the difference?
for (int k = 0; k < 3; k++)
{
constraints.Add(new NonlinearConstraint(3, x => x[k] >= 0));
};
//constraints.Add(new NonlinearConstraint(3, x => x[0] >= 0));
//constraints.Add(new NonlinearConstraint(3, x => x[1] >= 0));
//constraints.Add(new NonlinearConstraint(3, x => x[2] >= 0));
var cobyla = new Accord.Math.Optimization.Cobyla(function, constraints);