coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
513 stars 88 forks source link

Lazy Callback Question #343

Closed ryanhammonds closed 1 year ago

ryanhammonds commented 1 year ago

I'm considering adding python-mip as an option to a package that currently depends on cplex. The requirement is to run some custom code whenever the MIP solver finds an integer feasible solution that will compute a cut and add it to the MIP formulation as a lazy constraint. Right now we do this using the LazyCutCallback callback in cplex. Could the same be accomplished using lazy_constrs_generator, subclassing ConstrsGenerator, and defining the the callback in generate_constrs? I also wanted to confirm that lazy_constrs_generator is compatible with cbc, as the goal is to have an open source solver supported in the package I'm working on.

I noticed that there was some interest in a cplex interface in #49. If the lazy cut callback above is supported, I was planning on writing an interface class for python-mip, that could be accessed using cplex syntax (e.g. calling model.solve for model.optimize, etc), so that it could be easily integrated into the package I'm working on. But the inverse may be useful here. If there is current interest in this, I could make a PR for a cplex interface. Thanks!

sebheger commented 1 year ago

@ryanhammonds Thanks for your offer.

CPLEX interface would be quite a nice thing. Feel free to open a PR. At the moment #255 we are trying to intergrate another open source solver

CBC is theoretically supporting lazy cut generation during optimization through python-mip the way you described, but it is buggy #95 , #143 , #175 , and many more