Gams in matlab loop

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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

Hi,I understood that there is no problem with Gams and also GDXMRW utility. In Matlab, I measured time duration that Gams solve the quadratic programming problem in each iteration of the loop, and it was approximately the same. I also did it with Matlab quadprog function( matlab optimization toolbox) and I surprisingly saw that the first iteration takes 0.4 second and the other subsequent iterations take 0.02 second (inequality constraints change in every iteration) .

I’m very interested to know what MatLab has done and what can I do to increase optimization speed in Gams.

Best

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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

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 loop
2- 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

Salman,

It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving. This is also possible when using GAMS, but to say more some additional detail would be helpful. Specifically, what is changing in the sequence of QPs, and what stays constant?

-Steve


On Thu, Apr 11, 2013 at 4:44 PM, salman wrote:

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 loop
2- 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.





\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

Hi Mehdi,
Sure, I emailed you, the files and information that is needed.

Best,
Salman.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

Hi Steve,

I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
obj: 0.5 *transpose(x)Hx + transpose(f)x
constraint: Ax Salman,

It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving. This is also possible when using GAMS, but to say more some additional detail would be helpful. Specifically, what is changing in the sequence of QPs, and what stays constant?

-Steve

On Thu, Apr 11, 2013 at 4:44 PM, salman wrote:

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 loop
2- 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.


--
To unsubscribe from this group and stop receiving emails from it, send an email to <gamsworld+unsubscribe@googlegroups.com>.
To post to this group, send email to <gamsworld@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.


Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

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+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

Salman,

There is a certain amount of overhead that is introduced when you run a loop in Matlab and call gams each time in the loop. It’s not necessarily a large overhead, but it can seem large compared to the amount of work required to solve a QP with 2 vars and 3 constraints. I am attaching a .zip file with an example that demonstrates what I mean. A few things to note about the example:

  1. It uses the save/restart and solvelink=5 features of GAMS (documented in the User’s Guide) to minimize the startup time and solver-call times required by the gams calls in the loop.
  2. No data is passed on the gams() call: it runs a generic GAMS model that can be run independently of Matlab and can be used with save/restart.
  3. The average time for the trivial GAMS call (no new data, solve the QP starting from solution, do not read results back to Matlab): .055 seconds/iteration.
  4. The average time for the real GAMS call (new data, solve from base solution, results back to Matlab): .064 seconds/iteration.

I did these runs on a Dell XPS13 laptop with a solid-state disk which I believe helps keep the startup time for GAMS low. I used Matlab R2013a and GAMS 24.0.2 as we ship it.

My conclusion: in my computing environment, the overhead required to call gams is only large compared to the solve time for a very tiny model. .055 seconds/run is something that is typically noise when solving larger, more challenging models.

HTH,

Steve


On Sun, Apr 14, 2013 at 4:45 AM, Salman wrote:

Hi Steve,

I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
obj: 0.5 *transpose(x)Hx + transpose(f)x
constraint: Ax Salman,

It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving.  This is also possible when using GAMS, but to say more some additional detail would be helpful.  Specifically, what is changing in the sequence of QPs, and what stays constant?

-Steve


On Thu, Apr 11, 2013 at 4:44 PM, salman  wrote:

    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 loop
    2- 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.


    --

solveCompare.zip (1.92 KB)

Dear Steve,

Thanks a lot, your modifications was very effective and instructive. I learned to use save/restart and wgdx, rgdx for transferring data and many other things. The average time reduced from 0.5sec to

  1. 0.204 seconds/iteration (for trivial GAMS call)
  2. 0.206 seconds/iteration (for real GAMS call)
    in my laptop (ASUS N43S with a rotating hard drive).

Kind Regards,

Salman







On 04/15/2013 10:34 ب.ظ, Steven Dirkse wrote:

Salman,

