IBM ILOG Solver User's Manual > More on Modeling > Using Constrained Floating-Point Variables: Modeling Equations > Factored and canonical forms of expressions > Factored and canonical forms: Using IloGenerateBounds

IloGenerateBounds is a goal that performs efficient domain reduction, regardless of whether its arguments are factored or canonical form.

Let's look at an example, where the constraint is not written in a factored form but in canonical form, like this:

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main() {

  IloEnv env;
  try {
  IloModel model(env);

  IloNumVar x(env, -2, 2), y(env, 0, 10), z(env, -100, 100);
  model.add(z == x*y - y + 2*x - 2);
  IloSolver solver(model);
  solver.propagate();
  solver.out() << "z = [" << solver.getMin(z)
                          << ", " << solver.getMax(z)
                          << "]" << endl;
}
  catch (IloException& ex) {
          cerr << "Error:" << ex << endl;
  }
  env.end();
  return 0;
}

In this case, the domain of z is:

z = [-36, 22]

If you call the function IloGenerateBounds on the variable z, the reduction is efficient anyway. In other words, in situations where the form of a floating-point expression (whether canonical or factored) is an issue, it's a good idea to exploit IloGenerateBounds.

Here's the example:

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main() {

  IloEnv env;
  try {
  IloModel model(env);

  IloNumVar x(env, -2, 2), y(env, 0, 10), z(env, -100, 100);
  model.add(z == x*y - y + 2*x - 2);
  IloSolver solver(model);
  solver.solve(IloGenerateBounds(env, z, 1e-5));
  solver.out() << "z = [" << solver.getMin(z)
                          << ", " << solver.getMax(z)
                          << "]" << endl;
}
  catch (IloException& ex) {
          cerr << "Error:" << ex << endl;
  }
  env.end();
  return 0;
}

The output is:

z = [-36, 15.04]