ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 12 Oct 2011 04:11:44 -0500sage.numerical.optimize.minimize_constrained versus fminconhttps://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/Matlab has this function:
http://www.mathworks.com/help/toolbox/optim/ug/fmincon.html
And as far as I can tell, Sage's closest equivalent is this:
http://www.sagemath.org/doc/reference/sage/numerical/optimize.html#sage.numerical.optimize.minimize_constrained
I use the inequality feature of `fmincon`. I think that the `cons` lambdas can achieve the same thing, although: will the performance worsen? Since fmincon can run an interior-point method with knowledge of the boundary, will the convergence be better there than with minimize_constrained? Is there some implementation of an interior-point method that I'm not seeing in Sage?
Thanks.Tue, 11 Oct 2011 06:08:11 -0500https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/Answer by niles for <p>Matlab has this function:
<a href="http://www.mathworks.com/help/toolbox/optim/ug/fmincon.html">http://www.mathworks.com/help/toolbox...</a></p>
<p>And as far as I can tell, Sage's closest equivalent is this:
<a href="http://www.sagemath.org/doc/reference/sage/numerical/optimize.html#sage.numerical.optimize.minimize_constrained">http://www.sagemath.org/doc/reference...</a></p>
<p>I use the inequality feature of <code>fmincon</code>. I think that the <code>cons</code> lambdas can achieve the same thing, although: will the performance worsen? Since fmincon can run an interior-point method with knowledge of the boundary, will the convergence be better there than with minimize_constrained? Is there some implementation of an interior-point method that I'm not seeing in Sage?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?answer=12749#post-id-12749When you [browse the source](http://hg.sagemath.org/sage-main/file/2a2abbcad325/sage/numerical/optimize.py), you can see exactly what algorithm is being used--perhaps this can help answer some of your performance questions? For `minimize_constrained`, Sage calls the multivariate constrained optimization functions from [scipy.optimize](http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize): either `fmin_tnc` (truncated Newton's method) or `fmin_cobyla` (Constrained Optimization BY Linear) or, if requested, `fmin_l_bfgs_b` (L-BFGS-B algorithm).
If there are any other optimization methods, I would expect them to be in this same source file. Also, you might find some of the other functionality of scipy.optimize useful; in that case, the source here could be a template for how to use it.
Tue, 11 Oct 2011 15:43:31 -0500https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?answer=12749#post-id-12749Comment by Reinderien for <p>When you <a href="http://hg.sagemath.org/sage-main/file/2a2abbcad325/sage/numerical/optimize.py">browse the source</a>, you can see exactly what algorithm is being used--perhaps this can help answer some of your performance questions? For <code>minimize_constrained</code>, Sage calls the multivariate constrained optimization functions from <a href="http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize">scipy.optimize</a>: either <code>fmin_tnc</code> (truncated Newton's method) or <code>fmin_cobyla</code> (Constrained Optimization BY Linear) or, if requested, <code>fmin_l_bfgs_b</code> (L-BFGS-B algorithm).</p>
<p>If there are any other optimization methods, I would expect them to be in this same source file. Also, you might find some of the other functionality of scipy.optimize useful; in that case, the source here could be a template for how to use it.</p>
https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21136#post-id-21136It seems that `scipy.optimize.fmin_slsqp` is a good candidate.Wed, 12 Oct 2011 04:06:28 -0500https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21136#post-id-21136Comment by Reinderien for <p>When you <a href="http://hg.sagemath.org/sage-main/file/2a2abbcad325/sage/numerical/optimize.py">browse the source</a>, you can see exactly what algorithm is being used--perhaps this can help answer some of your performance questions? For <code>minimize_constrained</code>, Sage calls the multivariate constrained optimization functions from <a href="http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize">scipy.optimize</a>: either <code>fmin_tnc</code> (truncated Newton's method) or <code>fmin_cobyla</code> (Constrained Optimization BY Linear) or, if requested, <code>fmin_l_bfgs_b</code> (L-BFGS-B algorithm).</p>
<p>If there are any other optimization methods, I would expect them to be in this same source file. Also, you might find some of the other functionality of scipy.optimize useful; in that case, the source here could be a template for how to use it.</p>
https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21135#post-id-21135I don't see the SLSQP algorithm in that file. Is there a place where I could request that there be a Sage wrapper added for this function?Wed, 12 Oct 2011 04:08:40 -0500https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21135#post-id-21135Comment by Reinderien for <p>When you <a href="http://hg.sagemath.org/sage-main/file/2a2abbcad325/sage/numerical/optimize.py">browse the source</a>, you can see exactly what algorithm is being used--perhaps this can help answer some of your performance questions? For <code>minimize_constrained</code>, Sage calls the multivariate constrained optimization functions from <a href="http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize">scipy.optimize</a>: either <code>fmin_tnc</code> (truncated Newton's method) or <code>fmin_cobyla</code> (Constrained Optimization BY Linear) or, if requested, <code>fmin_l_bfgs_b</code> (L-BFGS-B algorithm).</p>
<p>If there are any other optimization methods, I would expect them to be in this same source file. Also, you might find some of the other functionality of scipy.optimize useful; in that case, the source here could be a template for how to use it.</p>
https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21134#post-id-21134It seems that someone is already using this, although I have to read more closely to see how it's done: http://www.sagenb.org/home/pub/1224/Wed, 12 Oct 2011 04:11:44 -0500https://ask.sagemath.org/question/8373/sagenumericaloptimizeminimize_constrained-versus-fmincon/?comment=21134#post-id-21134