1
$\begingroup$

In my PYOMO abstract model, I am reading my data file and storing some specific attributes in a list say demand=[].

I am reading the data file as follows:

 for node in G.nodes:
    demand.append(G.nodes[node]["demand"])
 print(demand)

I am getting the output as [10, 12, 22, 5, 2]

Now I want to store the values in the list as individual parameters for my model such as:

model.d1=10
model.d2=12

and so on.

Can you guide me on the logic for storing these values as individual parameters?

$\endgroup$

1 Answer 1

1
$\begingroup$

This can be accomplished using the INDEXED COMPONENT concept of Pyomo.

model.d = Param(demand, within=NonNegativeIntegers)

The Pyomo book explains this in chapter 3 and it is available at 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.