Hi all,
I wanted to parallel compute optimizations with different starting points to increase the chance of reaching a global minimum (non-convex problem).
I am therefore using a parfor loop:
parfor i=1:5
assign(Pr,gas.node(:,9)*ones(1,horizon)); % assign initial values
assign(Si,gas.node(:,10)*ones(1,horizon).*rand);
assign(shedg,zeros(nnode,horizon)); % assign initial values
exitflag = optimize(Constraints,Objective,options) % run optimization
end
However it looks like the assign function cannot be used with the workers:
Error using Gaspar (line 120)
An UndefinedFunction error was thrown on the workers for 'assign'. This might be because the file containing 'assign' is not
accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the
documentation for 'parallel.Pool/addAttachedFiles' for more details.
Caused by:
Undefined function 'assign' for input arguments of type 'double'.
Is there a way to solve this?
Thanks in advance!
Kind regards,
Michiel