Issue with ConstrsGenerator
See original GitHub issueHi,
I’m trying to implement lazy constraint generation by extending the ConstrsGenerator
class. I’ve been following the docs here https://python-mip.readthedocs.io/en/latest/custom.html and the example here https://github.com/coin-or/python-mip/blob/master/examples/queens-lazy.py, but I can’t seem to get it to work.
I have this small toy example that is failing and I’m not sure why.
import mip
class DelayedConstraintGenerator(mip.ConstrsGenerator):
def generate_constrs(self, model):
print("generating_constraints")
for v in model.vars:
print(v, v.x)
model += v >= 5
m = mip.Model()
x = m.add_var('x', var_type=mip.INTEGER)
y = m.add_var('y', var_type=mip.INTEGER)
m += x + y, "objective"
m += x + y <= 10
m.lazy_constrs_generator = DelayedConstraintGenerator()
status = m.optimize()
print(status)
for v in m.vars:
print(v, v.x)
Output from the example is:
generating_constraints
x 0.0
y 0.0
generating_constraints
x 0.0
y 0.0
OptimizationStatus.INFEASIBLE
x None
y None
I’m on Python-MIP 1.6.2 and Python 3.6.9.
Issue Analytics
- State:
- Created 4 years ago
- Comments:30 (23 by maintainers)
Top Results From Across the Web
Classes - Python MIP Documentation - Read the Docs
A cuts generator is an ConstrsGenerator object that receives a fractional solution and tries to generate one or more constraints (cuts) to remove...
Read more >Mixed Integer Linear Programming with Python - Read the Docs
ConstrsGenerator ] property lp_method. Which method should be used to solve the linear programming problem. If the problem has.
Read more >coin-or/python-mip 1.11.0 on GitHub - NewReleases.io
Python-MIP 1.11.0. Two additional parameters, three depth and pass number, are now informed to the generage_constrs method in ConstrsGenerator class (which ...
Read more >Mixed Integer Linear Programming with Python - DocPlayer.net
5 Chapter 1 Introduction The Python-MIP package provides tools for modeling and solving Mixed-Integer Linear Programming Problems (MIPs) [Wols98] in Python.
Read more >Haroldo G. Santos (@unxusr) / Twitter
... in ConstrsGenerator class (which is used for cut/lazy constraints callb. ... preemption are well-known NP-hard combinatorial optimization problems.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re welcome ! Thank @stefanhannie and @jooyous for the detailed bug report.
hi @jooyous and @stefanhannie , already fixed in master thanks to @jjhforrest ! will release another version tomorrow.