Hi
To complement what was written, let me share an example.
This example wil show you that printConflict also works with CPO and that you can iterate on the conflicts.
using CP;
range r = 1..10;
dvar int+ x[r] in 1..20;
{string} ctInConflict={};
// Preferences are stated as data of the opl model.
// prefs[i] will be used to represent the preference of seeing cts[i] in the conflict.
float prefs[i in r] = i;
minimize sum(i in r) x[i];
subject to {
forall(i in r)
cts: i+5 - x[i] <=0;
forall(i in r)
cts2: x[i] - i-5+2 <=0;
}
main {
thisOplModel.generate();
var def = thisOplModel.modelDefinition;
// Default behavior
writeln("Default Behavior");
var opl1 = new IloOplModel(def, cp);
opl1.generate();
writeln(opl1.printConflict());
// now iterating manually
writeln("now iterating manually");
writeln();
var iter = opl1.conflictIterator;
for(var c in iter)
{
var ct=c.ct;
writeln(ct.name, " with status ", c.status);
opl1.ctInConflict.add(ct.name);
firstOne=0;
writeln(ct.name,";");
}
writeln(opl1.ctInConflict);
opl1.end();
writeln();
// Default behavior
writeln("Default Behavior");
var opl2 = new IloOplModel(def, cp);
opl2.generate();
writeln(opl2.printConflict());
}
regards
#DecisionOptimization#OPLusingCPOptimizer