Hello,
I am relatively new to Julia and power systems optimization. At the moment, I am trying to understand power flows from scratch and this involves coding up/defining branch power flows for a simple
three bus network.
To do this, I have resorted to a crude approach of first defining the line equations and then attaching the equation to an equality constraint. I also want to limit the power flows to some value. The approach isn’t working as I’m getting error messages.
using JuMP, Clp, DataFrames, CSV
basic_model = Model(Clp.Optimizer)
@variable(basic_model, GEN[T, C] >=0) #Conventional plant generation
@variable(basic_model, FLOW[T, L] ) #power flow
@constraint(basic_model,
CapConstraint[t in T, c in C],
GEN[t,c] <= data[:plants][:g_max][c] ) # Capacity constraint
## issue starts here
flow1 = sum(1/3*GEN[1:3,"basel"] - 1/3*GEN[1:3,"bern"])
flow2 = sum(2/3*GEN[1:3,"basel"] + 1/3*GEN[1:3,"bern"])
flow3 = sum(1/3*GEN[1:3,"basel"] + 2/3*GEN[1:3,"bern"])
@constraint(basic_model,
LineFlowA[t in T, l in L],
FLOW[t,l] == flow1 )
@constraint(basic_model,
LineFlowB[t in T, l in L],
FLOW[t,l] == flow2 )
@constraint(basic_model,
LineFlowC[t in T, l in L],
FLOW[t,l] == flow3 )
@constraint(basic_model,
FlowMax_Pos[t in T, l in L],
FLOW[t,l] <= data[:lines][:f_max][l]
) #positve line flow constraint
@constraint(basic_model,
FlowMax_Neg[t in T, l in L],
FLOW[t,l] >= -data[:lines][:f_max][l]
) #negative line flow constraint
Sample error message when trying to code the flow (flow1 - flow3)
ERROR: MethodError: no method matching promote_shape(::Tuple{Vector{Int64}}, ::Tuple{Vector{Int64}})
A simple and viable approach to define the line flow constraints would be greatly appreciated.
Thanks