I am learning about Benders Decomposition and now, I am working with the file bendersatsp.py
. I understand that in the model (ATSP) which is programmed in it it isn't necessary add feasibility cuts. I would like to see a toy example in which it is necessary to add feasibility cuts using the same code structure that in this file in order to understand how to do that.
I have been thinking about that:
Is necessary to add a new condition if
inside the function def separate
:
if cpx.solution.get_status() == cpx.solution.status.MIP_optimal:
Can that be an option?
Thanks a lot!
I think you got that wrong: the example only separates feasibility cuts.
Your idea to hook into function separate
for optimality cuts is correct, though. However, since the subproblem is an LP and not a MIP you will have to check the status for cpx.solution.status.optimal
instead.
There currently is no example code for this in Python. On the other hand, it is probably not too hard to just take any textbook Benders description, align that with the Python example you quoted and then extend separation yourself.
In cplex/examples/src/remotec/parbenders.c
you have a Benders implementation that separates both types of cuts. This implementation is in C but may given that Python and C API are similar, this may help you.