There is a certain amount of overhead that is introduced when you run a loop in Matlab and call gams each time in the loop. It’s not necessarily a large overhead, but it can seem large compared to the amount of work required to solve a QP with 2 vars and 3 constraints. I am attaching a .zip file with an example that demonstrates what I mean. A few things to note about the example:

  1. It uses the save/restart and solvelink=5 features of GAMS (documented in the User’s Guide) to minimize the startup time and solver-call times required by the gams calls in the loop.
  2. No data is passed on the gams() call: it runs a generic GAMS model that can be run independently of Matlab and can be used with save/restart.
  3. The average time for the trivial GAMS call (no new data, solve the QP starting from solution, do not read results back to Matlab): .055 seconds/iteration.
  4. The average time for the real GAMS call (new data, solve from base solution, results back to Matlab): .064 seconds/iteration.

I did these runs on a Dell XPS13 laptop with a solid-state disk which I believe helps keep the startup time for GAMS low. I used Matlab R2013a and GAMS 24.0.2 as we ship it.

My conclusion: in my computing environment, the overhead required to call gams is only large compared to the solve time for a very tiny model. .055 seconds/run is something that is typically noise when solving larger, more challenging models.

HTH,

Steve

On Sun, Apr 14, 2013 at 4:45 AM, Salman wrote:

Hi Steve,

I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
obj: 0.5 *transpose(x)Hx + transpose(f)x
constraint: Ax     It takes about 0.5 sec for gams to compute this optimization problem and return the results to the matlab. by deleting the "solve" statement in my gams  code, this time reduced to 0.2 sec. it means that gams solve this optimization problem in 0.3sec (0.5-0.2=0.3).
 In a matlab loop, I solved this problem 5 times with gams() function and 5 times with matlab quadprog() function. and in each iteration I changed the constraint (A,b) and objective function (H,f).  the time duration to solve this problem for gams() was: 0.55, 0.53, 0.54, 0.59, 0.53 sec and for quadprog() was : 0.41, 0.06, 0.04, 0.04, 0.002 sec.

Best,
Salman.

%-------------------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






On 04/12/2013 01:44 ق.ظ, Steven Dirkse wrote:
Salman,

It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving.  This is also possible when using GAMS, but to say more some additional detail would be helpful.  Specifically, what is changing in the sequence of QPs, and what stays constant?

-Steve


On Thu, Apr 11, 2013 at 4:44 PM, salman  wrote:

    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 loop
    2- 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.


    --
    To unsubscribe from this group and stop receiving emails from it, send an email to <gamsworld+unsubscribe@googlegroups.com>.
    To post to this group, send email to <gamsworld@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.






--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181
<sdirkse@gams.com>
http://www.gams.com
--
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+unsubscribe@googlegroups.com>.

To post to this group, send email to <gamsworld@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.
--
To unsubscribe from this group and stop receiving emails from it, send an email to <gamsworld+unsubscribe@googlegroups.com>.
To post to this group, send email to <gamsworld@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.


Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

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+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@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.

\

Hi Steven,

I ran your same files, but also compared it with the following time:
%base time
tic
for t=1:N
wgdx(‘QPdata’, H, f, Aineq, bineq);
gams(‘base.gms’);
end
toc/N
This would be the time for a naive gams call, where I read the data in each time.
I observe the following wall clock time:
Base time: 0.04 secs/iteration
Trivial gams call: 0.039 secs/iteration
real gams call: 0.04 secs/iteration

When I turn solvelink = 0, all the 3 runs take 0.09 secs per iteration. So by leaving gams open in the shell, the start up time is reduced.

However, there appears to be no savings from the save and restart commands.

I am running some large problems where the model generation time takes about 6 secs, but solve time is < 1 sec. I would like to eliminate my NLP model generation time. By using the save and restart commands, I was hoping that this time would be eliminated and any execution time parameters would be loaded into the saved model file that gams understands, without having to generate the model all over again. Is gams capable of doing that, or every time a parameter changes, the entire model needs to be generated from scratch? Is there a way around that?

Thanks,
Ajit


On Wednesday, 10 April 2013 22:53:03 UTC-4, 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Ajit,

I found this question a bit confusing. You mention Matlab runs in a loop, but your question seems to have nothing to do with Matlab. You mention save and restart, but there are no save/restart commands in the script you send. You have very small run times in the Matlab loop, but you mention a generation time of 6 seconds for some other model. So I’m not sure where to start.

