Multi dimensional Set in a Variable/ error: one dimensional set expected

Problems with modeling
Post Reply
tolo
User
User
Posts: 2
Joined: 3 weeks ago

Multi dimensional Set in a Variable/ error: one dimensional set expected

Post by tolo » 2 weeks ago

Hello,

is it possible to have a multi dimensional set in a variable? If I define the sets and the variable as below, the error 'one dimensional set expected' will appear. Is it possible to avoid this error?


Sets
i products /Product1, Product2 /
Copies possible number of copies /1,2,3,4/

k(i,Copies) copies for product i (multidimensional) /Product1.(1,2,3,4)
Product2.(1,2) /
h position /P1,P2,P3,P4,P5,P6/ ;

...

Binary Variable

y(i,k,h) 1 if and only if copy k of product i is placed in position h

Fred
Posts: 22
Joined: 1 year ago

Re: Multi dimensional Set in a Variable/ error: one dimensional set expected

Post by Fred » 2 weeks ago

Hi Tolo,

At declaration you have to use the one dimensional (static) sets i.e. use sets i and Copies instead of two dimensional set k(i,Copies):

Code: Select all

Binary Variable y(i,i,Copies,h) 1 if and only if copy k of product i is placed in position h  
In your model you can then of course use multidimensional sets in the domain of a variable, as long as they match the sets used at declaration

Code: Select all

[...] y(i,k,h) [...]
I hope this helps!

Best,
Fred

Post Reply