improving the speed of parallel optimization

1 view (last 30 days)
sensation
sensation on 4 Jun 2018
Commented: sensation on 28 Jun 2018
Hi, I am trying to optimize in parallel but the speed is increased just slightly by using parfor. Do you have any further recommendations? Thanks!
parfor i = 1:M
options = optimset('MaxFunEvals',Inf,'MaxIter',10,...
'Algorithm','interior-point','Display','iter');
startTime = tic;
[x(:,i),fval(:,i)] = fmincon(@(x)revenue(price(1:N,1),ro,g,eff,x,N,k1,init_s(i),inFlow(:,i),alpha_par(i),b_par(i)),x0(1:2*N,i),A,b(:,i),Aeq,beq(:,i),LB(:,i),UB(:,i),[],options);
time_fmincon_parallel = toc(startTime);
fprintf('Parallel FMINCON optimization takes %g seconds.\n',time_fmincon_parallel);
end

Answers (2)

Walter Roberson
Walter Roberson on 4 Jun 2018
Instead of running the fmincon calls in parallel, try running them in a loop, but using the option UseParallel to allow parallel estimation of the gradient.
Remember, it is common for Parallel processing to be slower than serial, depending on the amount of data to be transferred compared to the amount of work to be done per iteration, and taking into account that non-parallel workers can use the built-in parallelization of some operations on large "enough" matrices by calling into LaPACK / MKL.
  9 Comments
Walter Roberson
Walter Roberson on 21 Jun 2018
If I recall correctly, with N even close to that large, asking matlabFunction to optimize the code takes far far too long, so I do not think you are going to be able to take advantage of that.

Sign in to comment.


Matt J
Matt J on 21 Jun 2018
Edited: Matt J on 21 Jun 2018
This is a more optimal implementation of storage(),
function S=storage(init_s,inFlow,x,N)
D=inFlow-totalflow(x,N);
D(1) = D(1) + ( init_s(1) + D(1) );
S=cumsum(D);
end
  14 Comments
Matt J
Matt J on 26 Jun 2018
Edited: Matt J on 26 Jun 2018
I have implemented those suggestions and its a bit faster
How fast is it now? It should have been a lot faster than what you were doing.
Do you know maybe how I can run it with quadprog instead of fmincon?
The problem doesn't look quadratic, except maybe when b_par=1.
sensation
sensation on 28 Jun 2018
With N being 4000 time steps, the optimization is quite long. It is a bit faster 1.2 times.
I was thinking to run fmincon with supplied hessian and gradient maybe. I run it in parallel with parfor but still not efficient.
If you have any idea to make it feasible, would appreciate it a lot Matt. Thanks!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!