#include /*a simple example of value ordering: random*/ ILOSTLBEGIN class mySelectI: public IlcIntSelectI { public: mySelectI(){} virtual IlcInt select(IlcIntVar var); }; IlcInt mySelectI::select(IlcIntVar var) { /* //if this code is chosen then values will be //tried in this order: 0,-1,1,-2,2,... IlcInt vn = var.getNextLower(1); if (vn == 0) return 0; IlcInt vp = var.getNextHigher(0); if (vp == 0) return vn; if (vn == 1) return vp; if (-vn <= vp) return vn; return vp; */ IlcInt domSize = var.getSize(); IlcInt lowerBound = var.getMin(); return lowerBound + domSize*rand()/(RAND_MAX+1); } IlcIntSelect mySelect(IloSolver solver) { return new (solver.getHeap()) mySelectI(); } int main(int argc, char* argv[]){ int seed = atoi(argv[1]); srand(seed); IloEnv env; IloModel model(env); IloNumVar x(env, -3, 5, ILOINT); model.add(x); IloSolver solver(model); IloGoal goal = IloInstantiate(env, x, mySelect(solver)); solver.startNewSearch(IloInstantiate(env, x, mySelect(solver))); while (solver.next()) solver.out() << solver.getValue(x) << endl; solver.endSearch(); env.end(); return 0; }