I am tring to solve the following linear program with SCIP and the .zpl-format:
where as c, p and A are defined the following way:
I already came up with a way to solve it:
param n := 1000;
set N := {1 .. n};
param c[<i> in N] := i/n ;
var p[<i> in N] real >= 0;
set A := N * N;
set O := {<i,j> in A with i < j};
set D := {<i,j> in A with i == j};
set U := {<i,j> in A with i > j};
param a[<i,j> in O] := 0;
param b[<i,j> in D] := i;
param g[<i,j> in U] := 1;
maximize prob: sum <i> in N : c[i] * p[i];
subto cond2:
forall <i> in N do
sum <j> in N with i>= j do
if(i ==j) then b[i,j] * p[j]
else g[i,j] * p[j] end <= 1 ;
For the matrix A I subdivided the 3 cases (Upper triangle being 0, diagonal being i, and lower traingle being 1) in three parameters, namely param a,b and g.
I was wondering whether there is a more elegant solution by having all three cases in only one parameter, so for the condition at the end I can basically just sum over one parameter.
you can define a function like:
defnumb v(i,j) := if i < j then 0 else if i == j then i else 1 end end;
Afterwards, you can rewrite constraint:
subto cond2:
forall <i> in N do
sum <j> in N with i>= j do v(i,j) * p[j] <= 1;
I hope this is elegant enough.
Best, Jakob