Hello everyone,
I have already read a similarly post on this forum but it has not helped me.
I need to do a lot of simulations and sensitivity propagation of the same ODE with different initial values/parameters.
doing it in a sequential way works fine, but doing in parallel, the codes crashes ( I have already considered all issues regarding MATLABs Parallel Computing Toolbox). I'm running it on my PC ,using 4 cores of my CPU. After removing any parts containing CasADi calls, the code works without errors.
a simplified version of the code:
%% done before
opts = struct('tf',T,'abstol',abstol,'reltol',reltol);
I = integrator('I', 'cvodes', dae, opts);
....
for k=1:N
x0= X0(k,:); % vector with all the initial values
u0 = U0(k,:);
res = I('x0',x0,'p',u0);
a(k) = [full(res.xf)]
% even putting the part of evaluating the integral into a matlab function does not help. for example crating a function... res = integrate_casadi(I,x0,u0);
end
replacing for with parfor does not work , even thought are iterates are independent,
MATLAB gives following error code:
Warning: While saving an object of class 'casadi.Function':
Serializing SWIG objects not supported.
> In parallel.internal.pool.serialize (line 21)
In distcomp.remoteparfor/addInterval (line 103)
In parallel_function>distributed_execution (line 780)
In parallel_function (line 587)
...
Warning: A worker aborted during execution of the parfor loop. The parfor loop will now run again on the remaining workers.
> In parallel_function (line 596)
...
Error using parallel_function (line 604)
All workers aborted during execution of the parfor loop.
Any help is appreciated. Thank you.
Best,
Armin