2

I use Docplex with python 3.7 to implement constraints programming. when it was infeasible, how can i proceed to list constraints those was to source of the conflict?

mdl.export_as_cpo(out="/home/..../MCP3.lp")
msol = mdl.solve(FailLimit=700000, TimeLimit=1600)
DInfos= msol.get_solver_infos()
mconflict=msol.CpoRefineConflictResult()
mconflict.get_all_member_constraints()

Error message: mconflict=msol.CpoRefineConflictResult() AttributeError: 'CpoSolveResult' object has no attribute 'CpoRefineConflictResult'

Issouf
  • 140
  • 12

2 Answers2

2

solve returns a SolveResult, and CpoRefineConflictResult is a class in docplex.cp.solution. So, the error message is correct: a SolveResult does not have an attribute CpoRefineConflictResult. You'd expect the CpoRefineConflictResult as the result of the conflict refiner.

You should probably read through the documentation a bit more http://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.solution.py.html

You can call the .refine_conflict() method on the CpoSolver object to obtain a CpoRefineConflictResult, as documented here http://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.solver.solver.py.html#detailed-description

Perhaps you can provide a minimal, reproducible example, if you need a more specific solution to your problem. https://stackoverflow.com/help/minimal-reproducible-example

Grismar
  • 27,561
  • 4
  • 31
  • 54
  • Thanks for this clarification, i have read the documentation and now my question is how to invoke the conflict refiner ? – Issouf Jul 23 '19 at 01:22
0

I have add:

from  docplex.cp.solver.solver import CpoSolver

After, i have add those lines if the model is infeasible:

mconfl= CpoSolver(model)
mconf = mconfl.refine_conflict()
Issouf
  • 140
  • 12