[Scilab-users] Least squares problem call to fmincon - HELP

Stéphane Mottelet stephane.mottelet at utc.fr
Fri Jan 10 15:32:51 CET 2020


Did you try one of the examples provided in the help page of fmincon (as 
a sanity test of FOT) ?

I don't see any stupid error in your code.

S.

Le 10/01/2020 à 15:25, David Brant a écrit :
> Many thanks for getting back Stéphane. I tried your suggestion with the
> gradient option, but got a problem:
>
>   !--error 26
> Too complex recursion! (recursion tables are full)
> at line       2 of function fun called by :
> at line       2 of function fGrad called by :
> sample_fGrad=fGrad(x0)
> at line     649 of exec file called by :
> init=fun(x0)
>
> The minimalist call also returned a problem:
>
> y=numderivative(fun,x)
>                         !--error 4
> Undefined variable: 10000000000000G*1000100
> at line      29 of function flag1 called by :
> at line      16 of function fGrad1 called by :
> init=fun(x0)
> at line     842 of exec file called by :
> API Error:
> in error: bad call to getVarAddressFromPosition! (1rst argument).
>
> Probably a stupid error on my part, but cannot spot it!
>
> Code:
> function z=fun(p)
> 	z=DAT(:,2)-p(1)*exp(p(2)*DAT(:,1))-p(3)*ones(DAT(:,1))
> endfunction
>
> //function dz=dfun(p)
> //	var=exp(p(2)*DAT(:,1))
> //	dz=[-var..
> //	-p(1)*DAT(:,1).*var..
> //	-ones(var)]
> //endfunction
>
> function f=costf(p)
> 	f = norm(fun(p))^2;
> endfunction
>
> //function g=grad(p)
> //	g = 2*dfun(p)'*fun(p);
> //endfunction
>
> DAT=[0 0;0 1;1 1;2 1.5;2 2];
> p0=[0 0 0];
>
> xopt = fmincon(costf,p0,[],[])
>
> //options = list("GradObj",grad)
> //xopt = fmincon(costf,p0,[],[],[],[],[],[],[],options)
>
> fmincon.sce <https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/mailinglists.scilab.org/file/t490392/fmincon.sce>
>
>
>
> --
> Sent from: https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet




More information about the users mailing list