Reputation: 2013
I have a Cobyla object in a VB project (which could just as easily be C#) for solving a problem with 7 variables. Each variable has its own constraint. I'm setting up the constraints like this, but the constraints aren't being followed.
Dim mesaConstraints As NonlinearConstraint() =
{' Make sure all variables follow their constraints
New NonlinearConstraint(7, Function(mesaVar) mesaVar(0) >= min0),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(1) >= min1),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(2) >= min2),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(3) >= min3),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(4) >= min4),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(5) >= min5),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(6) >= min6),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(0) <= max0),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(1) <= max1),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(2) <= max2),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(3) <= max3),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(4) <= max4),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(5) <= max5),
New NonlinearConstraint(7, Function(mesaVar) mesaVar(6) <= max6)
}
Is anyone able to suggest why the constraints aren't being followed? I would think it would be easy.
Upvotes: 0
Views: 145
Reputation: 2119
Make sure to check that the cobyla exit code (the status property [2]) is CobylaStatus.Success to ensure that the solution is valid. According to Anders Gustafsson there is no guarantee that constraints are met [1].
[1] Accord.net Cobyla solver returns success when there are no feasiable solutions
[2] http://accord-framework.net/docs/html/T_Accord_Math_Optimization_Cobyla.htm
Upvotes: 1