Question: Minimize doesn't work with dsolve procedure?

December 07 2013 PunkRediska 15

0

Minimize doesn't work with dsolve porcedure?

experiment_real.mw

tr := proc (x, y)::integer; tr := x+y; result := x^(2+y) end proc

Warning, `result` is implicitly declared local to procedure `tr`

 

tr(5, 5)

78125

(1)

with(Optimization); Minimize(tr(x, y), x = 0 .. 1000, y = 1 .. 1, initialpoint = {x = 25, y = 1})

[0.117556065072605623e-15, [x = HFloat(4.898709434833346e-6), y = HFloat(1.0)]]

(2)

xxx := 97.39391293; yyy := -1.588898710

-1.588898710

(3)

xx := 100;

3

(4)

trool := proc (leng, alpha)::integer; global psi, zx, zy, xx, yy, xxx, yyy, sa, ca, ps, Vx, Vy, vx, vy, ode, ics, XX, YY, trool, G, str, start, ds; sa := evalf(sin(alpha)); ca := evalf(cos(alpha)); ps := evalf(evalc(Im(evalc(str*(x+I*y)-((1/2)*I)*G*ln(x+I*y-start)/Pi)))); psi := ps; xxx := evalf(xx+leng*ca); yyy := evalf(yy+leng*sa); Vx := diff(psi, y); Vy := -(diff(psi, x)); vx := Re(evalf(subs(x = xxx, y = yyy, subs(vvx = Vx, vvx)))); vy := Re(evalf(subs(x = xxx, y = yyy, subs(vvy = Vy, vvy)))); proc (X) options operator, arrow; X(t) end proc; proc (Y) options operator, arrow; Y(t) end proc; zx := proc (t) options operator, arrow; evalf(subs(x = X(t), y = Y(t), subs(vvx = Vx, vvx))) end proc; zy := proc (t) options operator, arrow; evalf(subs(x = X(t), y = Y(t), subs(vvy = Vy, vvy))) end proc; ode := diff(X(t), t) = zx(t), diff(Y(t), t) = zy(t); ics := X(0) = xxx, Y(0) = yyy; ds := dsolve([ode, ics], type = numeric, [X(t), Y(t)], method = rkf45, maxfun = 0, output = listprocedure, abserr = 0.1e-3, relerr = 0.1e-3, minstep = 0.1e-1); XX := rhs(ds[2]); YY := rhs(ds[3]); trool := XX(0.1e-3) end proc:

with(Optimization); Minimize(trool(alpha, leng), assume = nonnegative, alpha = 0 .. 2*Pi, leng = .2 .. 2, iterationlimit = 1000, initialpoint = {alpha = 1, leng = 1})

Error, (in XX) parameter 'alpha' must be assigned a numeric value before obtaining a solution

 

alpha = 0 .. 2*Pi, leng = .2 .. 2, output = solutionmodule

alpha := 1; leng := 1; XX(10)

HFloat(100.54666738117751)

(5)

``

trool(1, 11)

HFloat(100.00711298362239)

(6)

psi

3.*y-11.93662073*ln((x-100.)^2+y^2)

(7)

``

 

Download experiment_real.mw

with trool procedure minimize dosent work .... and its make me realy sad, couse i need to optimize alpha and leng in other (big one) porcedure with same dsolve.

get this errors:
"Warning, The use of global variables in numerical ODE problems is deprecated, and will be removed in a future release. Use the 'parameters' argument instead (see ?dsolve,numeric,parameters)"
"Error, (in XX) parameter 'alpha' must be assigned a numeric value before obtaining a solution"

Please Wait...