It is true that by default GAMS regenerates the model and incurs some additional overhead as well each time it encounters a solve. If this becomes an issue there are ways to address it. Perhaps the place to start is by setting

option solvelink = %solvelink.LoadLibrary%;

prior to the solve. But if your model takes 6 seconds to generate and wrote:

Hi Steven,

I ran your same files, but also compared it with the following time:
%base time
tic
for t=1:N
wgdx(‘QPdata’, H, f, Aineq, bineq);
gams(‘base.gms’);
end
toc/N
This would be the time for a naive gams call, where I read the data in each time.
I observe the following wall clock time:
Base time: 0.04 secs/iteration
Trivial gams call: 0.039 secs/iteration
real gams call: 0.04 secs/iteration

When I turn solvelink = 0, all the 3 runs take 0.09 secs per iteration. So by leaving gams open in the shell, the start up time is reduced.

However, there appears to be no savings from the save and restart commands.

I am running some large problems where the model generation time takes about 6 secs, but solve time is < 1 sec. I would like to eliminate my NLP model generation time. By using the save and restart commands, I was hoping that this time would be eliminated and any execution time parameters would be loaded into the saved model file that gams understands, without having to generate the model all over again. Is gams capable of doing that, or every time a parameter changes, the entire model needs to be generated from scratch? Is there a way around that?

Thanks,
Ajit


On Wednesday, 10 April 2013 22:53:03 UTC-4, 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/groups/opt_out.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

hi dear

i have big problem with link matlab with the gams can you help me
i waana link matlab with gams for wind forecast consider a astochastic functtion in matlab or use matlab function
can you send me simple example gams file
thanks
best regards
rezaparker1@gmail.com


\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Dear Steve,

I have run the files you attached, and I am confused by how the files “matdata” and “matdata.gdx” are generated. Could you please explain more about it? Thanks a lot!

Yalin




On Monday, 15 April 2013 20:04:42 UTC+2, Steven Dirkse wrote:

Salman,

There is a certain amount of overhead that is introduced when you run a loop in Matlab and call gams each time in the loop. It’s not necessarily a large overhead, but it can seem large compared to the amount of work required to solve a QP with 2 vars and 3 constraints. I am attaching a .zip file with an example that demonstrates what I mean. A few things to note about the example:

  1. It uses the save/restart and solvelink=5 features of GAMS (documented in the User’s Guide) to minimize the startup time and solver-call times required by the gams calls in the loop.
  2. No data is passed on the gams() call: it runs a generic GAMS model that can be run independently of Matlab and can be used with save/restart.
  3. The average time for the trivial GAMS call (no new data, solve the QP starting from solution, do not read results back to Matlab): .055 seconds/iteration.
  4. The average time for the real GAMS call (new data, solve from base solution, results back to Matlab): .064 seconds/iteration.

I did these runs on a Dell XPS13 laptop with a solid-state disk which I believe helps keep the startup time for GAMS low. I used Matlab R2013a and GAMS 24.0.2 as we ship it.

My conclusion: in my computing environment, the overhead required to call gams is only large compared to the solve time for a very tiny model. .055 seconds/run is something that is typically noise when solving larger, more challenging models.

HTH,

Steve


On Sun, Apr 14, 2013 at 4:45 AM, Salman wrote:

Hi Steve,

I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
obj: 0.5 *transpose(x)Hx + transpose(f)x
constraint: Ax Salman,

    It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving.  This is also possible when using GAMS, but to say more some additional detail would be helpful.  Specifically, what is changing in the sequence of QPs, and what stays constant?

    -Steve


    On Thu, Apr 11, 2013 at 4:44 PM, salman  wrote:

        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 loop
        2- 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.


        --
        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.






    --
    Steven Dirkse, Ph.D.
    GAMS Development Corp.,  Washington DC
    Voice: (202)342-0180     Fax: (202)342-0181
    sdi...@gams.com
    http://www.gams.com
    --
    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.

    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.


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.





