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

The function IloDichotomize creates and returns a goal in a Concert Technology model. The goal tries to instantiate constrained floating-point variables. To do so, it recursively searches half the domain of each variable at a time. This function works on IloNumVar variables or IloNumVarArray arrays of variables. (The type can be either Float or Int.)

The following example computes the intersection between the folium of Descartes and an exponentially decaying function. It uses the goal returned by IloDichotomize to search for a solution.

For the model of the problem, you use two variables related by the following equations:

x*x/y + y*y/x = 2

y = e-x

Here is the code:.

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main() {
  IloEnv env;
  try {
    IloModel model(env);
    
    IloNumVar x(env, -1e30, 1e30);   // Declaring the variables 
    IloNumVar y(env, -1e30, 1e30);    

    model.add(x*x/y + y*y/x == 2.);  // Posting the constraints
    model.add(y == IloExponent(-x));  

    IloSolver solver(model);
    solver.startNewSearch(IloDichotomize(env, x));

    while (solver.next()) {
      solver.out() << "x = " << solver.getFloatVar(x) << endl;
      solver.out() << "y = " << solver.getFloatVar(y) << endl << endl;
    }
    solver.printInformation();
    solver.endSearch();
  }
  catch (IloException& ex) {
    cout << "Error: " << ex << endl;
  }
  env.end();
  return 0;
}

The program finds two solutions:

x = [0.868418..0.868418]
y = [0.419615..0.419615]

x = [0.294563..0.294563]
y = [0.744857..0.744857]

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