Novice struggling with a "Set Already Under Control" error

3,266 views
Skip to first unread message

Lynn

unread,
Mar 14, 2011, 11:47:57 AM3/14/11
to gamsworld
Hello everyone. I am a novice at GAMS and am struggling with which
may be a simple error. I have looked at sample code and still dont
understand what I am doing wrong. Here is the code snippit with my
error inserted. Any advice and reason why I am getting the error is
greatly appreciated.


SET c chemical /c1*c20/

PARAMETER heat(c) heat Values
/ c1 2.45, c2 1.32, c3 1.23, c4 4.21, c5 2.83,
c6 1.92, c7 2.2, c8 6.69, c9 3.67, c10 1.28,
c11 2.45, c12 3.33, c13 3.27, c14 1.91, c15 2.32,
c16 2.82, c17 1.72, c18 2.62, c19 2.72, c20 1.77/;

POSITIVE VARIABLES
mixpercent(c) Mixing percentages associated with chemicals

FREE VARIABLE
mixheat Objective to minimize

EQUATIONS
maxlimit(c) Limit of % of any one chemical
mixlimit(c) Limit on mix percentage
mixobj Objective function
;

* No chemical can be more than 20% of mix
maxlimit(c).. mixpercent(c) =l= 0.2;

* The sum of all the mixing percentages must be less or equal to 50%
mixlimit(c).. sum(c, mixpercent(c)) =e= 0.5;

**** $125 Set is under control already

* Objective to minimize total heat of mix
mixobj.. mixheat =e= sum(c, heat(c)*mixpercent(c));

MODEL mix /ALL/;
SOLVE mix using LP minimizing mixheat;

herve guene

unread,
Mar 14, 2011, 1:50:31 PM3/14/11
to gams...@googlegroups.com
yeah! i think youjust needed to rename the set c
find the code below
SET c chemical /c1*c20/ ;
alias (c, cc);
PARAMETER heat(c) heat Values
           / c1 2.45,  c2 1.32,  c3 1.23,  c4 4.21,  c5 2.83,
             c6 1.92,  c7 2.2,   c8 6.69,  c9 3.67,  c10 1.28,
             c11 2.45, c12 3.33, c13 3.27, c14 1.91, c15 2.32,
             c16 2.82, c17 1.72, c18 2.62, c19 2.72, c20 1.77/;
POSITIVE VARIABLES
   mixpercent(c)   Mixing percentages associated with chemicals   ;
FREE VARIABLE
   mixheat        Objective to minimize                            ;
EQUATIONS
  maxlimit(c)      Limit of % of any one chemical
  mixlimit(c)      Limit on mix percentage
  mixobj           Objective function
;
* No chemical can be more than 20% of mix
maxlimit(c)..    mixpercent(c) =l= 0.2;
* The sum of all the mixing percentages must be less or equal to 50%
mixlimit(c)..    sum(cc, mixpercent(cc)) =e= 0.5;
****                        $125 Set is under control already
* Objective to minimize total heat of mix
mixobj..         mixheat =e= sum(c, heat(c)*mixpercent(c));
MODEL mix /ALL/;
SOLVE mix using LP minimizing mixheat;
display mixpercent.l;



 
- - - - - - -- -- -- --- --- --- ----- ---- ---- ---- ----
M.  Hervé Jean-Louis GUENE
Ingénieur Statisticien - Economiste
Service du Suivi de la Paurevté (Insitut National de la Statistique et de la Démographie)
cel:(+226) 78 35 77 76/ 71 31 53 52

 


--- En date de : Lun 14.3.11, Lynn <lynn...@hotmail.com> a écrit :
--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


Lynn

unread,
Mar 14, 2011, 4:50:58 PM3/14/11
to gamsworld
Herve,

Thanks that worked but unsure why that was required. I will research
alias' and see what I can learn.

Thanks again!
> --- En date de : Lun 14.3.11, Lynn <lynnau...@hotmail.com> a écrit :
> To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.

Lynn

unread,
Mar 14, 2011, 5:50:00 PM3/14/11
to gamsworld
Thanks to Herve and Mohammad for your comments. While Herve's method
works, Mohammad identified the real problem in my model. In effort to
help other novices, I thought I would share his insight on equations.

I had added the subscripts to the mixlimit equation thinking that I
needed to as it was referenced on the equation. However, Mohammad's
comment is helped me understand more when I need those subscripts...
Do I need the equation sum(c, mixpercent(c)) =e= 0.5 for every c?
Nope. The alias worked but created many duplicated unneeded equations
(i.e., c-number of them). Once I eliminated the subscript, it worked
without the compiler error. (and the number of variables calculated
dropped significantly in the MODEL STATISTICS section). Much better
model.

Thanks Herve and Mohammad for the learning :)

Lynn

***** MOHAMMAD'S NOTE ******

Dear Lynn

The problem is with the indexes of mixlimit equations. First do u
really mean that you need C number of equations representing this
summation sum(c, mixpercent(c))?

I doubt about it, since then you will be repeating the same set of
equations. If so, just remove the (C) in the definition at it will
be:
mixlimit.. sum(c, mixpercent(c)) =e= 0.5;
If you think that this summation should not be the same for all
elements, consider using alias [in that case write back to me what
exactly u want , I may be able to help].

Hope it is useful.
Best Regards
--
محمد صادق تولّلی
Mohammad Sadegh Tavallali


On Mar 14, 12:50 pm, herve guene <hgu...@yahoo.fr> wrote:
> --- En date de : Lun 14.3.11, Lynn <lynnau...@hotmail.com> a écrit :
>
> De: Lynn <lynnau...@hotmail.com>
> To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages