Passing additional parameters to the optimization problem in OPTI

108 views
Skip to first unread message

Mohamed W. Mehrez

unread,
Apr 25, 2016, 11:57:14 AM4/25/16
to OPTI Toolbox Forum
Hello,

Thank you very much for the OPTI toolbox. It made it very easy to me to access NLOPT on windows and MATLAB. 

I was just wondering if there is a way to pass parameters to the optimization problem when we make the function call 

[x,fval,exitflag,info] = solve(Opt,x0)

 
I am wondering about this as in my OPTI implementation (Model predictive control-MPC) I need to change the parameters inside the optimization problem every time I call the optimizer.

Your help is highly appreciated!

Jonathan Currie

unread,
Apr 25, 2016, 6:19:24 PM4/25/16
to OPTI Toolbox Forum

Hi,

 

If you are modifying the optimization problem often (i.e. in an MPC problem), then using the opti constructor is likely not the most efficient, especially for nonlinear problems. You are better off using the solver interface directly, such as described here:

http://www.i2c2.aut.ac.nz/Wiki/OPTI/index.php/Advanced/LowLevel

 

You can inspect the problem OPTI is passing to NLOPT via Opt.nlprob (“nlprob” property of the OPTI object called “Opt”). Then you can pass parameters by redefining a function handle to the objective/constraints before each call:

http://au.mathworks.com/help/optim/ug/passing-extra-parameters.html?refresh=true

 

Regards,

Jonathan

--
You received this message because you are subscribed to the Google Groups "OPTI Toolbox Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opti-toolbox-fo...@googlegroups.com.
To post to this group, send email to opti-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohamed W. Mehrez

unread,
Apr 26, 2016, 3:08:52 AM4/26/16
to Jonathan Currie, OPTI Toolbox Forum
Hello,

Thank you very much for your reply. I tried to use the second option and when I tried to set the "objective" property in "nlprop", i.e. Opt.nlprob.objective = @(x) ... , I got the following error

"You cannot set the read-only property 'nlprob' of opti."

Is there a way to change the read-only characteristic.

All the best,
Mohamed


--
You received this message because you are subscribed to a topic in the Google Groups "OPTI Toolbox Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/opti-toolbox-forum/_mtrSclUE7E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to opti-toolbox-fo...@googlegroups.com.

Jonathan Currie

unread,
Apr 27, 2016, 2:23:50 AM4/27/16
to OPTI Toolbox Forum

Hi,

 

No, the fields are deliberately read only. My intention was for you to call NLOPT directly, using the function handles similar to the ones OPTI makes. Use the nlprob structure just as a reference, then look at the opti_nlopt function.

 

Jonathan

Reply all
Reply to author
Forward
0 new messages