Division by zero for division of two continuous variables

Problems with modeling
Post Reply
moosavi_69
User
User
Posts: 12
Joined: 1 year ago

Division by zero for division of two continuous variables

Post by moosavi_69 » 3 months ago

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
Attachments
Untitled_4.gms
(5.73 KiB) Downloaded 27 times

User avatar
Renger
Posts: 161
Joined: 2 years ago

Re: Division by zero for division of two continuous variables

Post by Renger » 3 months ago

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).

Code: Select all

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

moosavi_69
User
User
Posts: 12
Joined: 1 year ago

Re: Division by zero for division of two continuous variables

Post by moosavi_69 » 3 months ago

Renger wrote:
3 months ago
...
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.
...
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!

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);
);
);
or

Code: Select all

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
Attachments
Untitled_4.gms
(5.85 KiB) Downloaded 14 times

User avatar
Renger
Posts: 161
Joined: 2 years ago

Re: Division by zero for division of two continuous variables

Post by Renger » 3 months ago

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

moosavi_69
User
User
Posts: 12
Joined: 1 year ago

Re: Division by zero for division of two continuous variables

Post by moosavi_69 » 3 months ago

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;

Post Reply