Code: Select all
set i index of elements in the matrix /1*11/
parameter A(i) the row matrix
/1 0
2 -2
3 3
4 0
5 5
6 6
7 7
8 -8
9 9
10 -10
11 11/
;
Variables
total;
binary variable pick(i);
Equations
cost_func define objective function
limit_selection;
cost_func .. total =e= sum(i, pick(i) * A(i));
limit_selection .. card(pick) =l= 4;
Model alveva /all/;
Solve alveva using MINLP maximizing total;
display total.l, total.m;
Can anyone help me fix this?