Dimension Different Error

Problems with syntax of GAMS
Post Reply
meelih
User
User
Posts: 4
Joined: 6 years ago

Dimension Different Error

Post by meelih »

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
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Dimension Different Error

Post by bussieck »

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
User
Posts: 4
Joined: 6 years ago

Re: Dimension Different Error

Post by meelih »

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.
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Dimension Different Error

Post by bussieck »

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

Hope this helps,
-Michael
Post Reply