Dimension Different Error

Problems with syntax of GAMS
meelih
User
User
Posts: 2
Joined: 3 weeks ago

Dimension Different Error

Postby meelih » 3 weeks ago

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: 54
Joined: 1 year ago

Re: Dimension Different Error

Postby bussieck » 3 weeks ago

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: 2
Joined: 3 weeks ago

Re: Dimension Different Error

Postby meelih » 3 weeks ago

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: 54
Joined: 1 year ago

Re: Dimension Different Error

Postby bussieck » 3 weeks ago

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

Hope this helps,
-Michael


Who is online

Users browsing this forum: No registered users and 1 guest