7.2 Callback Functions

The second method, based on defining a set of callback functions, offers several distinct advantages, especially for more complex scenarios or for adding a feature for others to use, such as the zonal reserve requirement or the interface flow limits mentioned previously. This approach makes it possible to:

With this approach the OPF formulation is modified in the formulation callback, which is described and illustrated below in Section 7.3.2. The modifications to the formulation are handled by adding variables, costs and/or constraints to the OPF Model object (om) using one of the add_* methods. Please see the documentation for each of these methods for more details.

7.2.1 User-defined Variables

Additional variables are added using the add_var method.

om.add_var('myV', N, myV0, myV_min, myV_max);

Here myV is the name of the variable set, N the number of variables being added (i.e. this is an N  × 1  vector being appended to the current optimization variable ˆx  ), and myV0, myV_min, myV_max are vectors of initial values, lower bounds and upper bounds, respectively.

7.2.2 User-defined Costs

7.2.3 User-defined Constraints