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 righthand 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
Division by zero for division of two continuous variables

 User
 Posts: 21
 Joined: 3 years ago
Division by zero for division of two continuous variables
 Attachments

 Untitled_4.gms
 (5.73 KiB) Downloaded 76 times
Re: Division by zero for division of two continuous variables
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).
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
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).
Code: Select all
x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);
Hope that this solves the problem
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist

 User
 Posts: 21
 Joined: 3 years ago
Re: Division by zero for division of two continuous variables
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!
Code: Select all
execseed = 1e8*(frac(jnow));
loop(i,
loop(t,
x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);
);
);
Code: Select all
x.l(i,t) = uniform(1,10);
y.l(i,t) = uniform(1,10);
Thx a GALAXY
 Attachments

 Untitled_4.gms
 (5.85 KiB) Downloaded 66 times
Re: Division by zero for division of two continuous variables
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
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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist

 User
 Posts: 21
 Joined: 3 years ago
Re: Division by zero for division of two continuous variables
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.
Code: Select all
MaxExecError = 100000;
Option sys12 = 1;