pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

DataPortal bug

Open DLWoodruff opened this issue 7 years ago • 3 comments

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?

DLWoodruff avatar Mar 02 '17 23:03 DLWoodruff

This bug is still present in pyomo 5.7.1.

alok-kinesso avatar Sep 25 '20 05:09 alok-kinesso

@alok-kinesso - I'm going through old bug reports. Is this bug still present in pyomo 6.2?

mrmundt avatar Feb 22 '22 21:02 mrmundt

@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.

zacharygibbs avatar Apr 12 '22 02:04 zacharygibbs