programming flow set parameter

Dear Gams users,

I have a model with several sets of parameters. One of them, set ln /1*5/, has an associated parameter h(ln), which can take only a small number of values (predefined), say h(ln) in {1,5,10,20}.

I would like to solve my model for each possible combination of values for parameter h. Something like this:

For each possible combination of (h(1),…,h(5))
solve model(h(1),…,h(5))
end for.

Despite many tries, I haven’t succeeded :frowning: Any ideas about how to program this?

Thanks in advance

Fede

PS: I gave the number of elements in the set and the number of possible values of the parameter as indications. Of course in general there are n elements in the set, and m possible values for the parameter.


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 Fede



The first thing you need is some way to enter your predefined values. This can be done with something like



Set cases / c1*c4 /;

Parameter hvalues(cases) / c1 1, c2 5, c3 10, c4 20 /;



The next is to generate a loop over the possible combinations. I am not sure whether you can do it general independent on the size of the set ln.

But do you realize that you will have card(ln)card(cases) = nm = 5**4 = 1024 combinations? That is a lot!



Arne


\

Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, email: adrud@arki.dk



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Federico Perea
Sent: Wednesday, January 21, 2015 2:40 PM
To: gamsworld@googlegroups.com
Subject: programming flow set parameter



Dear Gams users,



I have a model with several sets of parameters. One of them, set ln /1*5/, has an associated parameter h(ln), which can take only a small number of values (predefined), say h(ln) in {1,5,10,20}.



I would like to solve my model for each possible combination of values for parameter h. Something like this:



For each possible combination of (h(1),…,h(5))

solve model(h(1),…,h(5))

end for.



Despite many tries, I haven’t succeeded :frowning: Any ideas about how to program this?



Thanks in advance



Fede



PS: I gave the number of elements in the set and the number of possible values of the parameter as indications. Of course in general there are n elements in the set, and m possible values for the parameter.


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.

Thanks Arne,

I am aware of the exponential number of cases but, since both n and m are small (3-5), this is not that many problems (instead of solving an intractable MINLP, I will solve n**m linear problems).

My main problem is exactly what you said: to do this independently of the size of the set ln. Still trying :frowning:

Regards

Fede

On Wed, Jan 21, 2015 at 3:08 PM, Arne Stolbjerg Drud wrote:

Hi Fede



The first thing you need is some way to enter your predefined values. This can be done with something like



Set cases / c1*c4 /;

Parameter hvalues(cases) / c1 1, c2 5, c3 10, c4 20 /;



The next is to generate a loop over the possible combinations. I am not sure whether you can do it general independent on the size of the set ln.

But do you realize that you will have card(ln)card(cases) = nm = 5**4 = 1024 combinations? That is a lot!



Arne


\

Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, email: adrud@arki.dk



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Federico Perea
Sent: Wednesday, January 21, 2015 2:40 PM
To: gamsworld@googlegroups.com
Subject: programming flow set parameter



Dear Gams users,



I have a model with several sets of parameters. One of them, set ln /1*5/, has an associated parameter h(ln), which can take only a small number of values (predefined), say h(ln) in {1,5,10,20}.



I would like to solve my model for each possible combination of values for parameter h. Something like this:



For each possible combination of (h(1),…,h(5))

solve model(h(1),…,h(5))

end for.



Despite many tries, I haven’t succeeded :frowning: Any ideas about how to program this?



Thanks in advance



Fede



PS: I gave the number of elements in the set and the number of possible values of the parameter as indications. Of course in general there are n elements in the set, and m possible values for the parameter.


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.

\

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.

2015-01-21 15:51 GMT+01:00 Federico Perea :

Thanks Arne,

I am aware of the exponential number of cases but, since both n and m are
small (3-5), this is not that many problems (instead of solving an
intractable MINLP, I will solve n**m linear problems).

My main problem is exactly what you said: to do this independently of the
size of the set ln. Still trying :frowning:

Regards

Fede

On Wed, Jan 21, 2015 at 3:08 PM, Arne Stolbjerg Drud wrote:

Hi Fede

