optim package question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

optim package question

Octave - General mailing list
Hi,

I am converting my matlab codes to octave, but I am having troubles with 2 commands below;

first: options=optimset('Algorithm','levenberg-marquardt','Jacobian','off','DerivativeCheck','off','TolX',1e-5,'TolFun',1e-5,'MaxIter',NIter,'display','off');

second: [XOut,ErrorTotal,ErrorPartial] = lsqnonlin('FETProcess_mod2a_Shuoqi',XGuess,XMin,XMax,options,Freq,SMeas,Scale);

From the octave manual, I think there's no "levenberg-marquardt" method in optimset and no lsqnonlin function.

Anyone can show me how to convert the above 2 commands?

Best Regards,

TsoMin



Reply | Threaded
Open this post in threaded view
|

Re: optim package question

Olaf Till-2
On Sun, Jun 30, 2019 at 01:55:49AM +0000, Tso-min Chou via Help-octave wrote:
> Hi,
> I am converting my matlab codes to octave, but I am having troubles with 2 commands below;
> first: options=optimset('Algorithm','levenberg-marquardt','Jacobian','off','DerivativeCheck','off','TolX',1e-5,'TolFun',1e-5,'MaxIter',NIter,'display','off');
>
> second: [XOut,ErrorTotal,ErrorPartial] = lsqnonlin('FETProcess_mod2a_Shuoqi',XGuess,XMin,XMax,options,Freq,SMeas,Scale);
> >From the octave manual, I think there's no "levenberg-marquardt" method in optimset and no lsqnonlin function.
> Anyone can show me how to convert the above 2 commands?
> Best Regards,
> TsoMin

Hi TsoMin,

the Octave manual is not the right place to get informations on a
package. For the optim package, you can try 'optim_doc' from the
Octave command line, or just 'help lsqnonlin' for your case. The
optimisation options are not defined by the 'optimset' function, but
by the individual optimization functions.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: optim package question

Olaf Till-2
On Sun, Jun 30, 2019 at 03:26:47PM +0000, Tso-min Chou wrote:

>  Hi Olaf,
> Thanks for the information. I looked at the optim_doc and it seems I
> can still use both optimset and lsqnonlin in Octave as in
> Matlab. But when I ran the code the error message points the issue
> is in function lsqnonlin.   error: Invalid call to lsqnonlin. 
> Correct usage is:  -- Function File: lsqnonlin (FUN, X0) -- Function
> File: lsqnonlin (FUN, X0, LB, UB) -- Function File: lsqnonlin (FUN,
> X0, LB, UB, OPTIONS) -- Function File: [X, RESNORM, RESIDUAL,
> EXITFLAG, OUTPUT, LAMBDA,          JACOBIAN] = lsqnonlin (...)error:
> called from    print_usage at line 91 column 5    lsqnonlin at line
> 184 column 5    Octave_ECP_optim at line 234 column 64 >From the
> original code [XOut,ErrorTotal,ErrorPartial] =
> lsqnonlin('FETProcess_mod2a_Shuoqi',XGuess,XMin,XMax,options,Freq,SMeas,Scale)
>
> I am not sure where I did run to call the function it looks correct to me.
> Best Regards,
> TsoMin
lsqnonlin in optim accepts only 5 arguments, so your 'Freq', 'SMeas',
and 'Scale' are two much for it. I don't find anything in Matlabs
lsqnonlin documentation saying that more than 5 arguments are
accepted. Can you give me a pointer to such information?

Also, it seems that lsqnonlin accepts only a function handle as the
first argument, not a name of a function. This is a bug (which can be
easily fixed, I'll do this soon), since according to Matlab
documentation a name of a function should be accepted, too.

Olaf

PS: At our mailing list it is regarded as good pratice to place
answers below the issue which is answerd (no 'top posting' --- see
https://en.wikipedia.org/wiki/Posting_style). It makes discussions
more readable.
And please keep the mailing list in CC.

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment