IBM ILOG Solver User's Manual > More on Modeling > Using Constrained Floating-Point Variables: Modeling Equations > Using floating-point variables in expressions

Concert Technology allows you to define expressions involving floating-point variables. For example, you can formulate constraints on floating-point expressions by using the operators:

You can then use these expression to formulate constraints:

The following example model and solves a simple equation by mixing constrained integer variables and constrained floating-point variables. The floating-point variables are modeled using the class IloNumVar. The member function IloSolver::getFloatVar returns the algorithmically constrained floating-point variable corresponding to the variable x. Here is the example:

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main() {

  IloEnv env;
  try {
  IloModel model(env);

  IloNumVar x(env, -2, 2), y(env, -100, 100);
  model.add((x - 1)*(x + 2) == y );
  IloSolver solver(model);
  solver.propagate();
  cout << "y = " << solver.getFloatVar(y) << endl;
}
  catch (IloException& ex) {
          cerr << "Error:" << ex << endl;
  }
  env.end();
  return 0;
}

The output is:

y = [-12, 4]