.. _opf: Optimisation problem ====================== The equation describes the basic formulation of the optimal power flow (OPF) problem. The pandapower optimal power flow can be constrained by either AC or DC loadflow equations. The branch constraints represent the maximum apparent power loading of transformers and the maximum line current loadings. The bus constraints can contain maximum and minimum voltage magnitude and angle. For the external grid, generators, loads, DC lines and static generators, the maximum and minimum active resp. reactive power can be considered as operational constraints for the optimal power flow. The constraints are defined element wise in the respective element tables. .. math:: & min & \sum_{i \ \epsilon \ gen, sgen, load, ext\_grid}{f_{i}(P_i)} \\ & subject \ to \\ & & loadflow \ equations \\ & & branch \ constraints \\ & & bus \ constraints \\ & & operational \ power \ constraints \\ **Generator flexibilities / Operational power constraints** The active and reactive power generation of generators, loads, dc lines and static generators can be defined as a flexibility for the OPF. .. tabularcolumns:: |p{0.40\linewidth}|p{0.4\linewidth}| .. csv-table:: :file: opf_flexibility.csv :delim: ; .. note:: Defining operational constraints is indispensable for the OPF, it will not start if constraints are not defined. **Network constraints** The network constraints contain constraints for bus voltages and branch flows: .. tabularcolumns:: |p{0.40\linewidth}|p{0.4\linewidth}| .. csv-table:: :file: opf_constraints.csv :delim: ; The defaults are unconstrained branch loadings and :math:`\pm 1.0 pu` for bus voltages. Cost functions --------------- The cost function is specified element wise and is organized in tables as well, which makes the parametrization user friendly. There are two options formulating a cost function for each element: A piecewise linear function with :math:`n` data points. .. math:: f_{pwl}(p) = f_{\alpha} +(p-p_{\alpha}) \frac{f_{\alpha + 1}-f_{\alpha}}{p_{\alpha + 1}-p_{\alpha}} \ , \ (p_{\alpha},f_{\alpha}) \ =\begin{cases} (p_{0},f_{0}) \ , \ & p_{0} < p