# DC OPF Setup

The E4ST.jl DC OPF is set up as a cost minimization problem. Costs are added to the objective function and benefits are subtracted. setup*dcopf!() adds VOM, Fuel Cost, FOM, Capex, and Curtialment Cost to the objective function. Other terms can be added to the objective in Modifications before the model is optimized. A dictionary of the terms added to the objective function can be found in data[:obj*vars].

Constraints and expressions can also be defined outside of setup_dcopf!() before the model is optimized. This will also be done in Modifications.

`E4ST.setup_dcopf!`

— Function`setup_dcopf!(config, data, model)`

Set up a DC OPF problem

### Get Model Variable Function

These functions get or use model variables. To get the value after optimizing the model they must be wrapped in value.().

`E4ST.get_pgen_bus`

— Function`get_pgen_bus(data, model, bus_idx, year_idx, hour_idx)`

Returns total power generation for a bus at a time * To use this to retieve the variable values after the model has been optimized, wrap the function with value() like this: value.(get*pgen*bus).

`E4ST.get_pflow_bus`

— Function`get_pflow_bus(data, model, f_bus_idx, year_idx, hour_idx)`

Returns net power flow out of the bus

- To use this to retieve the variable values after the model has been optimized, wrap the function with value() like this: value.(get
*pflow*bus).

`E4ST.get_pflow_branch`

— Function`get_pflow_branch(data, model, branch_idx, year_idx, hour_idx)`

Return total power flow on a branch.

- If branch
*idx*signed is positive then positive power flow is in the direction f*bus -> t*bus listed in the branch table. It is measuring the power flow out of f_bus. - If branch
*idx*signed is negative then positive power flow is in the opposite direction, t*bus -> f*bus listed in the branch table. It is measuring the power flow out of t_bus. - To use this to retieve the variable values after the model has been optimized, wrap the function with value() like this: value.(get
*pflow*branch).

### Constriant/Expression Info Function

These functions are used in defining the model constraints.

Missing docstring for `get_pgen_max`

. Check Documenter's build log for details.

`E4ST.get_egen_gen`

— Function`get_egen_gen(data, model, gen_idx)`

Returns the total energy generation from a gen summed over all rep time.

`get_egen_gen(data, model, gen_idx, year_idx)`

Returns the total energy generation from a gen summed over rep time for the given year.

`get_egen_gen(data, model, gen_idx, year_idx, hour_idx)`

Returns the total energy generation from a gen for the given year and hour. This is pgen*gen multiplied by the number of hours spent at that representative hour. See [`get*hour_weight`](@ref)

- To use this to retieve the variable values after the model has been optimized, wrap the function with
`value()`

like this:`value.(get_egen_gen(args...))`

.

### Model Mutation Functions

These functions are used to modify the model, specifically creating and adding terms to the objective expression. The `Term`

abstract type is used to determine how the term (cost or benefit) should be added to the objective function.

`E4ST.Term`

— Type`abstract type Term`

Abstract type Term is used to add variables (terms) to the objective function or other functions. Subtypes include PerMWhGen, PerMWCap, and PerMWhCurtailed.

Missing docstring for `PerMWhGen`

. Check Documenter's build log for details.

Missing docstring for `PerMWCap`

. Check Documenter's build log for details.

Missing docstring for `PerMWhCurtailed`

. Check Documenter's build log for details.

Missing docstring for `PerMWCapInv`

. Check Documenter's build log for details.

`E4ST.add_obj_term!`

— Function`add_obj_term!(data, model, ::Term, s::Symbol; oper)`

Adds or subtracts cost/revenue `s`

to the objective function of the `model`

based on the operator `oper`

. Adds the cost/revenue to the objective variables list in data.

`E4ST.add_obj_exp!`

— Function`function add_obj_exp!(data, model, term::Term, s::Symbol; oper)`

Adds expression s (already defined in model) to the objective expression model[:obj]. Adds the name, oper, and type of the term to data[:obj_vars].