# Linear Model¶

The main optimizer is `LPOptimizer`

. It creates linear programming problem representing network adequacy. We will see mathematics problem, step by step

Basic adequacy equations

Add lack of adequacy terms (lost of load and spillage)

As you will see, \(\Gamma_x\) represents a quantity in network, \(\overline{\Gamma_x}\) is the maximum, \(\underline{\Gamma_x}\) is the minimum, \(\overline{\underline{\Gamma_x}}\) is the maximum and minimum a.k.a it’s a forced quantity. Upper case grec letter is for quantity, and lower case grec letter is for cost \(\gamma_x\) associated to this quantity.

## Basic adequacy¶

Let’s begin by the first adequacy behavior. We have a graph \(G(N, L)\) with \(N\) nodes on the graph and \(L\) unidirectional edges on this graph.

### Variables¶

\(n \in N\) a node belongs to graph

\(T \in \mathbb{Z}_+\) time horizon

Edge variables

\(l \in L\) an unidirectional edge belongs to graphs

\(\overline{\Gamma_l} \in \mathbb{R}^T_+\) maximum power transfert capacity for \(l\)

\(\Gamma_l \in \mathbb{R}^T_+\) power transfered inside \(l\)

\(\gamma_l \in \mathbb{R}^T_+\) proportional cost when \(\Gamma_l\) is used

\(L^n_\uparrow \subset L\) set of edges with direction to node \(n\) (i.e. importation for \(n\))

\(L^n_\downarrow \subset L\) set of edges with direction from node \(n\) (i.e. exportation for \(n\))

Productions variables

\(P^n\) set of productions attached to node \(n\)

\(p \in P^n\) a production inside set of productions attached to node \(n\)

\(\overline{\Gamma_p} \in \mathbb{R}^T_+\) maximum power capacity available for \(p\) production.

\(\Gamma_p \in \mathbb{R}^T_+\) power capacity of \(p\) used during adequacy

\(\gamma_p \in \mathbb{R}^T_+\) proportional cost when \(\Gamma_p\) is used

Consumptions variables

\(C^n\) set of consumptions attached to node \(n\)

\(c \in C^n\) a consumption inside set of consumptions attached to node \(n\)

\(\underline{\overline{\Gamma_c}} \in \mathbb{R}^T_+\) forced consumptions of \(c\) to sustain.

### Objective¶

### Constraint¶

First constraint is from Kirschhoff law and describes balance between productions and consumptions

Then productions and edges need to be bounded

## Lack of adequacy¶

### Variables¶

Sometime, there are a lack of adequacy because there are not enough production, called *lost of load*.

Like \(\Gamma_x\) means quantity present in network, \(\Lambda_x\) represents a lack in network (consumption or production) to reach adequacy. Like for \(\Gamma_x\) , lower case grec letter \(\lambda_x\) is for cost associated to this lack.

\(\Lambda_c \in \mathbb{R}^T_+\) lost of load for \(c\) consumption

\(\lambda_c \in \mathbb{R}^T_+\) proportional cost when \(\Lambda_c\) is used

### Objective¶

Objective has a new term

### Constraints¶

Kirschhoff law needs an update too. Lost of Load is represented like a *fantom* import of energy to reach adequacy.

Lost of load must be bounded

## Storage¶

### Variables¶

Storage is a element inside Hadar to store quantity on a node. We have:

\(S^n\) : set of storage attached to node \(n\)

\(s \in S^n\) a storage element inside a set of storage attached to node \(n\)

\(\Gamma_s\) current capacity inside storage \(s\)

\(\overline{ \Gamma_s }\) max capacity for storage \(s\)

\(\Gamma_s^0\) initial capacity inside storage \(s\)

\(\gamma_s\) linear cost of capacity storage \(s\) for one time step

\(\Gamma_s^\downarrow\) input flow to storage \(s\)

\(\overline{ \Gamma_s^\downarrow }\) max input flow to storage \(s\)

\(\Gamma_s^\uparrow\) output flow to storage \(s\)

\(\overline{ \Gamma_s^\uparrow }\) max output flow to storage \(s\)

\(\eta_s\) storage efficiency for \(s\)

### Objective¶

### Constraints¶

Kirschhoff law needs an update too. **Warning with naming** : Input flow for storage is a output flow for node, so goes into consuming flow. And as you assume output flow for storage is a input flow for node, and goes into production flow.

And all these things are bounded :

Storage has also a new constraint. This constraint applies over time to ensure capacity integrity.

## Multi-Energies¶

Hadar handle multi-energies. In the code, one energy lives inside one network. Multi-energies means multi-networks. Mathematically, there are all the same. That why we don’t talk about multi graph, there are always one graph \(G\), nodes remains the same, with same equation for every kind of energies.

The only difference is how we link node together. If nodes belongs to same network, we use *link (or edge)* seen before. When nodes belongs to different energies we need to use *converter*. All things above remains true, we just add now a new element \(V\) converters ont this graph \(G(N, L, V)\) .

Converter can take energy form many nodes in different network. Each converter input has a ratio between output quantity and input quantity. Converter has only one output to only on node.

### Variables¶

\(V\) set of converters

\(v \in V\) a converter in the set of converters

\(V^n_\uparrow \subset V\) set of converters

**to**node \(n\)\(V^n_\downarrow \subset V\) set of converters

**from**node \(n\)\(\Gamma_v^\uparrow\) flow

**from**converter \(v\).\(\overline{\Gamma_v^\uparrow}\) max flow from converter \(v\)

\(\gamma_v\) linear cost when \(\Gamma_v^\uparrow\) is used

\(\Gamma_v^\downarrow\) flow(s)

**to**converter. They can have many flows for \(v \in V\), but only one for \(v \in V^n_\downarrow\)\(\overline{\Gamma_v^\downarrow}\) max flow to converter

\(\alpha^n_v\) ratio conversion for converter \(v\) from node \(n\)

### Objective¶

### Constraints¶

Of course Kirschhoff need a little update. Like for storage **Warning with naming !** Converter input is a consuming flow for node, converter output is a production flow for node.

And all these things are bounded :

Now, we need to fix ratios conversion by a new constraints