0

In my GAMS model, I have a objective function that involves a division.

GAMS sets the initial values to zero whenever it solves something...brilliant idea, how could that possibly ever go wrong!....oh wait, now there's division by zero.

What is the approach to handle this? I have tried manually setting lower bounds such that division by zero is avoided, but then GAMS spits out "infeasible" solution.

Which is wrong, since I know the model is feasible. In fact, removing the division term from my model and resolving does produce a solution. This solution ought to be feasible for the original problem as well, since we are just adding terms to the objective.

merija
  • 215
  • 1
  • 4

2 Answers2

2

Here are some common approaches:

  • set a lower bound. E.g. Z =E= X/Y, add Y.LO = 0.0001;
  • similarly, write something like: Z =E= X/(Y+0.0001)
  • set a initial value. E.g. Y.L = 1
  • Multiply both sides by Y: Z*Y =E= X

For any non-linear variable you should really think carefully about bounds and initial values (irrespective of division).

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Yeah, I just randomly set some bounds and initial values, and that worked. Thanks. Still feel the approach is slightly clumsy though. – merija May 15 '18 at 18:04
0

Try using the $ sign. For example: A(i,j)$C(i,j) = B(i,j) / C(i,j)

GFA
  • 86
  • 2