Querying Results

After successfully solving the optimization problem, you probably are interested in accessing the solution. The following methods can be used to query the solution value for a variable or a set of variables:

  IloNum IloCplex::getValue(IloNumVar var) const;
  void IloCplex::getValues(IloNumArray val,
                           const IloNumVarArray var) const;

For example:

  IloNum val1 = cplex.getValue(x1);

stores the solution value for the modeling variable x1 in variable val1. Other methods are available for querying other solution information. For example, the objective function value of the solution can be accessed using:

  IloNum objval = cplex.getObjValue();

Previous Page: Solving the Model - IloCplex   Return to Top Next Page: Handling Errors