Question: Opposite of infinitebound in Minimize (Optimization)?

I have multiple curves of the same function with different initial conditions, trying to find the most suitable initial condition (for initial cond's less than the optimal one the function breaks down at 0 and for ic's > the optimal value the function decreases to a minimum before blowing up to infinity) See below:

In trying to find this optimal initial condition (or there abouts) for lots of different curves of the same form, I've tried to store the minimum values of each curve somewhere using Minimize, but for the curves that break down I get the error

Error, (in Optimization:-NLPSolve) cannot evaluate the solution further right of xxxxx, maxfun limit exceeded (see ?dsolve,maxfun for details)

And the program exits the loop and doesn't move on to the next curve, I'd like to find a way for Minimize to just return zero or better NA (or equivalent) when it encounters this problem and move on. Is there any way to do this? My code is below

 

with(Optimization):

f1 := proc (r) options operator, arrow; (diff(p(r), r))/(r*p(r)) end proc:

f2 := proc (r) options operator, arrow; (1/4)*(diff(p(r), r))^2/p(r)^2 end proc:

f3 := proc (r) options operator, arrow; (1/2)*(diff(p(r), r, r))/p(r) end proc:

ode := 2*(diff(f1(r), r)-(diff(f2(r), r))+diff(f3(r), r))/r+diff(f1(r), r, r)-(diff(f2(r), r, r))+diff(f3(r), r, r)-mu(2*(diff(p(r), r))/r+diff(p(r), r, r)) = p(r):

ic3 := Array([seq(-.9 .. -.8, 0.1e-1)]):

curve := Array(1 .. 11):

for i to 11 do ics := p(0.1e-4) = 1, (D(p))(0.1e-4) = 0, ((D@@2)(p))(0.1e-4) = ic3[i], ((D@@3)(p))(0.1e-4) = 0; sol := dsolve({ics, ode}, p(r), numeric, output = listprocedure); curve[i] := rhs(sol[2]); mincurve[i] := Minimize(curve[i](r), assume = nonnegative) end do

Error, (in Optimization:-NLPSolve) cannot evaluate the solution further right of 3.7209455, maxfun limit exceeded (see ?dsolve,maxfun for details)

 

plot([curve[1](r), curve[2](r), curve[3](r), curve[4](r), curve[5](r), curve[6](r), curve[7](r), curve[8](r), curve[9](r), curve[10](r), curve[11](r)], r = 0 .. 10, y = 0 .. 1.05, labels = [r, rho])

 

``


 

Download checkmin.mw


Cheers!

 

EDIT the initial conditions were originally defined at 0.00001 as my previous function was undefined at zero, forgot to change this when I changed my function. However, with these now corrected the problem still stands.

Please Wait...