MatthewPeterKelly / OptimTraj

A trajectory optimization library for Matlab
MIT License
598 stars 207 forks source link

fmincon has 4 algorithm options: 'interior-point', 'trust-region-reflective', 'sqp', 'active-set'. Is OptimTraj capable of using any of these 4 NLP algorithms? Does OptimTraj default to use the default fmincon algorithm 'interior-point'? #18

Closed stumarcus314 closed 7 years ago

stumarcus314 commented 7 years ago

I have been able to use the fmincon algorithms: 'interior-point', 'sqp', 'active-set' . But the 'trust-region-reflective' algorithm produces this error:

Running OptimTraj, iteration 1 -> Transcription via Hermite-Simpson method, nSegment = 6

Error using fmincon (line 446) Option Algorithm = 'trust-region-reflective' but this algorithm does not solve problems with the constraints you have specified. Run a different algorithm by setting the Algorithm option. For information on applicable algorithms, see Choosing the Algorithm in the documentation.

Error in directCollocation (line 95) [zSoln, objVal,exitFlag,output] = fmincon(P);

Error in hermiteSimpson (line 77) soln = directCollocation(problem);

Error in optimTraj (line 182) soln(iter) = hermiteSimpson(P);

Error in invoke_OptimTraj (line 170) soln = optimTraj(problem);

MatthewPeterKelly commented 7 years ago

Good Question!

The default options for all OptimTraj problems are set in getDefaultOptions.m. Right now, they always select the default FMINCON solver, which is interior-point. This is intentional.

Let's look at the FMINCON page on algorithm selection. There are four algorithms. Of these algorithms, sqp and active-set are not good for trajectory optimization, as they are only for small and medium scale problems. Trajectory optimization creates large sparse problems. Of the remaining two algorithms, the trust-region-reflective requires a gradient, and only works for some constraints. Thus, it cannot handle all problems coming from OptimTraj. The final solver, interior-point, handles all problems, and thus is the most desirable choice.