Hi,I understood that the difference between computation speed of these two matlab code (1- use gams() function to compute quadratic programming in matlab in a loop2- use matlab quadprog() function in a loop) is not because of GAMS problem or GDXMRW utility problem but it is because of matlab priority in this case.I measured the computation time of gams() function and quadprog() function in every iteration , in the first iteration quadprog() takes 0.4 sec and gams() takes 0.3 sec.(it means that gams was a bit faster than matlab optimization toolbox function) .but I surprisingly saw that in subsequent iterations gams() computation did not changed significantly but quadprog() computation time was 0.02 sec.(20 times faster) (I should mention that I changed the constraints in every iteration).I tested this several times, in different problems, and the result was: when recalling matlab quadprog() for secend time in a code, the computation speed, become very faster. in another experiment I used "clear all" command in matlab in every iteration, and I saw that the computaion speed was the same (0.4 sec) in all the iterations.I guess matlab use past experiences and this is the reason that it is faster when executing the optimization function for more that one time. I don't know what are these (experience or configurations or .... )? and what can I do to speed up my gams optimization problem, when using it in matlab code, the computation speed is very important for me. so I would really appreciate if you could tell me how I can speed up my optimization problem.Best,Salman
On Thursday, April 11, 2013 7:23:03 AM UTC+4:30, salman wrote:--Hi,
after hours of working to make a link between gams and matlab, finally i made it. I learned how to use gams in a matlab loop to solve a quadratic programming problem via GDXMRW utility (gams() ). the problem is : when i use gams in a matlab loop to solve the quadratic programming problem, it is 10 times slower than using matlab quadprog function in the loop. I found that gams solve the problem faster than matlab when using gams out of the loop (execute for 1 time) but in the loop I don't know what happens that cause delay.
additionally i used gams() without any input and output arguments but it was still slow.
my operating system is windows7 64bit and i use gams 24.0.2 64bit and matlab 2010a64bit.
my final goal is to use gams in matlab to solve a mixed integer nonlinear programming problem that matlab can not solve itself, and I should solve this problem 2000 times in a loop. because of this, computation speed is very important for me.
I would really appreciate if you could help my solve this problem.
Best Regards,
Salman.
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
%-------------------may gams code-------------------------------
$set matout " 'matsol.gdx', z, x, cons, mdlstat, solstat ";
set i /1*2/,
id(i) /1*2/;
set j /1*3/;
parameters f(i);
parameters bineq(j);
parameter h(i,i);
parameter Aineq(j,i);
$if exist matdata.gms $include matdata.gms
scalar mdlstat,solstat;
positive variables x(i);
variable z;
equations obj,cons(j);
obj.. z=E= sum(i,0.5*x(i)*sum(id,h(i,id)*x(id)))+sum(i,f(i)*x(i));
cons(j).. sum(i,Aineq(j,i)*x(i) )=l=bineq(j);
model salmanqp /All/
solve salmanqp USING QCP MINIMIZING z ;
mdlstat=salmanqp.modelstat;
solstat=salmanqp.solvestat;
execute_unload %matout%;
% -------------------------- my matlab code-------------------------------------
clc;clear all;close all;
ii={'1','2'};
jj={'1','2','3'};
H0=[1,-1;-1,2];
f0=[-2;-6];
Aineq0=[1,1;-1,2;2,1];
bineq0=[4;2;3];
for t=1:5
H0=randi(50,2,2);
f0=-randi(100,2,1);
Aineq0=randi(80,3,2);
bineq0=randi(10,3,1);
H.name='h';
H.val=H0;
H.uels={ii,ii};
H.form='full';
f.name='f';
f.form='full';
f.val=f0;
f.uels={ii};
Aineq.name='Aineq';
Aineq.form='full';
Aineq.val=Aineq0;
Aineq.uels={jj,ii};
bineq.name='bineq';
bineq.form='full';
bineq.val=bineq0;
bineq.uels={jj};
tic;
gamso.output='Std';
gamso.show='invisible';
[z1 ,x1,cons,modelstat,solverstat] = gams('salman QCP=conopt',H,f,Aineq,bineq);
x1
z1
toc
tic;
% clear all;
H1=H.val;
f1=f.val;
bineq1=bineq.val;
Aineq1=Aineq.val;
lb=zeros(2,1);
options=optimset('LargeScale','off');
[x,fval,~,~]=quadprog(H1,f1,Aineq1,bineq1,[],[],lb,[],[],options)
toc
end
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/36ZKIQHBdx8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
hi dear
Dear
Visit this group at http://groups.google.com/group/gamsworld.
--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.