How can I write relationship for indices in CPLEX?

31 Views Asked by At

I am stucking at this stage.

  • U[t][i][v] is the quantity picked up at node i by vehicle v at period t (decision variable)
  • QT[t][p][m][w] is the quantity of product p produced in manufacturer m in time period t (decision variable) enter image description here

How can I write this constraint with a correspodence among i, p, and m? Note that we have 4 pick-up node, 2 manufacturers, and 2 products so <i,m,p> must be 1 of these <1,1,1>, <2,2,1>, <3,1,2>, <4,2,2> Thank you for your help

1

There are 1 best solutions below

0
Alex Fleischer On

You could start with

range PN=1..4;

range P=1..2;
range M=1..2;

range T=1..3;
range V=1..4;
range W=1..2;

tuple pm
{
  int p;
  int m;
}

pm pms[PN]=[<1,1>,<1,2>,<2,1>,<2,2>];

dvar float U[T][PN][V];
dvar float+ QT[T][P][M][W]; 
subject to
{
  forall(i in PN,t in T)
    sum(v in V) U[t][i][v]==sum(w in W)QT[t][pms[i].p][pms[i].m][w];
}