The first thing you need is some way to enter your predefined values. This
can be done with something like

Set cases / c1*c4 /;

Parameter hvalues(cases) / c1 1, c2 5, c3 10, c4 20 /;

The next is to generate a loop over the possible combinations. I am not
sure whether you can do it general independent on the size of the set ln.

But do you realize that you will have card(ln)card(cases) = nm = 5**4
= 1024 combinations? That is a lot!

Arne


Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, email: adrud@arki.dk

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
Behalf Of Federico Perea
Sent: Wednesday, January 21, 2015 2:40 PM
To: gamsworld@googlegroups.com
Subject: programming flow set parameter

Dear Gams users,

I have a model with several sets of parameters. One of them, set ln /1*5/,
has an associated parameter h(ln), which can take only a small number of
values (predefined), say h(ln) in {1,5,10,20}.

I would like to solve my model for each possible combination of values for
parameter h. Something like this:

For each possible combination of (h(1),…,h(5))

solve model(h(1),…,h(5))

end for.

Despite many tries, I haven’t succeeded :frowning: Any ideas about how to program
this?

Thanks in advance

Fede

PS: I gave the number of elements in the set and the number of possible
values of the parameter as indications. Of course in general there are n
elements in the set, and m possible values for the parameter.


“gamsworld” group.
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.


“gamsworld” group.
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.


“gamsworld” group.
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 Fede,

from what you explain I see you need two loops or two sets in the loop
(with alias),

if I got you correctly, please see a possible suggestion in the code below,

please write back if needed, this is a funny exercise (I suspect you
also might need only one value activated for your parameter each time,
not sure)

Cheers,
Roger



CODE
set
element /ae/
list /a
e/
;
alias
(list, lists)
(element,elements)
;
parameter
allocate (element),
value (list) / a 1, b 2, c 3, d 4, e 5 /
plus
pass
;
variable x, y , z;
equations
try
constraint;

try… x=g=1+ sum(element,allocate(element));
constraint… x=l=100000;
model yourmodel /all/;

loop((listS,elementS),
allocate(elements)=value (lists);
display allocate;
solve yourmodel using LP maximizing x;
);


2015-01-25 9:04 GMT+01:00 Roger Cremades Rodeja :

2015-01-21 15:51 GMT+01:00 Federico Perea :

Thanks Arne,

I am aware of the exponential number of cases but, since both n and m are
small (3-5), this is not that many problems (instead of solving an
intractable MINLP, I will solve n**m linear problems).

My main problem is exactly what you said: to do this independently of the
size of the set ln. Still trying :frowning:

Regards

Fede

On Wed, Jan 21, 2015 at 3:08 PM, Arne Stolbjerg Drud wrote:

Hi Fede

The first thing you need is some way to enter your predefined values. This
can be done with something like

Set cases / c1*c4 /;

Parameter hvalues(cases) / c1 1, c2 5, c3 10, c4 20 /;

The next is to generate a loop over the possible combinations. I am not
sure whether you can do it general independent on the size of the set ln.

But do you realize that you will have card(ln)card(cases) = nm = 5**4
= 1024 combinations? That is a lot!

Arne


Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, email: adrud@arki.dk

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
Behalf Of Federico Perea
Sent: Wednesday, January 21, 2015 2:40 PM
To: gamsworld@googlegroups.com
Subject: programming flow set parameter

Dear Gams users,

I have a model with several sets of parameters. One of them, set ln /1*5/,
has an associated parameter h(ln), which can take only a small number of
values (predefined), say h(ln) in {1,5,10,20}.

I would like to solve my model for each possible combination of values for
parameter h. Something like this:

For each possible combination of (h(1),…,h(5))

solve model(h(1),…,h(5))

end for.

Despite many tries, I haven’t succeeded :frowning: Any ideas about how to program
this?

Thanks in advance

Fede

PS: I gave the number of elements in the set and the number of possible
values of the parameter as indications. Of course in general there are n
elements in the set, and m possible values for the parameter.


“gamsworld” group.
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.


“gamsworld” group.
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.


“gamsworld” group.
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.

\