coin-or / coin-or/python-mip

Visual Code Python debugging tool crashes when trying to access "Model" object attributes before optimization

Open
#26 16 comments 0 reactions 0 assignees View on GitHub
bug cbc
Dominant language
Linear Programming
Stars
600
Forks
108
PR merge metrics
No merged PRs in 30d

Description

Consider the following code to model the maximum independent set problem to solve the maximum clique using MIP and NetworkX:

```
import mip
import networkx

n = 2 ** 3
g = networkx.binomial_tree(n)
networkx.add_star(g, [i for i in range(n)])
g1 = networkx.complement(g)

model = mip.Model("Independent Set")
x = [model.add_var(var_type=mip.BINARY) for _ in range(len(g1.nodes))]
model.objective = mip.maximize(mip.xsum(x[i] for i in range(len(g1.nodes))))
for (i, j) in g1.edges:
model += x[i] + x[j] <= 1
model.optimize()
selected = [i for i in range(len(g1.nodes)) if x[i].x >= 0.99]
print(selected)
g2 = g.subgraph(selected)
```

If I try to access the `model` variables in the `watch` section, it gives he following message on terminal:
```
Information not available, model was not optimized yet.
```
And then, the debugger dies. I believe this is not what should happen, some help with this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.