improving the speed of parallel optimization
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (2)
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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.
Matt J
am 21 Jun. 2018
Bearbeitet: Matt J
am 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 Kommentare
Matt J
am 26 Jun. 2018
Bearbeitet: Matt J
am 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.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!