Equation infeasible due to rhs value Topic is solved

Problems with syntax of GAMS
Post Reply
seydaseyda
User
User
Posts: 31
Joined: 3 years ago

Equation infeasible due to rhs value

Post by seydaseyda »

Hi everyone!

I am trying to solve a model on gams. I am comparing the lengths of each possible pieces and if it is greater than 1, gams can add this piece to the model. Otherwise, gams should not add this piece to the model and it should move on another point to calculate length of the another possible piece.
any two points can make a piece.

I basically added a equation.
i shows the beginning point
j shows the final point of the piece
l(i,j) shows the length of that piece.

Code: Select all


eq1(i,j)..l(i,j)=g=1;

But it gives me Equation infeasible due to rhs value error.

When I check the .lst file;

e.g. point 19 and point 13;

eq1(19,13).. 0 =G= 0.695861873485089 ; (LHS = 0, INFES = 0.695861873485089 ****)

It gives me 0.695861873485089. Also according to calculations the length of the piece between 19-13 is 0,304138. LHS must be 0,304138 and RHS must be 1, but it gives me (1-0,304138) instead of 1.

Could you please help me how can I solve this problem?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Equation infeasible due to rhs value

Post by abhosekar »

Hi,

is l(i, j) a parameter or a variable? If it is a parameter, then your problem is infeasible simply because 0.3 >= 1 should be infeasible. Regarding the error, GAMS is just rearranging the values 0 >= 0.7. This is equivalent to 0.3 >= 1 and both are infeasible.
If l(i, j) is a variable (which I don't think it is since you know the values), then you are forcing all l(i, j) to be greater than 1, I am not sure if you want to do this. You should instead assign a binary variable p(i, j) which is 1 if l(i, j) >=1 and 0 otherwise. Then you can use this variable p in combination with big-M constraints to model your constraints.

Hope this helps.

- Atharv
seydaseyda
User
User
Posts: 31
Joined: 3 years ago

Re: Equation infeasible due to rhs value

Post by seydaseyda »

Hi,

I also try to add a binary variable like that

Code: Select all

u(i,j) if length between i and j is greater than 1 it is 1 otherwise 0;
u.l(i,j)$(ord(i)<>ord(j) and d(i,j)>=1);



But it did not work.
Could you please help me how can i modify this?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Equation infeasible due to rhs value

Post by abhosekar »

I would suggest you to read about big-M constraints and look up some optimization formulations that have implemented a similar logic and adapt your model according to it. The question you are asking are related to general optimization and not specific to GAMS.

Looking back at your problem, binary variable is not needed. One can simply impose an 'if' condition wherever needed $l(i, j) ge 1 or $l(i, j) ge 1

It should be noted that when you assign a value to u.l(i, j) you are only setting the level value (which is sort of an initial guess).

It is not clear from the question what is the purpose of such a constraint. Are l and d same? Are those parameters or variables? What is the purpose of having a constraint that checks if a parameter is greater than 1?

I would suggest getting more clarity on the optimization formulation (understanding what is your objective, what are variables, what are the constraints) before implementing in GAMS.

- Atharv
Post Reply