Visual Code Python debugging tool crashes when trying to access "Model" object attributes before optimization
See original GitHub issueConsider 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?
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Debug Python code - Visual Studio (Windows) - Microsoft Learn
Open a command window in Visual Studio using the View > Other Windows > Command Window menu command. · Enter the following command:...
Read more >Debugging configurations for Python apps in Visual Studio Code
Sets a debug property that must be known to the debug server before the client connects. Such properties can be used directly in...
Read more >Python's assert: Debug and Test Your Code Like a Pro
When Not to Use Assertions? Understanding Python's assert Statements. The Syntax of the assert Statement; The AssertionError Exception.
Read more >A comprehensive guide to debugging Python scripts in VS Code
The basics · Variables Pane — here we can easily inspect the variables which are created while running the script. · Watch Pane...
Read more >Changelog — Python 3.11.1 documentation
gh-98783: Fix multiple crashes in debug mode when str subclasses ... gh-96352: Fix AttributeError missing name and obj attributes in object.
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
Hello Otávio !
Currently we throw an exception when an specific property of a variable (the solution value x) is accessed, since the debugger is probably trying to access all properties we have this problem…
I think that the behaviour could be changed to just return None as solution value when no optimization is performed. I’ll include this change in the next release.
Cheers,
Haroldo
–
Haroldo Gambini Santos Computing Department Universidade Federal de Ouro Preto - UFOP email: haroldo@ufop.edu.br Haroldo.GambiniSantos@cs.kuleuven.be home/research page: www.decom.ufop.br/haroldo
It has long been an axiom of mine that the little things are infinitely the most important. – Sir Arthur Conan Doyle, “A Case of Identity”
On Wed, 20 Nov 2019, Otávio Augusto Silva wrote:
I just tested it with the new version, there’s still something causing crashes.