IBM ILOG Solver User's Manual > More on Modeling > Using Constrained Floating-Point Variables: Modeling Equations > Using IloGenerateBounds

The function IloGenerateBounds creates and returns a goal. The goal efficiently reduces the domain of a floating-point variable by propagating any constraints on that variable more than usual. It checks whether the boundaries of the domain of the variable are consistent with all the constraints posted on the variable. If that is not the case, then it reduces an interval around the variable until the boundaries become consistent up to the precision indicated by a precision parameter. If the precision is small, the new domain computed by IloGenerateBounds will be smaller. However, the smaller the precision, the longer the computation will take. This function works on IloNumVar variables or IloNumVarArray arrays of variables. (The type can be either Float or Int.)

The following example uses the goal returned by IloGenerateBounds to search for a solution.

The problem is to find the roots of the following polynomial:

(x + 1)(x + 2)...(x + 20) + 2-23x19

That example can be coded like this:

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main () {
  IloEnv env;
  try {
    IloModel model(env);

    IloNumVar x(env, -1e10, 1e10);

    IloExpr y = x + 1;
    for(IloInt i = 2; i <= 20; i++)
      y = y * (x + i);

    model.add(y + IloPower(2, -23) * IloPower(x, 19) == 0);
    y.end();

    IloSolver solver(env);
    solver.setDefaultPrecision(1e-8);

    solver.out().precision(8);

    solver.extract(model);
    
    solver.startNewSearch(IloGenerateBounds(env, x, 1e-5) && 
                          IloDichotomize(env, x));
    
    while (solver.next()) 
      solver.out() << "x = " << solver.getFloatVar(x) << endl;
    solver.printInformation();
    solver.endSearch();
  }
  catch (IloException& ex) {
    cout << "Error: " << ex << endl;
  }
  env.end();
  return 0;
}

That program prints all the roots of the equation.

x = [-1..-1]
x = [-2..-2]
x = [-3..-3]
x = [-4..-4]
x = [-4.9999999..-4.9999999]
x = [-6.0000069..-6.0000069]
x = [-6.9996972..-6.9996972]
x = [-8.0072676..-8.0072676]
x = [-8.9172503..-8.9172502]
x = [-20.846908..-20.846908]

The complete program is available online in the YourSolverHome/examples/src/wilkins.cpp file.