Page 1 of 1

Dimension Different Error

Posted: Sat Nov 18, 2017 1:02 pm
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

Re: Dimension Different Error

Posted: Sat Nov 18, 2017 4:22 pm
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

Re: Dimension Different Error

Posted: Sun Nov 19, 2017 5:37 pm
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.

Re: Dimension Different Error

Posted: Mon Nov 20, 2017 12:51 am
by bussieck
Just define set i and make an alias(i,j).

Hope this helps,
-Michael