/*------------------------------------------------------------------- Solve integer program in ILOG Solver -------------------------------------------------------------------*/ /*** Solve ***/ X.setStorable(); ip.add(generateVar(X, *chooseVar)); if (objtype[0] == 0) allInt ? ip.setObjMin(ObjInt) : ip.setObjMin(ObjFloat, float_step); else allInt ? ip.setObjMin(-ObjInt) : ip.setObjMin(-ObjFloat, float_step); IlcBool success = IlcFalse; while (ip.nextSolution()) { success = IlcTrue; ip.storeSolution(); } if (!success) { ip.out() << "Problem is unbounded or infeasible" << endl; exit(10); } ip.restart(); ip.nextSolution(); /*** Write solution ***/ if (timing) Times[2] = xectim_(); int sSoFar = 0; char sMsg[256]; real *Xopt = new real [n_var]; sSoFar += Sprintf(sMsg, "%s: optimal solution found\n", solverID); sSoFar += Sprintf(sMsg+sSoFar, "%d choice points, objective ", ip.getNumberOfChoicePoints()); if (allInt) g_fmtop(sMsg+sSoFar, ObjInt.getValue()); else g_fmtop(sMsg+sSoFar, ObjFloat.getValue()); for(j = 0; j < n_var; j++) Xopt[j] = X[j].getValue(); write_soln(sMsg, Xopt, 0); ip.out() << endl; delete [] Xopt; /*** Write timings ***/ if (timing) { Times[3] = xectim_(); fprintf(stdout, "Times (seconds):\nInput = %g\nSolve = %g\nOutput = %g\n\n", Times[1] - Times[0], Times[2] - Times[1], Times[3] - Times[2]); } ip.end(); return 0; }