From bug-octave-request Thu May 27 10:51:38 1993 Subject: I think this is a bug From: esm (Edward Scott Meadows) To: bug-octave Date: Thu, 27 May 93 10:51:32 -0500 I'm having problems with a global parameter passed to the objective function for npsol. Here's the transcript of a bad octave session: --------------------Begin Bad------------------------------------------- Octave, version 0.71.8. Copyright (C) 1992, 1993, John W. Eaton. This is free software with ABSOLUTELY NO WARRANTY. For details, type `warranty'. octave:1> x0=rand(2,1) x0 = 0.750686 0.072777 octave:2> u=rand(3,1) u = 0.50838 0.84761 0.50798 octave:3> [u,obj,info]=npsol(u,'phi') error: `x0' undefined octave:3> x0 x0 = 0.750686 0.072777 octave:4> global x0 octave:5> [u,obj,info]=npsol(u,'phi') error: index invalid or out of range for scalar type octave:5> x0 x0 = 1 -------------End Bad----------------------------------------------- Note that phi (included below) doesn't alter x0. Simply declaring x0 to be global after forgetting doesn't work. npsol will never work again the correct way unless I quit and restart Octave. Here's the transcript of a good octave session: ------------Begin Good-------------------------------------------- Octave, version 0.71.8. Copyright (C) 1992, 1993, John W. Eaton. This is free software with ABSOLUTELY NO WARRANTY. For details, type `warranty'. octave:1> x0=rand(2,1) x0 = 0.75062 0.92573 octave:2> u=rand(3,1) u = 0.30012 0.13089 0.97077 octave:3> global x0 octave:4> [u,obj,info]=npsol(u,'phi') u = -0.916283 0.096027 0.034535 obj = 2.3779 info = 0 octave:5> x0 x0 = 0.75062 0.92573 octave:6> ---------End Bad-------------------------------------------------------- Here are f and phi, which are called from within npsol: function out=phi(u); out=u'*u+x0'*x0; x=x0; for i=1:max(size(u));x=f(x,u(i));out=out+x'*x;end; return; end; function out=f(x,u); out=0*ones(2,1); out(1)=x(1)+u; out(2)=x(2)+u**3; return; end;