Using Numerical Integration in Multistart with Parallel Computing
4 views (last 30 days)
Show older comments
I have an optimization problem that I want to use Multistart on. When I do it without parallel processing, the results are fine, but it's slow. When I turn on parallell processing, I get the error "MultiStart encountered failures in the user provided functions" with an exitflag of -10. I believe this is due to using ODE113 in the objective function. How do I use ODE113 inside of MultiStart like this? My code is as follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tspan = 3E7;
problem = createOptimProblem('fmincon','objective',@(x)obj_fcn(x(1),x(2),tspan),'x0',[-4.4,4.8,tspan],'lb',[-50,-50,tspan],'ub',[50,50,tspan], 'options',optimset('Algorithm','sqp'));
ms = MultiStart('UseParallel','always','Display','iter');
matlabpool open
[x fval eflag output manymins] = run(ms,problem,10);
matlabpool close
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function obj = obj_fcn(Vx0,Vy0,tspan)
options = odeset('AbsTol',1E-12,'RelTol',1E-12);
[~,x] = ode113(@ODEs,tspan,[0 0 0 Vx0 Vy0 0],options);
obj = (x(end,1)*x(end,1) + x(end,2)*x(end,2) + x(end,3)*x(end,3));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function x_dot = ODEs(t,x)
mu = 1.327124400180000e+011; n0 = 1.990983289296242e-007; a0 = 149597890;
d = ((a0+x(1))^2 + x(2)^2 + x(3)^2)^(3/2);
x_dot(1) = x(4);
x_dot(2) = x(5);
x_dot(3) = x(6);
x_dot(4) = 2*n0*x(5) + n0^2*x(1) - mu*(a0+x(1))/d + mu/(a0^2);
x_dot(5) = -2*n0*x(4) + n0^2*x(2)-mu*x(2)/d;
x_dot(6) = -mu*x(3)/d;
x_dot = x_dot';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Any help would be appreciated!
0 Comments
Answers (0)
See Also
Categories
Find more on Global or Multiple Starting Point Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!