is used as follows in the Symja NMinimize function NMinimize({Sinc(x)+Sinc(y)}, {x, y}) and returns: {-0.434467,{x->4.49341,y->4.49341}}
Is there an example, how I can define additional constraints? NMinimize({Sinc[x]+Sinc[y], x^2 + y^2 <=2}, {x, y}which should return: {1.68294,{x->1.0,y->1.0}}
We don’t have constrained optimization per se. We have been wanting to add this for… fifteen years at least.
The only thing we can do for now, and which in fact works for many cases, is to implement ParameterValidator. This takes as input the unconstrained values the optimizer would like to use for the next iteration, and it converts them to something else, taking into account any user-defined constraint.
We typically use this to clip parameters back to some domain when using an optimizer that does not take any contraint into account. As an example, in orbit determination using Keplerian elements, the orbit eccentricity must be between 0.0 and 1.0, so if the optimizer wants to try at some point an eccentricity set to -0.00001, we just clip it back to 0.0 using a custom implementation of the interface. The same thing could be done with other types of constraints (i.e. not simple boundaries like in the eccentricity case).
There is a LinearConstraintSet class in Hipparchus, but I don’t remember which optimizer is able to use it. It is based on the very ugly old OptimizationData hierarchy that requires reading the code to be used properly.
Yes I’m using LinearConstraint for the “linear case” inSimplexSolver.
I’m looking for something similar in the “non-linear case” for minimizing / maximizing.
From the test examples ParameterValidatorseems to be only useful in “least squares” problems?
hi
i wrote test library for hipparcus with nonlinear costraint optimization.
It is at first version. you could use and see if suit to you.
Fra optimization.7z (89.1 KB)
example:
TwiceDifferentiableFunction problem = new HockSchittkowskiFunction ();
InequalityConstraint ineq = new HockSchittkowskiCostraintInequality ();
EqualityConstraint eq = new HockSchittkowskiCostraintEquality();
SQPOptimizerS optimizer3 = new SQPOptimizerS() ;
LagrangetSolution sol = optimizer3.optimize(new InitialGuess(new double[]{1,5,5,1}),new ObjectiveFunction(problem),ineq,eq);
I have opened issue 296 for this and started a new branch with Francesco’s contribution.
It is not ready to be merged in the master branch, it still lacks lots of documentation, triggers a lot of checkstyle warnings (I have already fixed a few hundreds of them) and the tests are not in Junit form (they are main programs).
A first version of the contribution has been merged into master.
It generates lots of errors in SonarQube at this stage, as javadoc and test coverage are lacking.
See issue 296.
The SonarQube errors have now all be solved.
The project is still flagged with a red badge because we are clearly lacking a lot of tests. The current settings have been lowered to 80% on new code, but we still globally target 90% or more for all code, so we should target 90% to avoid decreasing our current status.
I cannot do this, @roccafrancesco could you take a look and add more tests to improve test coverage?
I think this was intended with InequalityConstraintSet because it takes a collection of TwiceDifferentiableFunction as arguments, but it doesn’t seem to be used anywhere in the code…