improving the speed of parallel optimization

2 vues (au cours des 30 derniers jours)
sensation
sensation le 4 Juin 2018
Commenté : sensation le 28 Juin 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

Réponses (2)

Walter Roberson
Walter Roberson le 4 Juin 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 commentaires
sensation
sensation le 21 Juin 2018
Any idea Walter? Thanks!
Walter Roberson
Walter Roberson le 21 Juin 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.

Connectez-vous pour commenter.


Matt J
Matt J le 21 Juin 2018
Modifié(e) : Matt J le 21 Juin 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 commentaires
Matt J
Matt J le 26 Juin 2018
Modifié(e) : Matt J le 26 Juin 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 le 28 Juin 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!

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by