## Dimension Different Error

Problems with syntax of GAMS
meelih
User
Posts: 4
Joined: 10 months ago

### Dimension Different Error

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

bussieck
Moderator
Posts: 145
Joined: 2 years ago

### 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

meelih
User
Posts: 4
Joined: 10 months ago

### 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.

bussieck
Moderator
Posts: 145
Joined: 2 years ago

### Re: Dimension Different Error

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

Hope this helps,
-Michael