[Scilab-users] Help with Jacobian call to Optim

David Brant brantosaurus at hotmail.com
Mon Jan 6 19:14:40 CET 2020


Hi, i am having problems with the below code.

It is a variation of an example listed in the optimization chapter of the
Modelling and Simuation in Scilab-Scicos book (pages 109-110 &114). I can
configure the code to work for leastsq and lsqrsolve, but not optim. Any
advice on mods would be very much appreciated. Regards, Dave

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,g,ind]=costf(p,ind)
	f=fun(p); g=dfun(p)
endfunction
DAT=[0 0;0 1;1 1;2 1.5;2 2]
p0=[0 0 0];
[fopt,popt]=optim(costf,p0)
[fopt,popt,gopt]=optim(list(NDcost,fun),p0')

Rsponse:
!--error 98 
Variable returned by scilab argument function is incorrect.



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



More information about the users mailing list