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

Bug about different VarList objects sharing the same components

Open
#409 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with the VarList entry point and run the reproduction from the issue against Python-MIP 1.14.2. Trace how VarList instances add and iterate variables within the same Model; done means separate lists yield only their own variables while existing VarList behavior remains intact.

Written by the indexing model from the issue text.

Description

Describe the bug
For the same model, if I create two VarList (called list1 and list2), then some cache bugs happen.
If I use list1 for storing x_1, x_2, x_3, ... and use list2 for storing y_1, y_2, y_3, ..., then the two lists will sharing elements.

It is very easy to reproduce it.

To Reproduce

import mip # version 1.14.2


model = mip.Model(name="test_model")
var_list = mip.VarList(model=model)
var_list.add(name="x1")
var_list.add(name="x2")
for var in var_list:
    print(var.name)
# print outputs:
# x1
# x2

var_list2 = mip.VarList(model=model)
var_list2.add(name="y1")
var_list2.add(name="y2")
var_list2.add(name="y3")
for var in var_list2:
    print(var.name)

# print outputs:
# x1
# x2
# y1

Expected behavior
I expect these two var list of the same model should not have the same components.

Desktop (please complete the following information):

  • Operating System, version: Linux
  • Python version: 3.12
  • Python-MIP version (we recommend you to test with the latest version): 1.14.2

Additional context
I have replaced this with the standard Python list in my project to bypass the bug.
Appreciate your work. If it is not a bug, could you tell me your design logic?

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 Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.