Division by zero for division of two continuous variables

Dear friends,

I have coded a facility layout problem as a MINLP model. Then, I used Baron as the default solver. In this model, constraint 19b determines the maximum distance between whole departments (DmaxF, a positive variable). Then, this variable is used on the right-hand sides of constraints 22a and 22b. When I run the model, I face an error called division by zero, which is related to constraints 22a and 22b.

But when I replace DmaxF with a constant, e.g., 40, in constraints 22a and 22b, the model solves the problem with no error. Surprisingly, the results show that DmaxF gets positive values (DmaxF <> 0).

Could you please help out? Note that I have attached a .gms file containing all information required for guidance!

Regards,
Amir
Untitled_4.gms (5.73 KB)

Hi Amir
In equation 18b, you use the sqrt function and as Gams initializes variables to 0, you get an error.
If I initialize these variables with a random number, the model starts solving using BONMIN (I don’t have a license for DICOPT).

x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);

I used a random initializiaton as you subtract x(j,t) from x(i,t) (same for y). Initializing them with the same values would results in zeros.

Hope that this solves the problem
Cheers
Renger

Hi Renger,
First of all, I have to appreciate your attention. As per as your valuable comment, I have added the following lines to the code (next to the place I had defined variables), but it does not work even now!

execseed = 1e8*(frac(jnow));
loop(i,
loop(t,
x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);
);
);

or

x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);

Do you have any idea? I have attached a new file in which x and y initialize from random values rather than zero.

Thx a GALAXY
Untitled_4.gms (5.85 KB)

Hi
Here it is exactly the same problem: you did not initialize DmaxF, so add DmaxF.l(t) = 1; and it works.
You don’t need a loop for assigning values to x and y. As long as the index of the variables on the LHS is equal to the RHS in the assignment, without a loop the assignment works well.
Cheers
Renger

I also found another solution to this problem, specifically for the Baron solver. If you add the following code, the Baron could ignore the error and try to find a feasible solution. I think there should be similar options for other solvers as well. But what you mentioned, is a solution for all solvers! Thank you very much. My code works right now.

MaxExecError = 100000;
Option sys12 = 1;