Error using lsqncommon (line 67)

Hi,
I have a case with an optim via lsqnonlin just trying to minimize a price but the lsqncommon is handing over my optim.
[x,resnorm,FVAL,Exitfalg,output] = lsqnonlin(G, I, lb, ub, options);
with G an function handled returning a price difference between two set.
I = [0.1 0.1 0.1 0.1 -1];
the returned error is as follow Error using lsqncommon (line 67) The Levenberg-Marquardt algorithm does not handle bound constraints and the trust-region-reflective algorithm requires at least as many equations as variables; aborting
lb = [0 0 0 0 -1];
ub = [1 1 1 1 1];
Would you provide a support?
thanks.

6 Kommentare

Star Strider
Star Strider am 4 Sep. 2015
What is the code for your ‘G’ function? From the error text, it may be the problem.
DIMITRY
DIMITRY am 4 Sep. 2015
it is simply a function handled @(x)FunctionHandle wich is simply returning a substract of two sets...do not think it is the issue since the optim is working for another solution.
The output of the function handled is 4.1859 with an initial set of value as
I = [0.6434 0.1705 0.0049 0.0198 -0.9509];
The error is when runing the lsqnonlin on the 4.1859 non lin syst as it do not seems to recognize the trust region algo. This is how I have spec the options
options = optimoptions('lsqnonlin','disp','iter','MaxFunEvals',1000,'TolFun',1e-5,'Algorithm','trust-region-reflective');
I have tried with different initial values without success.
Please help!
DIMITRY
DIMITRY am 4 Sep. 2015
Any Idea?????
Star Strider
Star Strider am 4 Sep. 2015
No idea, because I still haven’t seen the code for ‘G’!
DIMITRY
DIMITRY am 4 Sep. 2015
Hey sorry! please formalize what you clearly need to save time!
In G please!!! it is simply x = (b - c) as an handled function! the function G returned 4.1859 as explained!
thanks for your reply!
Star Strider
Star Strider am 4 Sep. 2015
I really need to see the full code for ‘G’.
What parameter are you optimising with respect to?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 4 Sep. 2015
Bearbeitet: Matt J am 4 Sep. 2015

1 Stimme

You have 5 unknowns and therefore the trust region algorithm expects your G function to return at least 5 elements (representing 5 equations), so that the system is over-determined. Instead, though, your G() is returning a scalar.
It doesn't really make sense to be solving 1 equation in 5 unknowns, so you should probably get more equations from somewhere. Possibly, you've misinterpreted lsqnonlin and think that, like fmincon/fminunc,etc... lsqnonlin expects a scalarized objective function. It does not.

1 Kommentar

DIMITRY
DIMITRY am 4 Sep. 2015
Great thanks Matt, that is it in fact my G function is a substract of x = (b - c) where b is the target function output and c is a 5 factor function to be minimized by the lsqnonlin with the I vector as entry. so in c I have flex the 5 factors with the x output of the minimization. I am still taking a deeper look at it in the meantime...

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 4 Sep. 2015

Kommentiert:

am 4 Sep. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by