\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Hi everybody!
I’m trying to call a GAMS model from MATLAB, but every time it executes the the GAMS command , I get the " gdxxrw.exe has stopped working" error.The model reads the data from excel files(xls not xlsx) and I run the model within the gams IDE just fine! Moreover, when I remove the lines related to gdxxrw from the GMAS model the mentioned link(between GMAS and MATLAB) works correctly.
Any suggestion what the problem might be?
Thanks in advance
Fahimeh


On Friday, February 28, 2014 8:35:34 PM UTC+3:30, Yalin Huang wrote:

Dear Steve,

I have run the files you attached, and I am confused by how the files “matdata” and “matdata.gdx” are generated. Could you please explain more about it? Thanks a lot!

Yalin




On Monday, 15 April 2013 20:04:42 UTC+2, Steven Dirkse wrote:

Salman,

There is a certain amount of overhead that is introduced when you run a loop in Matlab and call gams each time in the loop. It’s not necessarily a large overhead, but it can seem large compared to the amount of work required to solve a QP with 2 vars and 3 constraints. I am attaching a .zip file with an example that demonstrates what I mean. A few things to note about the example:

  1. It uses the save/restart and solvelink=5 features of GAMS (documented in the User’s Guide) to minimize the startup time and solver-call times required by the gams calls in the loop.
  2. No data is passed on the gams() call: it runs a generic GAMS model that can be run independently of Matlab and can be used with save/restart.
  3. The average time for the trivial GAMS call (no new data, solve the QP starting from solution, do not read results back to Matlab): .055 seconds/iteration.
  4. The average time for the real GAMS call (new data, solve from base solution, results back to Matlab): .064 seconds/iteration.

I did these runs on a Dell XPS13 laptop with a solid-state disk which I believe helps keep the startup time for GAMS low. I used Matlab R2013a and GAMS 24.0.2 as we ship it.

My conclusion: in my computing environment, the overhead required to call gams is only large compared to the solve time for a very tiny model. .055 seconds/run is something that is typically noise when solving larger, more challenging models.

HTH,

Steve


On Sun, Apr 14, 2013 at 4:45 AM, Salman wrote:

Hi Steve,

I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
obj: 0.5 *transpose(x)Hx + transpose(f)x
constraint: Ax Salman,

        It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving.  This is also possible when using GAMS, but to say more some additional detail would be helpful.  Specifically, what is changing in the sequence of QPs, and what stays constant?

        -Steve


        On Thu, Apr 11, 2013 at 4:44 PM, salman  wrote:

            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 loop
            2- 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.


            --
            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.






        --
        Steven Dirkse, Ph.D.
        GAMS Development Corp.,  Washington DC
        Voice: (202)342-0180     Fax: (202)342-0181
        sdi...@gams.com
        http://www.gams.com
        --
        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.

        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.


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.





\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Did I attach the matdata files? That is surprising since I find that interface confusing and try not to use it. I suggest that you avoid it also. It’s there only for backwards compatibility.

Best practice is to write your GDX files, call a gams model that uses generic GDX commands, and read any GDX files back into Matlab. Examples and more explanation on the GDXMRW Wiki.

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

Steve

Sent from my iPhone

Sent from my iPhone
On Feb 28, 2014, at 12:12, Yalin Huang wrote:

Dear
I have run the files you attached, and I am confused by how the files “matdata” and “matdata.gdx” are generated. Could you please explain more about it? Thanks a lot!

Yalin

On Monday, 15 April 2013 20:04:42 UTC+2, Steven Dirkse wrote:

Salman,

There is a certain amount of overhead that is introduced when you run a loop in Matlab and call gams each time in the loop.  It's not necessarily a large overhead, but it can seem large compared to the amount of work required to solve a QP with 2 vars and 3 constraints.  I am attaching a .zip file with an example that demonstrates what I mean.  A few things to note about the example:

