E-CE0600 — Non-numeric value in a fixed-variables dictionary
Error Type |
|
|---|---|
Phase |
configuring |
Python exception |
|
Message
Each value in the dictionary fixing an indexed variable in `fixed_variables` must be an `int` or `float`, but got `{type_name}`.
Possible fix: map every subscript to a numeric value.
({type_name} is the Python type of the offending value)
Cause
An entry in the fixed_variables argument (of Problem.eval, Problem.generate_random_instance, or the Compiler constructor) fixes an indexed decision variable with a dictionary mapping subscripts to values, and one of those values could not be converted to a number.
For example, fixed_variables={"x": {(0, 1): "one"}} raises this error because "one" is not numeric.
Besides int and float, values that support numeric conversion, such NumPy numeric scalars, are also accepted; strings are not, even if they spell a number.
Fix
Map every subscript to an int or float:
problem.eval(
instance_data,
fixed_variables={"x": {(0, 1): 1.0, (0, 2): 0.0}},
)
If the values come from a solver result or a data frame, convert them to plain numbers (e.g. with float(v)) before building the dictionary.