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

David Brant brantosaurus at hotmail.com
Thu Jan 9 22:32:31 CET 2020


How may i (if possible?) reconfigure the least-squares problem to be solved
with a minimalist call to fmincon (from the fossee toolbox)?

I tried everything, but must be (seriously?) overlooking something! Perhaps
something like:

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,g,ind]=costf(p,ind)
//	f=fun(p); g=dfun(p)
//endfunction

function [f,g,ind]=costf(p,ind)
	f=norm(fun(p))^2;
//	g=2*dfun(p)'*fun(p);
	g=2*numderivative(fun,p)'*fun(p);
endfunction

DAT=[0 0;0 1;1 1;2 1.5;2 2];
p0=[0 0 0];
A=[]; b=[];

[popt,fopt]=fmincon(costf,p0,A,b);
disp(popt,'popt',fopt,'fopt');
fmincon.sce <http://mailinglists.scilab.org/file/t490392/fmincon.sce>  
Dave



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html



More information about the users mailing list