1. It uses the save/restart and solvelink=5 features of GAMS (documented in the User's Guide) to minimize the startup time and solver-call times required by the gams calls in the loop.
2. No data is passed on the gams()  call: it runs a generic GAMS model that can be run independently of Matlab and can be used with save/restart.
3. The average time for the trivial GAMS call (no new data, solve the QP starting from solution, do not read results back to Matlab): .055 seconds/iteration.
4. The average time for the real GAMS call (new data, solve from base solution, results back to Matlab): .064 seconds/iteration.

I did these runs on a Dell XPS13 laptop with a solid-state disk which I believe helps keep the startup time for GAMS low.  I used Matlab R2013a and GAMS 24.0.2 as we ship it.

My conclusion: in my computing environment, the overhead required to call gams is only large compared to the solve time for a very tiny model.  .055 seconds/run is something that is typically noise when solving larger, more challenging models.

HTH,

Steve


On Sun, Apr 14, 2013 at 4:45 AM, Salman  wrote:

    Hi Steve,

    I changed both the constraint and objective function in each iteration. I have copied my matlab code and my gams code below. this is a quadratic programming with inequality constraint:
    obj: 0.5 *transpose(x)Hx + transpose(f)x
    constraint: Ax         It takes about 0.5 sec for gams to compute this optimization problem and return the results to the matlab. by deleting the "solve" statement in my gams  code, this time reduced to 0.2 sec. it means that gams solve this optimization problem in 0.3sec (0.5-0.2=0.3).
     In a matlab loop, I solved this problem 5 times with gams() function and 5 times with matlab quadprog() function. and in each iteration I changed the constraint (A,b) and objective function (H,f).  the time duration to solve this problem for gams() was: 0.55, 0.53, 0.54, 0.59, 0.53 sec and for quadprog() was : 0.41, 0.06, 0.04, 0.04, 0.002 sec.

    Best,
    Salman.

    %-------------------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






    On 04/12/2013 01:44 ق.ظ, Steven Dirkse wrote:
    Salman,

    It sounds like Matlab is able to take advantage of the similarity between the QPs you are solving.  This is also possible when using GAMS, but to say more some additional detail would be helpful.  Specifically, what is changing in the sequence of QPs, and what stays constant?

    -Steve


    On Thu, Apr 11, 2013 at 4:44 PM, salman  wrote:

        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 loop
        2- 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.


        --
        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.






    --
    Steven Dirkse, Ph.D.
    GAMS Development Corp.,  Washington DC
    Voice: (202)342-0180     Fax: (202)342-0181
    sdi...@gams.com
    http://www.gams.com
    --
    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.

    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.
    --
    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.






--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

hi
i want to run gams from matlab could you please help me too.?



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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hello Steven Dirkse
I have used Gams in a Matlab loop and I want to reduce the running time of my problem. I downloaded your file “solveCompare.zip” but when I run code “solve.gms” there appears an error “Error 140 Unknown symbol”. I also expanded your codes to my problem and I see the error too. I don’t know what’s the problem. I’ll be grateful if you help me.

Best Regards
Fateme Dorry


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Fateme,

You mention that you downloaded the file solveCompare.zip. I don’t recall that file: including a URL would be helpful.

Also, if you attach the .lst file from the run that would provide some context. Error 140 is not much to go on in isolation.

-Steve


On Sun, May 18, 2014 at 10:48 AM, Fateme Dorry wrote:

Hello Steven Dirkse
I have used Gams in a Matlab loop and I want to reduce the running time of my problem. I downloaded your file “solveCompare.zip” but when I run code “solve.gms” there appears an error “Error 140 Unknown symbol”. I also expanded your codes to my problem and I see the error too. I don’t know what’s the problem. I’ll be grateful if you help me.

Best Regards
Fateme Dorry


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

hi


On Wednesday, 10 April 2013 19:53:03 UTC-7, 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

hi dear
i have a question. I need to solve some lp in loop in my ga algorithem. i have used the link between gams and matlab to this but it 's too slow. is there any way to this work faster?
best regards

On Wednesday, April 10, 2013 7:53:03 PM UTC-7, 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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Salman;
I use matlab 2013a and gams 24.1;
I’ve tried a lot but I couldn’t link matlab and gams. I wonder if you would can help me in this regard.

Thank you so much.
mehdi massahi;
Phd student of Industrial Engineering
Amirkabir University of Technology;

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.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.