Fail to access variable in lazy_constrs_generator callback
See original GitHub issueIssue Description
After seeing “Reduced cost fixing - 45 rows, 117 columns - restarting search” message, variable access in lazy_constrs_generator callback will fail. All variable names are changed.
I see that both heuristics and preprocess are turned off at the beginning. Why it still triggers mini B&B?
The strangest thing is that, this only happens when using PyPy3.6. The same program ran just fine under CPython3.6. I’m using PyPy because it’s about 30% faster than CPython for my program.
Any clue or workaround? The full program with data is a little bit long, but I can provide that upon request.
Starting MIP optimization
Option for heuristicsOnOff changed from on to off
Option for preprocess changed from sos to off
Option for timeMode changed from cpu to elapsed
maxSavedSolutions was changed from 0 to 10
integerTolerance was changed from 1e-06 to 1e-06
Option for mergeCliques changed from off to after
Option for cliqueCuts changed from ifmove to off
Option for bkcliqueCuts changed from off to ifmove
Option for oddholewcCuts changed from off to ifmove
Continuous objective value is 52.3333 - 0.00 seconds
Cgl0015I Clique merge extended 0 cliques, 0 were dominated
Cutoff increment increased from 1e-05 to 0.9999
Cbc0013I At root node, 0 cuts changed objective from 52.333333 to 52.333333 in 1 passes
Cbc0014I Cut generator 0 (LazyConstraints) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is 1
Cbc0014I Cut generator 1 (Probing) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 2 (Gomory) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 3 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 4 (BKClique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 5 (OddHoleWC) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 6 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 7 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 8 (TwoMirCuts) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 9 (ZeroHalf) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100
Cbc0016I Integer solution of 92 found by strong branching after 182 iterations and 37 nodes (0.30 seconds)
Cbc0038I Full problem 228 rows 182 columns, reduced to 45 rows 117 columns
Cbc0044I Reduced cost fixing - 45 rows, 117 columns - restarting search
Cbc0012I Integer solution of 83 found by Previous solution after 0 iterations and 0 nodes (0.38 seconds)
From cffi callback <function SolverCbc.optimize.<locals>.cbc_cut_callback at 0x00007fffef4d52e0>:
Traceback (most recent call last):
File "/localworkspaces/pypy3.6-v7.3.0-linux64/site-packages/mip/cbc.py", line 763, in cbc_cut_callback
self.model.lazy_constrs_generator.generate_constrs(osi_model)
File "/localworkspaces/pysandbox/stp14.py", line 142, in generate_constrs
selected = [n for n, nv in nsv.items() if nv.x >= 0.99]
File "/localworkspaces/pysandbox/stp14.py", line 142, in <listcomp>
selected = [n for n, nv in nsv.items() if nv.x >= 0.99]
AttributeError: 'NoneType' object has no attribute 'x'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
No results found
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
I’m playing with node-weighted steiner tree problems. The code below can trigger the error under pypy3.6-v7.3.0 and CPython3.6.5. Python-MIP version is 1.7.2.
I’ve had this happen to me, the issue was passing something that was not a list of variables to the model.translate() method. I was passing the .values() of a dict (not the dict itself), which doesn’t work.
I suggest changing the code of model.translate() to throw an exception when it cannot do the translation, rather than silently returning the original set of variables.