Skip to content

set_array for a 3-Tuple set membership #1119

@daniel1685

Description

@daniel1685

I am trying to define 3-tuple data with the set_array format. The data is taken from an excel file.
My code:

from pyomo.environ import *

model = ConcreteModel()

model.A = Set([A1,A2,A3])
model.B = Set([B1, B2, B3])
model.C = Set([C1, C2, C3])
model.D = Set(model.A, model.B, model.C)
data = DataPortal()
data.load(filename='excel.xlsx', range='set3', format='set_array', set='D')

Excel table (excel.xlsx, range=set3)

B C A1 A2 A3
B1 C1 + - +
B2 C2 - - +
B3 C3 + + +
the problem is that the code is generating a 2-tuple set instead of a 3-tuple. The result I am obtaining is:

D =[(A1, B1), (A3, B1), (A3, B2), (A1, B3), (A2, B3), (A3, B3)]

What I would like:

D =[(A1, B1, C1), (A3, B1, C1), (A3, B2, C2), (A1, B3, C3), (A2, B3, C3), (A3, B3, C3)]

Any suggestion and/or recommendations would be very much appreciated. Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    not plannedpyomo.dataAny issues related to data portals and data file parsing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions