-
Notifications
You must be signed in to change notification settings - Fork 2k
A few updates to optimization constraints #821
Comments
Hi @AlexJCross, Thanks a lot for all the nice suggestions! I will comment on them below:
Thanks again, |
Hi @cesarsouza
I hadn't thought about this but I'll check it out - sounds v sensible.
Yep - that's exactly what I had in mind. An extra layer of indirection in the Best, |
- Adding Tolerance to the interface of IConstraint - Add GetViolation and IsViolated as extension methods to IConstraint (removing duplicated code) GH-821: - Changing all references from NonlinearConstraint to IConstraint in AugmentedLagrangian.cs. - Updating the documentation to give an example of using LinearConstraints in the AugmentedLagrangian
- Adding Tolerance to the interface of IConstraint - Add GetViolation and IsViolated as extension methods to IConstraint (removing duplicated code) GH-820: - Changing all references from NonlinearConstraint to IConstraint in AugmentedLagrangian.cs. - Updating the documentation to give an example of using LinearConstraints in the AugmentedLagrangian
Added in 3.8.0. |
Hi @cesarsouza,
I had a few thoughts on some of the constraints that exist in the library and I was wondering if you'd be interested in these changes?
Changes
double Tolerance { get; }
to theIConstraint
interfacebool IsViolated(double[] input)
as an extension method onIConstraint
(or add it to the interface)IConstraint
, promoteFunc<double[], double> Function { get; }
todouble Function(double[] x)
Func<double[], double[]> Gradient { get; }
todouble[] Gradient(double[] x)
ExpressionParser
or some similar class.NonlinearConstraint
andLinearConstraint
void Gradient(double[] x, double[] grad)
nonlinear constraintsWhy?
IConstraint
s get it for free. I probably wouldn't add it to the interface as it feels a bit mean to make implementers ofIConstraint
implement this over and over.Func<double[], double>
. To me, the API is far clearer and it stops the intellisense bringing up obscure properties when filling in constraint properties. I'm aware that there is some dynamism with Expressions being compiled but this can all be handled without any issue. (Proposed code snippet below)public LinearConstraint(int numberOfVariables)
) making it hard for the uninitiated to know what properties need to be set. I noticed someone raised an issue yesterday requesting help. Perhaps I could add some constructors that specify the exact requirements, fully document those and obsolete some others?Let me know if you'd be interested in me adding any of these.
Thanks,
Alex
The text was updated successfully, but these errors were encountered: