Skip to content

wangxk9999/dnn-opf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

AC-OPF Learning

Author: Ferdinando Fioretto

Last update: July, 9, 2019

This repository contains the code is associated with paper:

Predicting AC Optimal Power Flows: Combining Deep Learning and Lagrangian Dual Methods. Ferdinando Fioretto, Terrence W.K. Mak, Pascal Van Hentenryck. In Proceedings of the AAAI Conference on Artificial Intelligence (AAAI), 2020.

Cite as

@inproceedings{Fioretto:AAAI20, 
  author    = {Ferdinando Fioretto and {Terrence W.K.} Mak and Pascal {Van Hentenryck}},
  title     = {Predicting {AC} Optimal Power Flows: Combining Deep Learning and Lagrangian Dual Methods},
  pages     = {630--637},
  publisher = {{AAAI} Press},
  booktitle = {The Thirty-Fourth {AAAI} Conference on Artificial Intelligence {(AAAI)}}
  url    =  {https://ojs.aaai.org/index.php/AAAI/article/view/5403}, 
  DOI    =  {10.1609/aaai.v34i01.5403}, 
  year   = {2020}
}

Usage

Dataset Generation The training set for a network are generated using the following command:

  julia src/opf_solver/opf_datagen.jl --netname nesta_case14_ieee
			      	      --lb 0.8 --ub 1.2 --step 0.0001

It will generate test cases varying the nominal power loads (pd, qd) by a multiplicative factor $\delta \in [lb, ub]$ with a step size indicated by the step parameter.

OPF-training Step

After the training data is generated we can train our Neural Network. To do so, run the following command:

  julia src/ml-opf.jl --netname nesta_case14_ieee

The following arguments can be set:

  • --nocuda (Do not use CUDA).
    • Default value: false
  • --traindata The name of the input file, within the "netname" folder. It expects a file formatted as the output of the dataset generation procedure.
    • Default value: "traindata.json"
  • --outfile The name of the output file, within the "netname" folder.
    • Default value: "results.json"
  • --nepochs The number of epochs.
    • Default value: 10
  • --batchsize The size of the batch.
    • Default value: 1
  • --split Train split in (0, 1). The rest is given to Test.
    • Default value: 0.8
  • --version Problem version [1, 2].
    • version 1: outputs (pg, vg)
    • version 2: outputs (pg, vg), (S_ij, S_ji)
    • Default value: 2
  • --lr The learning rate.
    • Default value: 0.001
  • --c_pv_bnd Activate Lagrangian on Pg and Vg bounds.
    • Default value: true
  • --c_flow_loss Activate lagrangian on total flow loss.
    • Default value: false
  • --c_thermolimits Activate thermolimits loss
    • Default value: false
    • Version required: >= 2

The program above executes two main steps:

  1. A Training Step: It trains the neural network and produces the vector (pg, vg) of predictions.

  2. A Testing Step: This testing routine calls a restoration program for each network in the test set. The restoration program leaves a free slack bus, runs an OPF (i.e., it finds an assignment for the variables <qg, va, vm>). Recall that we predict the voltage magnitude only for generator buses.

The second step produces an output file, saved by default in "results.json". Its component are reviewed next.

Result Output

The result file, output of the testing restoration phase is described by the following components. All these results pertain the networks generated in the test set:

  • settings: It contains the parameters with which the training step was run. These include the arguments of the ml-opf.jl program.
  • results:
    • n_fail: The number of instances for which a restoration procedure failed.
    • n_success: The number of instances for which a restoration procedure succeeded.
    • n_primal_feasible: The number of instances for which a restoration procedure did not converged but a primal feasible solution is returned.
    • avg_objective_diff: The average OPF objective difference between that associated to the original networks and that obtained during the restoration phase using the predicted (pg, vg).
    • avg_err_pg: The average difference between the vectors pg in the original network and in the predictions.
    • avg_err_vg: The average difference between the vectors vg in the original network and in the predictions.
    • avg_solve_time_restoration: The average solve time taken by the restoration procedure.
    • avg_solve_time_ori: The average solve time taken to solve the original OPF problems.
    • test_errors: The errors obtained during the learning test phase. In this phase, we simply verify the prediction outputs of networks not seen during training.
      • err_pv: The MSE error for the vector predicted vectors pg and vg w.r.t. the original ones
      • err_flow: The MSE error for the vector predicted vector p_from, q_from, p_to, q_to w.r.t. the original ones
    • train_losses: The vector of losses obtained during the training step. We store the losses obtained at each training iteration, for each loss function adopted.
      • mse_pv
      • mse_flow (only for ver >= v2)
      • vg_bnd (if c_pv_bnd constraint is active)
      • pg_bnd (if c_pv_bnd constraint is active)
      • thermo (if c_thermolimits constraint is active, and ver >= 2)
      • real_flow_loss (if c_flow_loss constraint is active)

AC-OPF Learning model

Inputs:

  • vector of demands: $(p^d, q^d) \in \mathbb{R}^{2n}$ Output:
  • vector of generators and voltage levels: $(p^g, v^g) \in \matbb{R}^{2n}$

Once the output vector is given, the values for the vectors $q^g, \delta$ can be retrieved as solving a power flow problem.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 99.7%
  • Julia 0.3%