Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fmincon, Hessian and extra parameters

215 views
Skip to first unread message

Marco

unread,
Mar 21, 2010, 5:31:02 PM3/21/10
to
Hi,
I got a problem with the definition of the Hessian used by the FMINCON function.
I'm using the interior-point algorithm to solve a constrained nonlinear problem.
I calculated the analytic expression of both gradient and Hessian, and
I'm passing both to FMINCON using the options ('GradObj','on') and
('Hessian','user-supplied'). The Hessian function is a separate defined function named @hessmgrp. It works, but I have a programming problem.

My Hessian is a function of two vectors: the target vector and another vector.
The input arguments of the Hessian function are only two, the target vector
and the Lagrange multipliers, that is

function h = hessmgrp(y,lambda)

Then, I have to pass the extra parameter to this function. I read the optim toolbox manual and found different solutions. Eventually, the only way I found is to define global variables and use them locally. It is not the best solution, as remarked in the manual.

Does anybody of you know how to pass extra parameters to
the Hessian function in a more appropriate way?

Thanks in advance
Marco

Steven Lord

unread,
Mar 21, 2010, 6:21:10 PM3/21/10
to

"Marco " <mari...@gmail.com> wrote in message
news:ho636m$g99$1...@fred.mathworks.com...

Anonymous function. Specify your Hessian function as @(y, lambda)
hessmgrp(y, lambda, whateverOtherParametersYouWant) [as long as
whateverOtherParametersYouWant are defined before you create this anonymous
function handle.]

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


Marco

unread,
Mar 22, 2010, 12:35:05 PM3/22/10
to
Thanks, it works now!
Marco

"Steven Lord" <sl...@mathworks.com> wrote in message <ho664c$rjl$1...@fred.mathworks.com>...

Manthos Vogiatzoglou

unread,
Mar 22, 2010, 6:21:20 PM3/22/10
to
Steven thank you for the very helpfull comment. I have exactly the same problem as Marco, however my constraints are linear therefore in my case the hessian of the objective is the same as the hessian of the Lagrangian. Does this change anything? In my case how should I pass the hessian function to optimset? @(y)HessianFcn(y,[],myextraparameters) or @(y,lambda)HessianFcn(y,lambda,myextraparameters) or in another way?

Thanks again!!!

Fang

unread,
Nov 6, 2013, 4:15:05 PM11/6/13
to
"Steven Lord" <sl...@mathworks.com> wrote in message <ho664c$rjl$1...@fred.mathworks.com>...
>
I tried this method, but I got an error message
Error Using
@(x, lambda)fun_hessian(x, lambda, k, S_T1, iS_T2, xy_h, xy_d)
Too many input arguments".

I have a function file:
function Hes=fun_hessian(x, lambda, k, S_T1, iS_T2, xy_h, xy_d)

And in my script:
hessinterior=@(x, lambda)fun_hessian(x, lambda, k, S_T1, iS_T2, xy_h, xy_d);
options = optimset('Algorithm','interior-point', 'GradObj','on', ...
'Hessian', 'user-supplied', 'HessFcn', hessinterior, 'UseParallel', 'Always');
[x, fval] = fmincon(@fun_f,x0,[],[],[],[],lb,ub,[],options, k, RFA, iS_T1, iS_T2);

What is the problem? Anyone can help? Thank you very much.

Torsten

unread,
Nov 7, 2013, 2:37:06 AM11/7/13
to
"Fang" wrote in message <l5ebgp$296$1...@newscl01ah.mathworks.com>...
The problem are the parameters k, RFA, iS_T1, iS_T2 in the call to fmincon.
You can't just add them to the usual calling list.

Best wishes
Torsten.

Fang

unread,
Nov 7, 2013, 3:50:19 AM11/7/13
to
"Torsten" wrote in message <l5ffv2$1nh$1...@newscl01ah.mathworks.com>...
Yes, you are right. Thank you very much.
0 new messages