Hi

i am trying to do modelling in gams but i faced such a problem:

in one of my equations i write

precedence(i).. sum(k, x(i,k)*k) =L= something for example.

When i write like this it gives dimension different error. But if i write this equation in opened form for i=1 for example, it doesnt give any error. But i need to write this in closed form.

By the way, the error happens only if i multiply k with x (k*x(i,k))

Related information:

k is a set /1*5/

i is a set /1*5/

x(i,k) is a binary variable

## Dimension Different Error

### Re: Dimension Different Error

Hi,

k is a label (string) not a number, so you can't multiply this with a variable. If the label happens to represent a number you can use k.val (see https://www.gams.com/latest/docs/UG_GAM ... ams_Labels)

Hope this helps,

- Michael

k is a label (string) not a number, so you can't multiply this with a variable. If the label happens to represent a number you can use k.val (see https://www.gams.com/latest/docs/UG_GAM ... ams_Labels)

Hope this helps,

- Michael

### Re: Dimension Different Error

Thank you for reply. It has worked.

I want to ask one more thing.

for example i defined two sets.

i /1*3/ and j /1*3/

and i defined binary variable x(i)

and i want to use j in variable x as a set.

I mean i want gams to understand x(j) since both i and j are defined /1*3/

How can i do that.

Note: When i try to use j in x(j), gams says domain violation.

I want to ask one more thing.

for example i defined two sets.

i /1*3/ and j /1*3/

and i defined binary variable x(i)

and i want to use j in variable x as a set.

I mean i want gams to understand x(j) since both i and j are defined /1*3/

How can i do that.

Note: When i try to use j in x(j), gams says domain violation.

### Re: Dimension Different Error

Just define set i and make an alias(i,j).

Hope this helps,

-Michael

Hope this helps,

-Michael