Nimd_at

10 Reputation

One Badge

1 years, 57 days

MaplePrimes Activity


These are questions asked by Nimd_at

I am trying to adapt the code with Direct Search 2 for my needs but do not quite understand the syntaxis :( . I have system with 8 first order but nonlinear odes and 20 parameters but for starters I fix most of them (to estimate time consumption for full calculations etc). The part of the code where it ``breaks'' looks as follows:

#argument
X0:=Vector([24, 36, 48, 60, 72, 84], datatype = float):
#value
Y0:=Vector([13.8e+9, 12.13333333e+9, 10.7e+9, 10.5e+9, 9.8e+9, 10.1e+9], datatype = float):

#so this is the data - time in X0 and corresponding observables (at that time instances) at Y0


par_sol:=dsolve(dsys, numeric, range=0..85,  parameters=[eta_L, L0]);

#parametric numerical solution with eta_L parameter of the model and L0 initial condition to fit

ffit2 := proc(etaLValue, L0Value, tValue) global old_eta, old_L0; local res;
if not [etaLValue, L0Value,tValue]::list(numeric) then
      return 'procname'(args); end if;
if old_eta<>etaLValue and old_L0<>L0Value then
      (old_eta,old_L0) := etaLValue,L0Value;
      par_sol('parameters'=[eta_L=etaLValue,L0=L0Value]);
   end if;
   res:=rhs(par_sol(tValue)[4]); end proc;


# this is just adapted copy of your function

 

par_sol(parameters=[eta_L=0.004, L0=1.1e10]);

par_sol(84)[4];ffit2(0.004, 1.1e10, 84);

#their output coincide OK; same for another trio of parameters

DS2:=CodeTools:-Usage(
        DirectSearch:-DataFit(ffit2,X0,Y0,t,
                              [ eta_L=0.001 .. 0.1, L0=1.5e10 .. 1.7e10
 #                               
                              ] )
);

#and here it breaks:

Warning, initial point [L0Value = .9, tValue = .9] does not satisfy the inequality constraints; trying to find a feasible initial point
Error, (in DirectSearch:-Search) cannot find feasible initial point; specify a new one


But tValue is a time variable - I integrate over it, it is not a parameter to fit - I evaluate ffit2 at it. So basically ffit2 return exactly the model value which need to be fited with data in Y0 at times specified in X0. I thought it is easier than the other problems I saw in examples with Direct Search 2 and still I can't get through syntax neither with it not with NonlinearFit of core Maple...

I would appreciate if you could point me what I am doing wrong. Just in case I also attach full version of the file.01test.mw

Thank you in advance!

Page 1 of 1