toing_toing
toing_toing

Reputation: 2442

cannot enforce strict bound ampl

I set a variable to var p > 0; after it was var p >=0; (and a working model) to make sure that I do not get a divide by zero error. Now, while trying to run the model, it gives me the following error:

cannot enforce strict bound
context:  var p >  >>> 0; <<<

After a quick search, I found that I have to give a low value and not zero to make it work.

var p > 0.00001; or var p > 1e-6;

however, it still gives the same error. Can you please explain what exactly is the issue here, and how to solve it? My equation is of the form

Maximize Z : (quadratic function of p)/p;

Upvotes: 1

Views: 770

Answers (1)

G_B
G_B

Reputation: 1573

Optimisation in general (and AMPL in particular) generally requires that the feasible region is topologically closed, i.e. any limit point of the permitted solution space is itself part of the solution space. This means that strict inequalities are generally not permitted as constraints on variables.

To understand why, consider the problem:

var p > 0;
maximize OF: 1-p^2;

Even though the OF is obviously bounded and can never exceed 1, this cannot be optimised because there is no optimal value of p. For any permitted (i.e. positive) value of p that you might propose, I can improve the objective function by halving p. It's hard to define an optimisation algorithm that deals with a situation where no optimum exists, not even a local optimum!

(Technically, machine precision does impose an optimal value of p, where p is the smallest positive number that can be represented in computer arithmetic. But if we want to look at it that way, then effectively we do have a strict inequality, p >= eps, and we're better off acknowledging that explicitly.)

For this reason, constraints on variables generally need to be non-strict inequalities, e.g. replace "> 0" with ">= smallnum".

Upvotes: 4

Related Questions