Bravos-Power / pyoframe

Rapidly formulate huge optimization models
https://bravos-power.github.io/pyoframe/
MIT License
1 stars 1 forks source link

Map variables (or expressions) from one set of indexes to another #21

Closed kjartan-at-bravos closed 3 months ago

kjartan-at-bravos commented 3 months ago

The suggested improvement is motivated by the following use-case: Power system models will typically have bus voltage angles as decision variables, and a number of transmission lines defined with "to-bus" and "from-bus". In the DC-model the flow in a transmission line equals the line susceptance times the voltage difference between its "from-bus" and "to-bus". Thus, we want to formulate the differences between the voltage angles for each transmission line. This will be a set of variables (or expressions) that should be indexed by the transmission line ID.

A suitable syntax for this could be the following:

# from_bus and to_bus are polar Dataframes each with two columns "l" and "n"
# voltage_angle is a Variable indexed over "n" and "t"
angle_diff = voltage_angle.map(from_bus) - voltage_angle.map(to_bus)