(This is a simplified version of my problem)

declarations

i= 1..1000

j= 1..100

x: array(i,j) of mpvar

end-declarations

With this formulation I will have 100000 xs. But I know that in x(i,j) for each ** i **there is only 1

**.**

*j*The data table looks like this i j

1 16

2 3

3 4....

I have 2 questions:

1. How I write this in Declarations so I only have 1000 xs and not 100000?

2. How do I write a constraint that sweeps in the same way i and j (only the combinations in the data table)?

Thanks,

You should make both arrays, the data array and the decision variable array, explicitly 'dynamic'.

The data array gets populated by reading the input data, the entries of decision variable arrays need to created via the explicit call to 'create'.

declarations

I= 1..1000

J= 1..100

x: dynamic array(I,J) of mpvar

A: dynamic array(I,J) of real

end-declarations

initializations from 'data.dat'

A

end-initializations

! Create the decision variables:

forall(i in I,j in J | exists(A(i,j)) ) create(x(i,j))

! Use 'exists' tests in any loops of the dynamic arrays for more efficient enumeration:

forall(i in I,j in J | exists(x(i,j)) ) x(i,j) <= Some_Bound

sum(i in I,j in J | exists(x(i,j)) ) x(i,j) <= Some_Value

NB: I have noticed that the discussion seems to continue in another thread: Problems reducing number of integer variables