pyomo
pyomo copied to clipboard
DataPortal bug
bug found by: Maria Marcos Nuñez
from pyomo.environ import *
model = AbstractModel()
# Definición de los diferentes parametros del modelo
model.qv = Param(within = NonNegativeReals)
# Definicion de las variables
model.D = Var(within = NonNegativeReals, bounds =(0.2, 6),initialize = 3, doc='Diametro del reactor')
# silly objective function supplied by DLW
def _e(m):
return m.qv * m.D
model.silliness = Objective(rule=_e)
data = DataPortal()
data.load(filename="foobar.dat")
mc = model.create_instance(data)
contents of foobar.dat:
param qv := 7.734;
output (after stack trace):
ValueError: Parameter 'qv' defined with '1' dimensions, but data has '1' values: [7.734]. Are you missing a value for a 1-dimensional index?
This bug is still present in pyomo 5.7.1
.
@alok-kinesso - I'm going through old bug reports. Is this bug still present in pyomo 6.2
?
@alok-kinesso, @mrmundt
I just tried this in pyomo 6.4 and got a similar error as is listed here.
A little more detail, attempting to initialize a scalar param.