Uncontrolled Set Entered as Constant

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks

\

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallali.msadegh@gmail.com


On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thanks Tavallali
It Worked

On Mar 11, 11:08 am, Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as
number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallali.msad...@gmail.com

On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.

\

Reply-to: gamsworld@googlegroups.com

Elaborating on Mohammad’s post

Depending on where it is used,
X(i,k)$( ord(k) = 1 )
may still return “Uncontrolled Set Entered As Constant”.

For example, run the following (without the line numbers).


1 set k /1*3/;
2 scalar kk;
3 parameters
4 X(k),
5 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
6 for ( kk = 1 to 3,
7 if ( Y(k)( ord(k) = kk ) > 1.0 , 8 X(k)( ord(k) = kk ) = Y(k)$( ord(k) = kk );
9 );
10 );


The previous code returns “Uncontrolled Set Entered As Constant,” in reference to Y(k) in line 5.

Referencing the set k there makes no sense to GAMS. k is not part of an assignment (like line 8, which does not cause an error), nor is k controlled by GAMS in any other way.

The following code uses a GAMS Loop to avoid the problem:


1 set k /1*3/;
2 parameters
3 X(k),
4 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
5 Loop ( k,
6 if ( Y(k) > 1.0 ,
7 X(k) = Y(k);
8 );
9 );
10 display X;


RESULT:
---- 10 PARAMETER X

1 3.000, 3 2.500


New GAMS users who code in a language like C++ may find these issues incredibly frustrating and confusing (as I did); thus, the reason for my attempt at clarification.

Tom

PS: Although this example illustrated my point, their is a more efficient way to reach the code’s result:


1 set k /1*3/;
2 parameters
3 X(k),
4 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
5 X(k) = Y(k)$( Y(k) > 1.0 );
6 display X;










On Friday, March 11, 2011 5:39:08 AM UTC-6, USMZ wrote:

Thanks Tavallali
It Worked

On Mar 11, 11:08 am, Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as
number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallali.msad...@gmail.com

On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


“gamsworld” group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


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.

\

Reply-to: gamsworld@googlegroups.com

Elaborating on Tavallali’s post

Depending on where it is used,
X(i,k)$( ord(k) = 1 )
may still return “Uncontrolled Set Entered As Constant”.

For example, run the following (without the line numbers).


1 set k /1*3/;
2 scalar kk;
3 parameters
4 X(k),
5 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
6 for ( kk = 1 to 3,
7 if ( Y(k)( ord(k) = kk ) > 1.0 , 8 X(k)( ord(k) = kk ) = Y(k)$( ord(k) = kk );
9 );
10 );


The previous code returns “Uncontrolled Set Entered As Constant,” in reference to Y(k) in line 7.

Referencing the set k there makes no sense to GAMS. k is not part of an assignment (like line 8, which does not cause an error), nor is k controlled by GAMS in any other way.

The following code uses a GAMS loop to avoid the problem:


1 set k /1*3/;
2 parameters
3 X(k),
4 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
5 loop ( k,
6 if ( Y(k) > 1.0 ,
7 X(k) = Y(k);
8 );
9 );
10 display X;


RESULT:
---- 10 PARAMETER X

1 3.000, 3 2.500


Tom

PS: Although this example illustrated my point, there’s a more efficient way to reach the code’s result:


1 set k /1*3/;
2 parameters
3 X(k),
4 Y(k) / 1 3.0, 2 1.0, 3 2.5 /;
5 X(k) = Y(k)$( Y(k) > 1.0 );
6 display X;


On Friday, March 11, 2011 5:39:08 AM UTC-6, USMZ wrote:

Thanks Tavallali
It Worked

On Mar 11, 11:08 am, Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as
number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallali.msad...@gmail.com

On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


“gamsworld” group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


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 Mohammad
I’m currently modelling the Chance constraints into my LP model (called Basic Three Stage For Pension Fund), since I find in GAMs EMP library, there is a ‘simple chance constraint model’, which can help me to model the chance constraints.

