You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using SCIP as the solver (possibly with other .nl file-based solvers as well), any initialized Boolean variable will make SCIP fail ("ERROR: expected double"). The obvious workaround is to declare the variable as Binary and explicitly cast (False, True) to (0, 1).
SCIP version 8.0.3 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: Soplex 6.0.3] [GitHash: 62fab8a2e3]
Copyright (C) 2002-2022 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)
External libraries:
Soplex 6.0.3 Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: f900e3d0]
CppAD 20180000.0 Algorithmic Differentiation of C++ algorithms developed by B. Bell (github.com/coin-or/CppAD)
ZLIB 1.2.13 General purpose compression library by J. Gailly and M. Adler (zlib.net)
AMPL/MP 4e2d45c4 AMPL .nl file reader library (github.com/ampl/mp)
PaPILO 2.1.2 parallel presolve for integer and linear optimization (github.com/scipopt/papilo) [GitHash: 2fe2543]
bliss 0.77 Computing Graph Automorphism Groups by T. Junttila and P. Kaski (www.tcs.hut.fi/Software/bliss/)
Ipopt 3.14.12 Interior Point Optimizer developed by A. Waechter et.al. (github.com/coin-or/Ipopt)
user parameter file <scip.set> not found - using default parameters
read problem <knapsack.nl>
============
[reader_nl.cpp:1355] ERROR: knapsack.nl:16:3: expected double
[scipshell.c:216] ERROR: Error <-2> in function call
[scipshell.c:272] ERROR: Error <-2> in function call
[scipshell.c:559] ERROR: Error <-2> in function call
SCIP Error (-2): read error
Information on your system
Pyomo version: 6.5.0
Python version: 3.10.10
Operating system: Windows 10
How Pyomo was installed (PyPI, conda, source): conda
Solver (if applicable): SCIP
Additional information
pyomo/repn/plugins/nl_writer.pynl_write.py uses calls to repr() extensively, mostly as f-strings (f'var {value!r}'). Since pyomo stores the values for boolean variables as numpy.bool_ type, the use of repr() alone is not adequate to write their values as SCIP-readable .nl files.
The above case can be fixed by replacing the code block starting at this line:
This is probably not the way to fix this bug. Maybe Boolean variables need to be cast to Binary [0, 1] before calling the writer. Otherwise, there are likely other place in the writer code that would need changing.
The text was updated successfully, but these errors were encountered:
Summary
When using SCIP as the solver (possibly with other
.nl
file-based solvers as well), any initialized Boolean variable will make SCIP fail ("ERROR: expected double"). The obvious workaround is to declare the variable as Binary and explicitly cast (False, True) to (0, 1).Steps to reproduce the issue
Which generates the file
knapsack.nl
:Error Message
SCIP output to
scip knapsack.nl -AMPL
:Information on your system
Pyomo version: 6.5.0
Python version: 3.10.10
Operating system: Windows 10
How Pyomo was installed (PyPI, conda, source): conda
Solver (if applicable): SCIP
Additional information
pyomo/repn/plugins/nl_writer.pynl_write.py
uses calls torepr()
extensively, mostly as f-strings (f'var {value!r}'
). Since pyomo stores the values for boolean variables asnumpy.bool_
type, the use ofrepr()
alone is not adequate to write their values as SCIP-readable.nl
files.The above case can be fixed by replacing the code block starting at this line:
by this block:
This is probably not the way to fix this bug. Maybe Boolean variables need to be cast to Binary [0, 1] before calling the writer. Otherwise, there are likely other place in the writer code that would need changing.
The text was updated successfully, but these errors were encountered: