Hi everyone,
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 :
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;
Ps: when we have a equations system with the same number of equations and variables, Are there any other way to solve the problem? I mean, the LP maximizing is a optimization proces and it wouldn’t be necessary in that system. In this example, I have put the variable “s” because I don’t know other way to solve the system although my goal would be take the variable “X”. I know I could do this easy example without doing equations( using IF and PARAMETERS), but I must resolve with equations in my real problem.
Thanks everybody