However when I’m trying to incorporate this into my already-worked ThreeStage LP model and solve it by coding 'solve sc max Z use emp scenario dict; ’ however it report
the errors as:

249 solve sc min Z use emp scenario dict;
**** $778,257
Therefore I’m quite confusing whether can I use the different functions in the GAMs (such as, solve LP, worstcase and emp) at the same time?
I have attached two GAMs files, the BasicThreeStageForPensionFund has proved to work properly. However if I incorporate EMP inside, it fails to work, which is covered in the second file Basic with chance constraint

I have already attached my GAMs model in this email, could you please have some time do read it. Many thanks

Regards
Paul


On Friday, March 11, 2011 8:08:16 AM UTC, Mohammad Sadegh Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallali.msadegh@gmail.com


On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


BasicThreeStageForPensinFund.gms (8.56 KB)
Basic with chance constraint.gms (10.3 KB)

I am trying to do something similar to USMZ and the alias command isn’t quite solving my problem. I want to set all the elements of a variable Alpha(K,I) less than or equal to the elements in a table B(K,J) where I and J have the same elements. It’s not working because I have to name I,J,K in the equation to avoid the error “uncontrolled set entered as constant” even though each Alpha and B only have two elements. This is the code:

Sets
J ending locations
/ CA, WA, ND/
K time periods
/K1*K2/;
alias(J,I);

TABLE B(K,J)
CA WA ND
K1 1 2 3
K2 0 1 5;


VARIABLES
Alpha(K,I)
Z;

EQUATIONS
PROFIT
BEG(K,I) ;

PROFIT…Z=E=SUM((K,I),Alpha(K,I));
BEG(K,I)…Alpha(K,I)=L=B(K,J);

MODEL TEST /ALL/ ;
SOLVE TEST USING LP MAXIMIZING Z;




On Friday, March 11, 2011 at 2:08:16 AM UTC-6, Mohammad Sadegh Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallal...@gmail.com


On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Kendra

Why don’t you write BEG(K,I)…Alpha(K,I)=L=B(K,I);?

Cheers

Renger







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Kendra Williamson
Sent: Mittwoch, 13. Januar 2016 21:04
To: gamsworld
Subject: Re: Uncontrolled Set Entered as Constant



I am trying to do something similar to USMZ and the alias command isn’t quite solving my problem. I want to set all the elements of a variable Alpha(K,I) less than or equal to the elements in a table B(K,J) where I and J have the same elements. It’s not working because I have to name I,J,K in the equation to avoid the error “uncontrolled set entered as constant” even though each Alpha and B only have two elements. This is the code:



Sets

J ending locations

/ CA, WA, ND/

K time periods

/K1*K2/;

alias(J,I);



TABLE B(K,J)

CA WA ND

K1 1 2 3

K2 0 1 5;





VARIABLES

Alpha(K,I)

Z;



EQUATIONS

PROFIT

BEG(K,I) ;



PROFIT…Z=E=SUM((K,I),Alpha(K,I));

BEG(K,I)…Alpha(K,I)=L=B(K,J);



MODEL TEST /ALL/ ;

SOLVE TEST USING LP MAXIMIZING Z;







On Friday, March 11, 2011 at 2:08:16 AM UTC-6, Mohammad Sadegh Tavallali wrote:

Hi

Plz use this

SETS
i /12/
j /1
4/;
alias (j,k);

also note that in GAMS u cannot use x(i,1) as the indexes are not treated as number. The alternatives are :
X(i,“1”) or X(i,k)$( ORD(k) =1)

Hope it is helpful.

Regards


محمد صادق تولّلی
Mohammad Sadegh Tavallali
tavallal...@gmail.com

On Fri, Mar 11, 2011 at 1:25 PM, USMZ wrote:

HI Everyone,

It’s my first post on this helpful group.

I have defined the variable x(i,j) where i is /12/ and j is /14/ and
the other sets I defined are k,l /1*4/ as they are same as j.

When I write x(i,k) or x(i,1), i get the error message “Uncontrolled
Set Entered as Constant”

I will appreciate if anyone can help me with this matter.

Thanks


To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


\

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 https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.