I know it could be a "stupid question" but I could find anything about write this type of conditional.
I will try to simplify my problem by the next example:
I have a matrix which I need to put a condition for an specific positions. The mathematical expression would be something like that:
X(i,j)=A(i,j) ∀𝑗,i≠1,i≠4;
X(i,j)=B(i,j) ∀𝑗,i=1,i=4;
My gms code would be :
Code: Select all
Sets
i modulo /1*5/
j nodo /1*5/;
table A(i,j)
1 2 3 4 5
1 1 2 3 4 5
2 6 7 8 9 10
3 11 12 13 14 15
4 16 17 18 19 20
5 21 22 23 24 25
;
table B(i,j)
1 2 3 4 5
1 0 1 2 3 4
2 0 1 2 3 4
3 0 1 2 3 4
4 0 1 2 3 4
5 0 1 2 3 4
;
Variable
X(i,j)
s;
Equations
EQ1, EQ2, obj;
EQ1(i,j)$(j ne 1)and(j ne 4).. X(i,j)=e=A(i,j);
EQ2(i,j)$(j = 1)and(j = 4).. X(i,j)=e=B(i,j);
obj..s=e=sum((i,j),x(i,j));
Model MTR /all/ ;
Solve MTR using lp maximizing s;
Thanks everybody