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 /1*2/*

j /14/;

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 /1*2/ and j is /1*4/ 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.

\