Reputation: 27
Currently, I'm working on docplex on python.
I just found out that result from IBM cplex Ilog and docplex is way different.
Even though their constraints, objective function, everything are identical, their solution is very different.
In some cases, docplex says infeasible even though it is feasible in Ilog.
I tried to limit integrality and minimum gap in docplex tolerances but the same problem happens.
Is there anyone have idea why this happens? and how to solve this??
Upvotes: 0
Views: 695
Reputation: 10059
In order to understand what is different you could export models in a lp file.
See
mdl.export("c:\\temp\\buses.lp")
in
from docplex.mp.model import Model
mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.minimize(nbbus40*500 + nbbus30*400)
mdl.solve()
mdl.export("c:\\temp\\buses.lp")
for v in mdl.iter_integer_vars():
print(v," = ",v.solution_value)
"""
which gives
nbBus40 = 6.0
nbBus30 = 2.0
"""
Upvotes: 1
Reputation: 836
To complement Alex's answer: in Docplex, Model.export_as_lp(path'c:/temp/mymodel.lp') is the way to generate a LP file from you Docplex model. In Cplex's Python API, you have a Cplex instance, use cpx.write('c:/temp/mymodel_cplex.lp') to generate the LP files.
If your models are identical, then both LP files should also be identical (except maybe some differences in variable ordering, e.g. x2+x1 instead of x1+x2). If you need to work the same model both APIs, then you must first reach this equality before going further.
DOcplex has tools to investigate infeasible models, but there is no point until you ensure both models are identical.
Upvotes: 1
Reputation: 3
Something must be different between the two versions. You can use refine_conflict to know the source of infeasibility
Upvotes: 0