Linear Programming: modelling with GAMS Model Factory

Dear all,

I’m trying to solve a problem given in Paul Williams book “model building in mathematical programming” with GAMS

Here’s the solution with sMAGIC (www.maths.ed.ac.uk/ERGO/sMAGIC/) developed by Williams:http://personal.lse.ac.uk/williahp/mod_factory.htm

I have difficulties in forming the equations in GAMS, since I can’t use the syntax in sMAGIC

This is what I have so right now, and the optimal solution differs from Williams.

equations TARGET C1 C2 C3 C4 C5 C6; TARGET… Sum( (t,i), (dbx(i)xsold(t,i) - 0.5xhold(t,i)) ) =e= DB; C1(t,i)sameas(t,"1").. xprod(t,i) - xsold(t,i) - xhold(t,i) =e= 0; C2(t,i)(sameas(t,“2”) OR sameas(t,“3”) OR sameas(t,“4”) OR sameas(t,“5”) OR sameas(t,“6”))… xprod(t,i) - xsold(t,i) - xhold(t,i) + xhold(t-1,i) =e= 0; C3(m,t)… Sum(i, time(m,i)xprod(t,i)) =l= hours_availmach(m,t); C4(t,i)… xprod(t,i) =l= market(t,i); C5(t,i)$(sameas(t,“1”) OR sameas(t,“2”) OR sameas(t,“3”) OR sameas(t,“4”) OR sameas(t,“5”)) … xhold(t,i) =l= 100; C6(t,i)$sameas(t,“6”)… xhold(t,i) =e= 50;



Somehow I want to tell GAMS, to create Constraints of type C1 only for t=1, meaning for the first periode of the 6. Same applies to C2, were those kind of constraints should be created for t>1

C5 and C6 were created with a FOR-Loop and If condition in sMAGIC, but these constructs cant be used within equations…

I tried the $ symbol on the left hand side with some OR expressions… but no sucesss


Does anyone have a hint how to model Factorya and Factoryb in GAMS?

Thank you!

\

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

If t has 6 periodes t /1*6/ you can just use the ord and card operator, where card(t) gives you the number of elements in set t



The equations can then be written as $(ord(t) > 1) …. Or for the last one ord(t) = card(t).

The ones for the first equations can either be written out completely (using “1”) without a dollar sign. Or you use ord(t) = 1.



Hope this helps



Renger


\


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Hans Adam
Sent: Thursday, November 13, 2014 14:15
To: gamsworld@googlegroups.com
Subject: Linear Programming: modelling with GAMS Model Factory



Dear all,

I’m trying to solve a problem given in Paul Williams book “model building in mathematical programming” with GAMS

Here’s the solution with sMAGIC (www.maths.ed.ac.uk/ERGO/sMAGIC/) developed by Williams:http://personal.lse.ac.uk/williahp/mod_factory.htm

I have difficulties in forming the equations in GAMS, since I can’t use the syntax in sMAGIC

This is what I have so right now, and the optimal solution differs from Williams.

equations

TARGET

C1

C2

C3

C4

[Renger >]

C5

C6;



TARGET… Sum( (t,i), (dbx(i)xsold(t,i) - 0.5xhold(t,i)) ) =e= DB;



C1(t,i)$sameas(t,“1”)… xprod(t,i) - xsold(t,i) - xhold(t,i) =e= 0;

C2(t,i)(sameas(t,"2") OR sameas(t,"3") OR sameas(t,"4") OR sameas(t,"5") OR sameas(t,"6")).. xprod(t,i) - xsold(t,i) - xhold(t,i) + xhold(t-1,i) =e= 0; \ \ \ C3(m,t).. Sum(i, time(m,i)*xprod(t,i)) =l= hours_avail*mach(m,t); \ \ \ C4(t,i).. xprod(t,i) =l= market(t,i); \ \ \ C5(t,i)(sameas(t,“1”) OR sameas(t,“2”) OR sameas(t,“3”) OR sameas(t,“4”) OR sameas(t,“5”)) … xhold(t,i) =l= 100;



C6(t,i)$sameas(t,“6”)… xhold(t,i) =e= 50;



Somehow I want to tell GAMS, to create Constraints of type C1 only for t=1, meaning for the first periode of the 6. Same applies to C2, were those kind of constraints should be created for t>1

C5 and C6 were created with a FOR-Loop and If condition in sMAGIC, but these constructs cant be used within equations…

I tried the $ symbol on the left hand side with some OR expressions… but no sucesss



Does anyone have a hint how to model Factorya and Factoryb in GAMS?

Thank you!


\

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.


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,
thanks for your information. Looks better now,
but I still have different values when I solve the problem with GAMS and sMagic.
The objective functions delivers different values, and it seems like the inter-periode connection of products via a storage doesnt work properly.
Which in my sense shouldn’t be,
since the underlying model is the same.



On Thursday, November 13, 2014 3:12:09 PM UTC+1, Renger van Nieuwkoop wrote:

Hi

If t has 6 periodes t /1*6/ you can just use the ord and card operator, where card(t) gives you the number of elements in set t



The equations can then be written as $(ord(t) > 1) …. Or for the last one ord(t) = card(t).

The ones for the first equations can either be written out completely (using “1”) without a dollar sign. Or you use ord(t) = 1.



Hope this helps



Renger



\

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.