newsgroups-index (beta)

Current group: sci.op-research

GAMS: variable reduction question

GAMS: variable reduction question  
A C
 Re: GAMS: variable reduction question  
Erwin Kalvelagen
From:A C
Subject:GAMS: variable reduction question
Date:Mon, 24 Jan 2005 15:33:08 +1300
Hi

We have a model which has a large number of variables which we need to
reduce (performance issues, model sometimes gets too large to generate).
The variables are, for example, defined over set A and B. Lets assume that
the sets are as follows:

A B
a 1
b 2
c 3

*Excuse all crummy syntax and bad math represenation etc below, simple
written in an easy manner to get the gist across*

If I declare a variable my_var(A,B) I get 9 variables, namely something like
my_var(a,1)
my_var(a,2)
my_var(a,3)
my_var(b,1)
my_var(b,2)
my_var(b,3)
my_var(c,1)
my_var(c,2)
my_var(c,3)

But lets also say that we know that some of these combinations will always
be unused by the model, for example maybe there is some restriction that
prevents A="a" being paired with B="1" such as cost being too high. We can
define some new set my_allowable_combinations(A,B) which we dynamically set
to enforce our rules. eg something like:
parameter cost(A,B) //
set my_allowable_combinations(A,B);
my_allowable_combinations(A,B)$(cost(A,B) < 1000) = yes;

Lets assume that for whatever reason cost(a,1) and cost(c,3) have a cost >
1000 and hence we dont define my_allowable_combinations for (a,1) and (c,3).

In our equations we use my_allowable_combinations(A,B) to only generate
equations which contain variables with allowable combos of A and B, and this
extends to the obj function as well. i.e my_var(a,1) and my_var(c,3) never
appear in an equation or in the obj function.

So the particular variables with non-allowable combos are free to take on
whatever value they feel like, but as they never appear in anything that
does not matter. Its possible to restrict these variables to zero using .fx
or .up or similar, but as this just increases the number of constraints we
no longer do this wherever possible.

What I would like to do however is never generate these variables in the
first place. If I have the set my_allowable_combinations how can I use it
to only generate the variables that I need???

Furthermore, whatever I do I need to do it in a manner that allows me to
"see" the individual A and B elements as well, as some of the equations use
A or B on its own rather than as a "combined" set. For example, imagine I
had a (silly) equation like:
test_eqn(A,B).. my_var(A,B)*(sum(A,x(A))) + my_var(A,B)*y(B) =e= z(A,B);
I need to be able to "see" the A and B separately from an "A and B together"
set (such as my_allowable_combinations).


Can someone help us?

Thanks
A
From:Erwin Kalvelagen
Subject:Re: GAMS: variable reduction question
Date:Mon, 24 Jan 2005 05:21:08 GMT

Use:

test_eqn(A,B)$my_allowable_combinations(A,B).. my_var(A,B)*(sum(A,x(A))) +
my_var(A,B)*y(B) =e= z(A,B);

or even shorter:

test_eqn(my_allowable_combinations(A,B)).. my_var(A,B)*(sum(A,x(A))) +
my_var(A,B)*y(B) =e= z(A,B);


Note that it is probably better to ask GAMS related questions in the
GAMS mailing list (see http://www.gams.com/maillist/gams_l.htm) or
by contacting support@gams.com.

----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
erwin@gams.com, http://www.gams.com/~erwin
----------------------------------------------------------------

On Mon, 24 Jan 2005 15:33:08 +1300, A C wrote:

> Hi
>
> We have a model which has a large number of variables which we need to
> reduce (performance issues, model sometimes gets too large to generate).
> The variables are, for example, defined over set A and B. Lets assume that
> the sets are as follows:
>
> A B
> a 1
> b 2
> c 3
>
> *Excuse all crummy syntax and bad math represenation etc below, simple
> written in an easy manner to get the gist across*
>
> If I declare a variable my_var(A,B) I get 9 variables, namely something like
> my_var(a,1)
> my_var(a,2)
> my_var(a,3)
> my_var(b,1)
> my_var(b,2)
> my_var(b,3)
> my_var(c,1)
> my_var(c,2)
> my_var(c,3)
>
> But lets also say that we know that some of these combinations will always
> be unused by the model, for example maybe there is some restriction that
> prevents A="a" being paired with B="1" such as cost being too high. We can
> define some new set my_allowable_combinations(A,B) which we dynamically set
> to enforce our rules. eg something like:
> parameter cost(A,B) //
> set my_allowable_combinations(A,B);
> my_allowable_combinations(A,B)$(cost(A,B) < 1000) = yes;
>
> Lets assume that for whatever reason cost(a,1) and cost(c,3) have a cost >
> 1000 and hence we dont define my_allowable_combinations for (a,1) and (c,3).
>
> In our equations we use my_allowable_combinations(A,B) to only generate
> equations which contain variables with allowable combos of A and B, and this
> extends to the obj function as well. i.e my_var(a,1) and my_var(c,3) never
> appear in an equation or in the obj function.
>
> So the particular variables with non-allowable combos are free to take on
> whatever value they feel like, but as they never appear in anything that
> does not matter. Its possible to restrict these variables to zero using .fx
> or .up or similar, but as this just increases the number of constraints we
> no longer do this wherever possible.
>
> What I would like to do however is never generate these variables in the
> first place. If I have the set my_allowable_combinations how can I use it
> to only generate the variables that I need???
>
> Furthermore, whatever I do I need to do it in a manner that allows me to
> "see" the individual A and B elements as well, as some of the equations use
> A or B on its own rather than as a "combined" set. For example, imagine I
> had a (silly) equation like:
> test_eqn(A,B).. my_var(A,B)*(sum(A,x(A))) + my_var(A,B)*y(B) =e= z(A,B);
> I need to be able to "see" the A and B separately from an "A and B together"
> set (such as my_allowable_combinations).
>
>
> Can someone help us?
>
> Thanks
> A
   

Copyright © 2006 newsgroups-index   -   All rights reserved   -   Impressum