Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

LazyConstraint based MIP yields incorrect optimum

Open
#331 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Start with the attached lazy-minimal-example.py.txt and compare its complete-model, lazy-constraint, and lazy-constraint-generator runs against the execution log. Trace the Python-MIP lazy-constraint handling with CBC; done means both lazy variants produce the same optimum as the complete model and report it correctly.

Written by the indexing model from the issue text.

Description

bug cbc

Describe the bug
Solving a MIP with lazy constraints yields a sub optimal solution. Yet, the solver reports the solution to be optimal.

My assumption is that adding all constraints (a) up-front, (b) as lazy constraints, or (c) using a lazy constraint generator should not affect the optimal of the solution. Is this assumption incorrect?

To Reproduce
A minimal example with 1 continuous variable (the objective), 4 integer variables, and 2 constraint is provided.
The problem is solved three times: (a) complete model, (b) lazy constraints, (c) using lazy constraint generator.

Solving the complete model yields the true optimal solution. Both lazy variants provide a sub-optimal solution.
Variant (c) shows that both constraints are generated and added to the model in the first call to the lazy constraint generator.

Expected behavior
Using (generated) lazy constraints should yield the same optimum as solving the complete model with all constraint provided up front.

Desktop (please complete the following information):

  • Operating System, version: macOS Monterey 12.4 (M1)
  • Python version: 3.9.6
  • Python-MIP version (we recommend you to test with the latest version): 1.14.2
  • CBC built from coin-or/cbc/0713c30b8e5e2b2a8e1b804ee9d98087fc524530 (23.Nov 2022)

Example Program and Execution Log:
lazy-minimal-example.py.txt
lazy-minimal-example.log

Dominant language
Linear Programming
Stars
601
Forks
108
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coin-or/python-mip

All issues in coin-or/python-mip

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.