Originally posted by: SystemAdmin
You can write the first constraint as you suggested if you add parenthesis. Below is a .mod file that should answer your questions.
{string
} P =
{
"P1",
"P2",
"P3",
"P4"
};
{
int
} D =
{1, 2, 3, 4, 5, 6, 7
};
{
int
} A =
{1, 2, 3, 4, 5, 6, 7
};
float LOS[P][D] = [ [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ], [ 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ], [ 15.0, 16.0, 17.0, 18.0, 29.0, 20.0, 21.0 ], [ 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0 ] ] ; dvar int+ x[P][A]; maximize sum(p in P) sum(a in A) x[p][a]; subject to
{
// Your first constraint. sum(p in P) (x[p][1] * LOS[p][1] + x[p][5] * LOS[p][4] + x[p][4] * LOS[p][5] + x[p][3] * LOS[p][6] + x[p][2] * LOS[p][7]) <= 200;
// Sum only over p=P1 or p=P2 sum(p in P : p ==
"P1" || p ==
"P2") sum(a in A) x[p][a] <= 1;
}
Not that for questions concerning OPL you best refer to the OPL forum
here.
#DecisionOptimization#MathematicalProgramming-General