Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2.02k stars 518 forks source link

DataPortal bug #120

Closed DLWoodruff closed 1 year ago

DLWoodruff commented 7 years ago

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?
alok-kinesso commented 4 years ago

This bug is still present in pyomo 5.7.1.

mrmundt commented 2 years ago

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

zacharygibbs commented 2 years ago

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