[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: leasqr with bounds
From: |
Francesco Potortì |
Subject: |
Re: leasqr with bounds |
Date: |
Mon, 29 Jan 2018 11:43:49 +0100 |
>I am new to the use of octave and I have tried to use the leasqr function
>for the adjustment of some experimental data. Given the characteristics of
>the adjustment function, some of the parameters to be adjusted must be
>within certain limits (since they have a certain physical meaning). I wanted
>to use the "bounds" option to limit the possible values that these
>parameters can have.
>
>In order to test the operation of the leasqr function I tried with the
>following
>
>x=[1:10]
>y= [10,8,5.5,3.5,0,1.2,2.5,4.6,7.5,9.8]
>F=@(x, p) (p (1) * x .^ 2 + p (2) * x + p (3))
>a=1
>b=1
>c=1
>p = [a,b,c];
>
>wt=ones(size(x));
>iter=400;
>tol=0.000000001;
>dFdp="dfdp";
>dp=0.001*ones(size(p));
>[f, pfit, kvg, iter, corp, covp, stdresid, Z, r2] = leasqr (Temp_bkg,
>Int_Prom_bkg, par, F,tol, iter,wt, dp, dFdp);
>
>and gives this results;
>
>f =
>
> 10.8900
> 7.2773
> 4.5502
> 2.7086
> 1.7527
> 1.6824
> 2.4977
> 4.1986
> 6.7852
> 10.2573
>
>pfit =
>
> 0.44280
> -4.94114
> 15.38833
>
>kvg = 1
>iter = 6
>
>Assuming I want parameter 3 to be within the limit -1 and 1
>
>bounds =[-5,5; -5,5; -1,1 ]
>
>it gives me
>
>[f, pfit, kvg, iter, corp, covp, stdresid, Z, r2] = leasqr (x, y, p, F,tol,
>iter,wt, dp, dFdp, bounds)
> CONVERGENCE NOT ACHIEVED!
>f =
>
> 10.8516
> 7.2616
> 4.5519
> 2.7225
> 1.7732
> 1.7041
> 2.5153
> 4.2067
> 6.7783
> 10.2302
>
>pfit =
>
> 0.44011
> -4.91026
> 15.32171
>
>kvg = 0
>iter = 6
>
>As I said, this is a function invented to test the operation.
>I have tried with my experimental data and it does not work either.
>
>I expected that by limiting the possible values of parameter 3, the
>iterations would give a function that may not be the best, but that has the
>parameter 3 with values within the allowed ones
I have used leasqr in the past, but never with bounds. Leasqr is a
complicated beast. I would try with a more gradual approach. As far as
I understand, when unbounded you obtain p3=15.3. Then instead of
forcing [-1,1] bounds try something easier, for example [-15,15] and see
what happens.
Also, try playing with the convergence options, maybe there is a
possibility of increasing the number of iterations, or you should change
the fractional precision or step change?
As a last suggestion, maybe you can sqp, described in Octave's manual at
"Nonlinear programming", or have a look at the many alternatives offered
by the optim package at
<https://octave.sourceforge.io/optim/package_doc/index.html>. I haev no
experience with any of these alternatives.
--
Francesco Potortì (ricercatore) Voice: +39.050.621.3058
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it