├── sddip ├── sddip │ ├── __init__.py │ ├── common.py │ ├── constants.py │ ├── storage.py │ ├── sddip_logging.py │ ├── tree.py │ ├── utils.py │ ├── ucmodelclassical.py │ └── scenarios.py ├── operators │ └── __init__.py ├── scripts │ ├── __init__.py │ ├── create_result_directories.py │ ├── copy_raw.py │ ├── clear_result_directories.py │ ├── create_supplementary.py │ ├── gather_latest_results.py │ └── create_scenarios.py ├── __init__.py ├── __main__.py ├── config.py ├── logging.py ├── session.py └── cli.py ├── poetry.toml ├── data └── 01_test_cases │ ├── case118 │ ├── raw │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ └── bus_data.txt │ └── t12_n06 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ └── bus_data.txt │ ├── case14 │ ├── raw │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t06_n03 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t06_n06 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t08_n06 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t12_n06 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t12_n12 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t24_n06 │ │ ├── storage_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ └── info │ │ └── case14.m │ ├── case30 │ ├── raw │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── ren_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t06_n06 │ │ └── gen_sup_data.txt │ ├── t06_n12 │ │ └── gen_sup_data.txt │ ├── t08_n06 │ │ └── gen_sup_data.txt │ ├── t12_n06 │ │ └── gen_sup_data.txt │ ├── t12_n12 │ │ └── gen_sup_data.txt │ ├── t24_n06 │ │ └── gen_sup_data.txt │ ├── t24_n12 │ │ └── gen_sup_data.txt │ └── info │ │ └── case30.m │ ├── WB5 │ ├── raw │ │ ├── ren_data.txt │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ └── branch_data.txt │ ├── t06_n03 │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t06_n06 │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t08_n06 │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t12_n06 │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── storage_data.txt │ │ ├── gen_cost_data.txt │ │ ├── gen_data.txt │ │ ├── bus_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ └── info │ │ └── WB5.m │ ├── case6ww │ ├── raw │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ └── branch_data.txt │ ├── t06_n03 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t06_n06 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t08_n06 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t12_n06 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ ├── branch_data.txt │ │ └── scenario_data.txt │ ├── t12_n12 │ │ ├── storage_data.txt │ │ ├── ren_data.txt │ │ ├── gen_sup_data.txt │ │ ├── gen_cost_data.txt │ │ ├── bus_data.txt │ │ ├── gen_data.txt │ │ └── branch_data.txt │ └── info │ │ └── case6ww.m │ └── supplementary │ └── load_profiles │ ├── h0_summer_workday.xlsx │ └── h0_summer_workday.txt ├── LICENSE ├── sessions └── demo.toml ├── pyproject.toml ├── .gitignore ├── docs └── README.md └── notebooks └── archive └── results.ipynb /sddip/sddip/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sddip/operators/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sddip/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry.toml: -------------------------------------------------------------------------------- 1 | [virtualenvs] 2 | in-project = true 3 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/raw/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC -------------------------------------------------------------------------------- /sddip/__init__.py: -------------------------------------------------------------------------------- 1 | from sddip import logging 2 | 3 | __all__ = ["logging"] 4 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | -------------------------------------------------------------------------------- /sddip/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from . import cli 4 | 5 | cli.main(sys.argv[1:]) 6 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 5 40.0 40.0 2 2 4 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 5 40.0 40.0 2 2 4 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 5 40.0 40.0 2 2 4 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 5 40.0 40.0 2 2 4 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/storage_data.txt: -------------------------------------------------------------------------------- 1 | bus Rc Rdc Effc Effdc SOC 2 | 2 10 10 0.9 0.9 30 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 2 0 3 0 4.00 0 3 | 2 2 0 3 0 1.00 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 2 0 3 0 4.00 0 3 | 2 2 0 3 0 1.00 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 2 0 3 0 4.00 0 3 | 2 2 0 3 0 1.00 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 2 0 3 0 4.00 0 3 | 2 2 0 3 0 1.00 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 2 0 3 0 4.00 0 3 | 2 2 0 3 0 1.00 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 2 30.0 30.0 2 2 4 | 3 36.0 36.0 2 2 5 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 2 30.0 30.0 2 2 4 | 3 36.0 36.0 2 2 5 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 20.0 20.0 5 5 3 | 2 15.0 15.0 5 5 4 | 3 18.0 18.0 5 5 5 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 40.0 40.0 2 2 3 | 2 30.0 30.0 2 2 4 | 3 36.0 36.0 2 2 5 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 100.0 100.0 2 2 3 | 2 75.0 75.0 2 2 4 | 3 90.0 90.0 2 2 5 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 166.2 166.2 5 5 3 | 2 70.0 70.0 5 5 4 | 3 50.0 50.0 5 5 5 | 6 50.0 50.0 5 5 6 | 8 50.0 50.0 5 5 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 66.48 66.48 2 2 3 | 2 28.0 28.0 2 2 4 | 3 20.0 20.0 2 2 5 | 6 20.0 20.0 2 2 6 | 8 20.0 20.0 2 2 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 66.48 66.48 2 2 3 | 2 28.0 28.0 2 2 4 | 3 20.0 20.0 2 2 5 | 6 20.0 20.0 2 2 6 | 8 20.0 20.0 2 2 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 33.24 33.24 5 5 3 | 2 14.0 14.0 5 5 4 | 3 10.0 10.0 5 5 5 | 6 10.0 10.0 5 5 6 | 8 10.0 10.0 5 5 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 166.2 166.2 5 5 3 | 2 70.0 70.0 5 5 4 | 3 50.0 50.0 5 5 5 | 6 50.0 50.0 5 5 6 | 8 50.0 50.0 5 5 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 166.2 166.2 5 5 3 | 2 70.0 70.0 5 5 4 | 3 50.0 50.0 5 5 5 | 6 50.0 50.0 5 5 6 | 8 50.0 50.0 5 5 7 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 100 50 3 0.00533 11.669 213.1 3 | 2 100 50 3 0.00889 10.333 200 4 | 2 100 50 3 0.00741 10.833 240 -------------------------------------------------------------------------------- /data/01_test_cases/supplementary/load_profiles/h0_summer_workday.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leoschleier/sddip/HEAD/data/01_test_cases/supplementary/load_profiles/h0_summer_workday.xlsx -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case30/t06_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t06_n12/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t08_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t12_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t12_n12/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t24_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/t24_n12/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 16.0 16.0 2 2 3 | 2 16.0 16.0 2 2 4 | 22 10.0 10.0 2 2 5 | 27 11.0 11.0 2 2 6 | 23 6.0 6.0 2 2 7 | 13 8.0 8.0 2 2 8 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.0430292599 20 0 3 | 2 0 0 3 0.25 20 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 10 5 3 0.02 2 0 3 | 2 10 5 3 0.0175 1.75 0 4 | 2 10 5 3 0.0625 1 0 5 | 2 10 5 3 0.00834 3.25 0 6 | 2 10 5 3 0.025 3 0 7 | 2 10 5 3 0.025 3 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 500 50 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 3 | 5 0 0 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 500 50 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 3 | 5 0 0 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 500 50 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 3 | 5 0 0 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 500 50 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 3 | 5 0 0 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 500 50 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 3 | 5 0 0 1800 -30 1 100 1 200 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /sddip/scripts/create_result_directories.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from sddip import config 4 | 5 | 6 | def main() -> None: 7 | for dir in [config.RESULTS_DIR, config.LOGS_DIR]: 8 | Path(dir).mkdir(parents=True, exist_ok=True) 9 | 10 | 11 | if __name__ == "__main__": 12 | main() 13 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95 3 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95 4 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95 5 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95 6 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95 3 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95 4 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95 5 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95 6 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95 3 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95 4 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95 5 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95 6 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95 3 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95 4 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95 5 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95 6 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95 3 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95 4 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95 5 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95 6 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05 3 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05 4 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07 5 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95 6 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95 7 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0 3 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0 4 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 16 | 15 0 17 | 16 0 18 | 17 0 19 | 18 0 20 | 19 0 21 | 20 0 22 | 21 0 23 | 22 0 24 | 23 0 25 | 24 0 26 | 25 0 27 | 26 0 28 | 27 0 29 | 28 0 30 | 29 0 31 | 30 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 4 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/raw/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360 3 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360 4 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 5 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 6 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360 7 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360 3 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360 4 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 5 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 6 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360 7 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360 3 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360 4 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 5 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 6 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360 7 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360 3 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360 4 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 5 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 6 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360 7 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360 3 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360 4 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 5 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360 6 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360 7 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 23.54 0 150 -20 1 100 1 80 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 60.97 0 60 -20 1 100 1 80 0 0 0 0 0 0 0 0 0 0 0 0 4 | 22 21.59 0 62.5 -15 1 100 1 50 0 0 0 0 0 0 0 0 0 0 0 0 5 | 27 26.91 0 48.7 -15 1 100 1 55 0 0 0 0 0 0 0 0 0 0 0 0 6 | 23 19.2 0 40 -10 1 100 1 30 0 0 0 0 0 0 0 0 0 0 0 0 7 | 13 37 0 44.7 -15 1 100 1 40 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/raw/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n12/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360 3 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360 4 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360 5 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360 6 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360 7 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360 8 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360 9 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360 10 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360 11 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360 12 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94 3 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94 4 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94 5 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94 6 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94 7 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94 8 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94 9 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94 10 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94 11 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94 12 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94 13 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94 14 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94 15 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94 -------------------------------------------------------------------------------- /sddip/scripts/copy_raw.py: -------------------------------------------------------------------------------- 1 | """Copy raw data files to test case directories.""" 2 | 3 | import shutil 4 | from pathlib import Path 5 | 6 | 7 | def move_files(source: Path, target: Path) -> None: 8 | for f in source.glob("*"): 9 | shutil.copy2(f, target / f.name) 10 | 11 | 12 | if __name__ == "__main__": 13 | test_cases = [ 14 | "WB5", 15 | "case6ww", 16 | "case14", 17 | "case118", 18 | ] 19 | 20 | cwd = Path.cwd() 21 | test_dir = cwd / "data" / "01_test_cases" 22 | 23 | for case in test_cases: 24 | test_case_dir = test_dir / case 25 | raw_dir = test_case_dir / "raw" 26 | raw_files = list(raw_dir.glob("*")) 27 | 28 | for test in test_case_dir.glob(r"t*"): 29 | move_files(raw_dir, test) 30 | -------------------------------------------------------------------------------- /sddip/sddip/common.py: -------------------------------------------------------------------------------- 1 | from enum import StrEnum, auto 2 | 3 | 4 | class CutType(StrEnum): 5 | """Types of cuts for SDDiP.""" 6 | 7 | BENDERS = auto() 8 | STRENGTHENED_BENDERS = auto() 9 | LAGRANGIAN = auto() 10 | 11 | @classmethod 12 | def from_str(cls, s: str) -> "CutType": 13 | """Converts a string to a CutType.""" 14 | match s: 15 | case "BENDERS" | "benders" | "b": 16 | return cls.BENDERS 17 | case "STRENGTHENED_BENDERS" | "strengthened_benders" | "sb": 18 | return cls.STRENGTHENED_BENDERS 19 | case "LAGRANGIAN" | "lagrangian" | "l": 20 | return cls.LAGRANGIAN 21 | case _: 22 | msg = f"Invalid CutType: {s}" 23 | raise ValueError(msg) 24 | -------------------------------------------------------------------------------- /sddip/scripts/clear_result_directories.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import shutil 4 | 5 | from sddip import config 6 | 7 | logger = logging.getLogger(__name__) 8 | 9 | 10 | def main() -> None: 11 | for rd in [config.RESULTS_DIR, config.LOGS_DIR]: 12 | for filename in os.listdir(rd): 13 | file_path = os.path.join(rd, filename) 14 | try: 15 | if os.path.isfile(file_path) or os.path.islink(file_path): 16 | os.unlink(file_path) 17 | elif os.path.isdir(file_path): 18 | shutil.rmtree(file_path) 19 | except Exception as ex: 20 | logger.exception( 21 | "Failed to delete %s. Reason: %s", file_path, ex 22 | ) 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /sddip/sddip/constants.py: -------------------------------------------------------------------------------- 1 | class ResultKeys: 2 | # Result keys 3 | v_key = "v" 4 | x_key = "x" 5 | y_key = "y" 6 | x_bs_key = "x_bs" 7 | soc_key = "soc" 8 | primal_solution_keys = [x_key, y_key, x_bs_key, soc_key] 9 | 10 | dv_key = "dual_value" 11 | dm_key = "dual_multiplier" 12 | dual_solution_keys = [dv_key, dm_key] 13 | 14 | ci_key = "intercepts" 15 | cg_key = "gradients" 16 | y_bm_key = "y_multipliers" 17 | soc_bm_key = "soc_multipliers" 18 | cut_coefficient_keys = [ci_key, cg_key, y_bm_key, soc_bm_key] 19 | 20 | lb_key = "lb" 21 | ub_l_key = "ub_l" 22 | ub_r_key = "ub_r" 23 | bound_keys = [lb_key, ub_l_key, ub_r_key] 24 | 25 | bc_intercept_key = "intercept" 26 | bc_gradient_key = "gradient" 27 | bc_trial_point_key = "trial_point" 28 | benders_cut_keys = [bc_intercept_key, bc_gradient_key, bc_trial_point_key] 29 | 30 | ds_iterations = "iterations" 31 | ds_solver_time = "solver_time" 32 | dual_solver_keys = [ds_iterations, ds_solver_time] 33 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/raw/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t08_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t12_n12/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t24_n06/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.01938 0.05917 0.0528 200 0 0 0 0 1 -360 360 3 | 1 5 0.05403 0.22304 0.0492 200 0 0 0 0 1 -360 360 4 | 2 3 0.04699 0.19797 0.0438 200 0 0 0 0 1 -360 360 5 | 2 4 0.05811 0.17632 0.034 200 0 0 0 0 1 -360 360 6 | 2 5 0.05695 0.17388 0.0346 200 0 0 0 0 1 -360 360 7 | 3 4 0.06701 0.17103 0.0128 200 0 0 0 0 1 -360 360 8 | 4 5 0.01335 0.04211 0 0 200 0 0 0 1 -360 360 9 | 4 7 0 0.20912 0 0 0 200 0.978 0 1 -360 360 10 | 4 9 0 0.55618 0 0 0 200 0.969 0 1 -360 360 11 | 5 6 0 0.25202 0 0 0 200 0.932 0 1 -360 360 12 | 6 11 0.09498 0.1989 0 0 200 0 0 0 1 -360 360 13 | 6 12 0.12291 0.25581 0 0 200 0 0 0 1 -360 360 14 | 6 13 0.06615 0.13027 0 0 200 0 0 0 1 -360 360 15 | 7 8 0 0.17615 0 0 0 200 0 0 1 -360 360 16 | 7 9 0 0.11001 0 0 0 200 0 0 1 -360 360 17 | 9 10 0.03181 0.0845 0 0 200 0 0 0 1 -360 360 18 | 9 14 0.12711 0.27038 0 0 200 0 0 0 1 -360 360 19 | 10 11 0.08205 0.19207 0 0 200 0 0 0 1 -360 360 20 | 12 13 0.22092 0.19988 0 0 200 0 0 0 1 -360 360 21 | 13 14 0.17093 0.34802 0 0 200 0 0 0 1 -360 360 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Leo Schleier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sddip/config.py: -------------------------------------------------------------------------------- 1 | """Configuration file containing paths required by the `sddip` 2 | package. 3 | """ 4 | 5 | import logging 6 | import os 7 | from pathlib import Path 8 | 9 | logger = logging.getLogger(__name__) 10 | 11 | 12 | # Directories 13 | APP_DIR = Path(__file__).parent 14 | 15 | DATA_DIR = APP_DIR / ".." / "data" 16 | 17 | TEST_CASES_DIR = DATA_DIR / "01_test_cases" 18 | RESULTS_DIR = DATA_DIR / "02_results" 19 | LOGS_DIR = DATA_DIR / "03_logs" 20 | 21 | # Load Profile 22 | LOAD_PROFILE_DIR = TEST_CASES_DIR / "supplementary" / "load_profiles" 23 | H0_LOAD_PROFILE_FILE = LOAD_PROFILE_DIR / "h0_summer_workday.txt" 24 | 25 | 26 | if __name__ == "__main__": 27 | logger.info("Current directory: %s", os.getcwd()) 28 | logger.info("App directory: %s", APP_DIR) 29 | 30 | data_dirs = [TEST_CASES_DIR, RESULTS_DIR, LOGS_DIR] 31 | dir_labels = ["Test cases", "Results", "Logs"] 32 | 33 | for data_dir, label in zip(data_dirs, dir_labels, strict=False): 34 | if os.path.isdir(data_dir): 35 | logger.info("%s directory exists.", label) 36 | else: 37 | logger.warning("%s directory does not exists.", label) 38 | -------------------------------------------------------------------------------- /sddip/logging.py: -------------------------------------------------------------------------------- 1 | """Logging configuration.""" 2 | 3 | from pathlib import Path 4 | 5 | _file_path = Path() / "var" / "log" 6 | 7 | 8 | def create_logging_dir() -> None: 9 | """Create the logging directory.""" 10 | _file_path = Path() / "var" / "log" 11 | _file_path.mkdir(parents=True, exist_ok=True) 12 | 13 | 14 | config = { 15 | "version": 1, 16 | "formatters": { 17 | "simple": { 18 | "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s" 19 | } 20 | }, 21 | "handlers": { 22 | "console": { 23 | "class": "logging.StreamHandler", 24 | "level": "NOTSET", 25 | "formatter": "simple", 26 | "stream": "ext://sys.stdout", 27 | }, 28 | "file": { 29 | "class": "logging.FileHandler", 30 | "level": "NOTSET", 31 | "formatter": "simple", 32 | "filename": f"{_file_path}/app.log", 33 | "mode": "w", 34 | }, 35 | }, 36 | "loggers": { 37 | "": {"handlers": ["console"], "level": "INFO"}, 38 | "sddip": { 39 | "handlers": ["console", "file"], 40 | "level": "INFO", 41 | "propagate": False, 42 | }, 43 | }, 44 | } 45 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/raw/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 16 | 15 0 17 | 16 0 18 | 17 0 19 | 18 0 20 | 19 0 21 | 20 0 22 | 21 0 23 | 22 0 24 | 23 0 25 | 24 0 26 | 25 0 27 | 26 0 28 | 27 0 29 | 28 0 30 | 29 0 31 | 30 0 32 | 31 0 33 | 32 0 34 | 33 0 35 | 34 0 36 | 35 0 37 | 36 0 38 | 37 0 39 | 38 0 40 | 39 0 41 | 40 0 42 | 41 0 43 | 42 0 44 | 43 0 45 | 44 0 46 | 45 0 47 | 46 0 48 | 47 0 49 | 48 0 50 | 49 0 51 | 50 0 52 | 51 0 53 | 52 0 54 | 53 0 55 | 54 0 56 | 55 0 57 | 56 0 58 | 57 0 59 | 58 0 60 | 59 0 61 | 60 0 62 | 61 0 63 | 62 0 64 | 63 0 65 | 64 0 66 | 65 0 67 | 66 0 68 | 67 0 69 | 68 0 70 | 69 0 71 | 70 0 72 | 71 0 73 | 72 0 74 | 73 0 75 | 74 0 76 | 75 0 77 | 76 0 78 | 77 0 79 | 78 0 80 | 79 0 81 | 80 0 82 | 81 0 83 | 82 0 84 | 83 0 85 | 84 0 86 | 85 0 87 | 86 0 88 | 87 0 89 | 88 0 90 | 89 0 91 | 90 0 92 | 91 0 93 | 92 0 94 | 93 0 95 | 94 0 96 | 95 0 97 | 96 0 98 | 97 0 99 | 98 0 100 | 99 0 101 | 100 0 102 | 101 0 103 | 102 0 104 | 103 0 105 | 104 0 106 | 105 0 107 | 106 0 108 | 107 0 109 | 108 0 110 | 109 0 111 | 110 0 112 | 111 0 113 | 112 0 114 | 113 0 115 | 114 0 116 | 115 0 117 | 116 0 118 | 117 0 119 | 118 0 -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/ren_data.txt: -------------------------------------------------------------------------------- 1 | bus max_frac 2 | 1 0 3 | 2 0 4 | 3 0 5 | 4 0 6 | 5 0 7 | 6 0 8 | 7 0 9 | 8 0 10 | 9 0 11 | 10 0 12 | 11 0 13 | 12 0 14 | 13 0 15 | 14 0 16 | 15 0 17 | 16 0 18 | 17 0 19 | 18 0 20 | 19 0 21 | 20 0 22 | 21 0 23 | 22 0 24 | 23 0 25 | 24 0 26 | 25 0 27 | 26 0 28 | 27 0 29 | 28 0 30 | 29 0 31 | 30 0 32 | 31 0 33 | 32 0 34 | 33 0 35 | 34 0 36 | 35 0 37 | 36 0 38 | 37 0 39 | 38 0 40 | 39 0 41 | 40 0 42 | 41 0 43 | 42 0 44 | 43 0 45 | 44 0 46 | 45 0 47 | 46 0 48 | 47 0 49 | 48 0 50 | 49 0 51 | 50 0 52 | 51 0 53 | 52 0 54 | 53 0 55 | 54 0 56 | 55 0 57 | 56 0 58 | 57 0 59 | 58 0 60 | 59 0 61 | 60 0 62 | 61 0 63 | 62 0 64 | 63 0 65 | 64 0 66 | 65 0 67 | 66 0 68 | 67 0 69 | 68 0 70 | 69 0 71 | 70 0 72 | 71 0 73 | 72 0 74 | 73 0 75 | 74 0 76 | 75 0 77 | 76 0 78 | 77 0 79 | 78 0 80 | 79 0 81 | 80 0 82 | 81 0 83 | 82 0 84 | 83 0 85 | 84 0 86 | 85 0 87 | 86 0 88 | 87 0 89 | 88 0 90 | 89 0 91 | 90 0 92 | 91 0 93 | 92 0 94 | 93 0 95 | 94 0 96 | 95 0 97 | 96 0 98 | 97 0 99 | 98 0 100 | 99 0 101 | 100 0 102 | 101 0 103 | 102 0 104 | 103 0 105 | 104 0 106 | 105 0 107 | 106 0 108 | 107 0 109 | 108 0 110 | 109 0 111 | 110 0 112 | 111 0 113 | 112 0 114 | 113 0 115 | 114 0 116 | 115 0 117 | 116 0 118 | 117 0 119 | 118 0 -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 3 0 0 0 0 1 1 0 135 1 1.05 0.95 3 | 2 2 21.7 12.7 0 0 1 1 0 135 1 1.1 0.95 4 | 3 1 2.4 1.2 0 0 1 1 0 135 1 1.05 0.95 5 | 4 1 7.6 1.6 0 0 1 1 0 135 1 1.05 0.95 6 | 5 1 0 0 0 0.19 1 1 0 135 1 1.05 0.95 7 | 6 1 0 0 0 0 1 1 0 135 1 1.05 0.95 8 | 7 1 22.8 10.9 0 0 1 1 0 135 1 1.05 0.95 9 | 8 1 30 30 0 0 1 1 0 135 1 1.05 0.95 10 | 9 1 0 0 0 0 1 1 0 135 1 1.05 0.95 11 | 10 1 5.8 2 0 0 3 1 0 135 1 1.05 0.95 12 | 11 1 0 0 0 0 1 1 0 135 1 1.05 0.95 13 | 12 1 11.2 7.5 0 0 2 1 0 135 1 1.05 0.95 14 | 13 2 0 0 0 0 2 1 0 135 1 1.1 0.95 15 | 14 1 6.2 1.6 0 0 2 1 0 135 1 1.05 0.95 16 | 15 1 8.2 2.5 0 0 2 1 0 135 1 1.05 0.95 17 | 16 1 3.5 1.8 0 0 2 1 0 135 1 1.05 0.95 18 | 17 1 9 5.8 0 0 2 1 0 135 1 1.05 0.95 19 | 18 1 3.2 0.9 0 0 2 1 0 135 1 1.05 0.95 20 | 19 1 9.5 3.4 0 0 2 1 0 135 1 1.05 0.95 21 | 20 1 2.2 0.7 0 0 2 1 0 135 1 1.05 0.95 22 | 21 1 17.5 11.2 0 0 3 1 0 135 1 1.05 0.95 23 | 22 2 0 0 0 0 3 1 0 135 1 1.1 0.95 24 | 23 2 3.2 1.6 0 0 2 1 0 135 1 1.1 0.95 25 | 24 1 8.7 6.7 0 0.04 3 1 0 135 1 1.05 0.95 26 | 25 1 0 0 0 0 3 1 0 135 1 1.05 0.95 27 | 26 1 3.5 2.3 0 0 3 1 0 135 1 1.05 0.95 28 | 27 2 0 0 0 0 3 1 0 135 1 1.1 0.95 29 | 28 1 0 0 0 0 1 1 0 135 1 1.05 0.95 30 | 29 1 2.4 0.9 0 0 3 1 0 135 1 1.05 0.95 31 | 30 1 10.6 1.9 0 0 3 1 0 135 1 1.05 0.95 -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/gen_sup_data.txt: -------------------------------------------------------------------------------- 1 | bus R_up R_down UT DT 2 | 1 10.0 10.0 5 5 3 | 4 10.0 10.0 5 5 4 | 6 10.0 10.0 5 5 5 | 8 10.0 10.0 5 5 6 | 10 55.0 55.0 5 5 7 | 12 18.5 18.5 5 5 8 | 15 10.0 10.0 5 5 9 | 18 10.0 10.0 5 5 10 | 19 10.0 10.0 5 5 11 | 24 10.0 10.0 5 5 12 | 25 32.0 32.0 5 5 13 | 26 41.400000000000006 41.400000000000006 5 5 14 | 27 10.0 10.0 5 5 15 | 31 10.700000000000001 10.700000000000001 5 5 16 | 32 10.0 10.0 5 5 17 | 34 10.0 10.0 5 5 18 | 36 10.0 10.0 5 5 19 | 40 10.0 10.0 5 5 20 | 42 10.0 10.0 5 5 21 | 46 11.9 11.9 5 5 22 | 49 30.400000000000002 30.400000000000002 5 5 23 | 54 14.8 14.8 5 5 24 | 55 10.0 10.0 5 5 25 | 56 10.0 10.0 5 5 26 | 59 25.5 25.5 5 5 27 | 61 26.0 26.0 5 5 28 | 62 10.0 10.0 5 5 29 | 65 49.1 49.1 5 5 30 | 66 49.2 49.2 5 5 31 | 69 80.52000000000001 80.52000000000001 5 5 32 | 70 10.0 10.0 5 5 33 | 72 10.0 10.0 5 5 34 | 73 10.0 10.0 5 5 35 | 74 10.0 10.0 5 5 36 | 76 10.0 10.0 5 5 37 | 77 10.0 10.0 5 5 38 | 80 57.7 57.7 5 5 39 | 85 10.0 10.0 5 5 40 | 87 10.4 10.4 5 5 41 | 89 70.7 70.7 5 5 42 | 90 10.0 10.0 5 5 43 | 91 10.0 10.0 5 5 44 | 92 10.0 10.0 5 5 45 | 99 10.0 10.0 5 5 46 | 100 35.2 35.2 5 5 47 | 103 14.0 14.0 5 5 48 | 104 10.0 10.0 5 5 49 | 105 10.0 10.0 5 5 50 | 107 10.0 10.0 5 5 51 | 110 10.0 10.0 5 5 52 | 111 13.600000000000001 13.600000000000001 5 5 53 | 112 10.0 10.0 5 5 54 | 113 10.0 10.0 5 5 55 | 116 10.0 10.0 5 5 56 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/raw/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.01 40 0 3 | 2 0 0 3 0.01 40 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.0222222222 20 0 7 | 2 0 0 3 0.117647059 20 0 8 | 2 0 0 3 0.01 40 0 9 | 2 0 0 3 0.01 40 0 10 | 2 0 0 3 0.01 40 0 11 | 2 0 0 3 0.01 40 0 12 | 2 0 0 3 0.0454545455 20 0 13 | 2 0 0 3 0.0318471338 20 0 14 | 2 0 0 3 0.01 40 0 15 | 2 0 0 3 1.42857143 20 0 16 | 2 0 0 3 0.01 40 0 17 | 2 0 0 3 0.01 40 0 18 | 2 0 0 3 0.01 40 0 19 | 2 0 0 3 0.01 40 0 20 | 2 0 0 3 0.01 40 0 21 | 2 0 0 3 0.526315789 20 0 22 | 2 0 0 3 0.0490196078 20 0 23 | 2 0 0 3 0.208333333 20 0 24 | 2 0 0 3 0.01 40 0 25 | 2 0 0 3 0.01 40 0 26 | 2 0 0 3 0.064516129 20 0 27 | 2 0 0 3 0.0625 20 0 28 | 2 0 0 3 0.01 40 0 29 | 2 0 0 3 0.0255754476 20 0 30 | 2 0 0 3 0.0255102041 20 0 31 | 2 0 0 3 0.0193648335 20 0 32 | 2 0 0 3 0.01 40 0 33 | 2 0 0 3 0.01 40 0 34 | 2 0 0 3 0.01 40 0 35 | 2 0 0 3 0.01 40 0 36 | 2 0 0 3 0.01 40 0 37 | 2 0 0 3 0.01 40 0 38 | 2 0 0 3 0.0209643606 20 0 39 | 2 0 0 3 0.01 40 0 40 | 2 0 0 3 2.5 20 0 41 | 2 0 0 3 0.0164744646 20 0 42 | 2 0 0 3 0.01 40 0 43 | 2 0 0 3 0.01 40 0 44 | 2 0 0 3 0.01 40 0 45 | 2 0 0 3 0.01 40 0 46 | 2 0 0 3 0.0396825397 20 0 47 | 2 0 0 3 0.25 20 0 48 | 2 0 0 3 0.01 40 0 49 | 2 0 0 3 0.01 40 0 50 | 2 0 0 3 0.01 40 0 51 | 2 0 0 3 0.01 40 0 52 | 2 0 0 3 0.277777778 20 0 53 | 2 0 0 3 0.01 40 0 54 | 2 0 0 3 0.01 40 0 55 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/gen_cost_data.txt: -------------------------------------------------------------------------------- 1 | type startup shutdown n c2 c1 c0 2 | 2 0 0 3 0.01 40 0 3 | 2 0 0 3 0.01 40 0 4 | 2 0 0 3 0.01 40 0 5 | 2 0 0 3 0.01 40 0 6 | 2 0 0 3 0.0222222222 20 0 7 | 2 0 0 3 0.117647059 20 0 8 | 2 0 0 3 0.01 40 0 9 | 2 0 0 3 0.01 40 0 10 | 2 0 0 3 0.01 40 0 11 | 2 0 0 3 0.01 40 0 12 | 2 0 0 3 0.0454545455 20 0 13 | 2 0 0 3 0.0318471338 20 0 14 | 2 0 0 3 0.01 40 0 15 | 2 0 0 3 1.42857143 20 0 16 | 2 0 0 3 0.01 40 0 17 | 2 0 0 3 0.01 40 0 18 | 2 0 0 3 0.01 40 0 19 | 2 0 0 3 0.01 40 0 20 | 2 0 0 3 0.01 40 0 21 | 2 0 0 3 0.526315789 20 0 22 | 2 0 0 3 0.0490196078 20 0 23 | 2 0 0 3 0.208333333 20 0 24 | 2 0 0 3 0.01 40 0 25 | 2 0 0 3 0.01 40 0 26 | 2 0 0 3 0.064516129 20 0 27 | 2 0 0 3 0.0625 20 0 28 | 2 0 0 3 0.01 40 0 29 | 2 0 0 3 0.0255754476 20 0 30 | 2 0 0 3 0.0255102041 20 0 31 | 2 0 0 3 0.0193648335 20 0 32 | 2 0 0 3 0.01 40 0 33 | 2 0 0 3 0.01 40 0 34 | 2 0 0 3 0.01 40 0 35 | 2 0 0 3 0.01 40 0 36 | 2 0 0 3 0.01 40 0 37 | 2 0 0 3 0.01 40 0 38 | 2 0 0 3 0.0209643606 20 0 39 | 2 0 0 3 0.01 40 0 40 | 2 0 0 3 2.5 20 0 41 | 2 0 0 3 0.0164744646 20 0 42 | 2 0 0 3 0.01 40 0 43 | 2 0 0 3 0.01 40 0 44 | 2 0 0 3 0.01 40 0 45 | 2 0 0 3 0.01 40 0 46 | 2 0 0 3 0.0396825397 20 0 47 | 2 0 0 3 0.25 20 0 48 | 2 0 0 3 0.01 40 0 49 | 2 0 0 3 0.01 40 0 50 | 2 0 0 3 0.01 40 0 51 | 2 0 0 3 0.01 40 0 52 | 2 0 0 3 0.277777778 20 0 53 | 2 0 0 3 0.01 40 0 54 | 2 0 0 3 0.01 40 0 55 | 2 0 0 3 0.01 40 0 -------------------------------------------------------------------------------- /sddip/scripts/create_supplementary.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import pandas as pd 4 | 5 | 6 | def create_supplementary_data(source_dir: Path, target_dir: Path) -> None: 7 | """Create supplementary data for the given test case.""" 8 | if not target_dir.exists(): 9 | msg = f"Path '{target_dir.resolve().absolute()}' does not exist." 10 | raise ValueError(msg) 11 | 12 | # Ramp rate 13 | # (%/100 of rated capacity per unit time) 14 | ramp_rate = 0.2 15 | # Min up/-down time 16 | 17 | # Parameter retrieval 18 | gen_file = source_dir / "gen_data.txt" 19 | supplementary_file_path = target_dir / "gen_sup_data.txt" 20 | 21 | gen_df = pd.read_csv(gen_file, delimiter=r"\s+") 22 | 23 | rated_capacities = gen_df["Pmax"].values.tolist() 24 | buses = gen_df["bus"].values.tolist() 25 | 26 | # Generate ramp rate limits 27 | r_up = [ramp_rate * p_max for p_max in rated_capacities] 28 | r_down = r_up 29 | 30 | # Generate min up-/down-time 31 | n_gens = len(rated_capacities) 32 | 33 | min_up_time = [2] * n_gens 34 | min_down_time = min_up_time 35 | 36 | # Export results 37 | supplementary_dict = { 38 | "bus": buses, 39 | "R_up": r_up, 40 | "R_down": r_down, 41 | "UT": min_up_time, 42 | "DT": min_down_time, 43 | } 44 | 45 | supplementary_df = pd.DataFrame.from_dict(supplementary_dict) 46 | 47 | supplementary_df.to_csv(supplementary_file_path, sep="\t", index=False) 48 | -------------------------------------------------------------------------------- /sessions/demo.toml: -------------------------------------------------------------------------------- 1 | title = "Test Session" 2 | 3 | [tests] 4 | 5 | # Test cases to be executed sequentially. 6 | [[tests.cases]] 7 | 8 | name = "WB5_t06_n03_sddip" 9 | path = "data/01_test_cases/WB5/t06_n03" 10 | 11 | algorithm = "sddip" # Standard SDDiP 12 | 13 | seed = 42 14 | 15 | sddip_n_binaries = 15 16 | 17 | sddip_max_iterations = 100 18 | sddip_time_limit = 300 19 | 20 | sddip_stop_stabilization_count = 1000 21 | 22 | sddip_no_improvement_tolerance = 0.00001 23 | 24 | sddip_primary_cut_type = "sb" 25 | sddip_n_samples_primary = 3 26 | sddip_secondary_cut_type = "l" 27 | sddip_n_samples_secondary = 1 28 | 29 | sddip_n_samples_final_ub = 300 30 | 31 | dual_solver_stop_tolerance = 0.00001 32 | dual_solver_time_limit = 300 33 | dual_solver_max_iterations = 5000 34 | 35 | 36 | [[tests.cases]] 37 | 38 | name = "WB5_t06_n03_dsddip" 39 | path = "data/01_test_cases/WB5/t06_n03" 40 | 41 | algorithm = "dsddip" # Dynamic SDDiP 42 | 43 | seed = 42 44 | 45 | sddip_n_binaries = 5 46 | 47 | sddip_max_iterations = 100 48 | sddip_time_limit = 300 49 | 50 | sddip_refinment_stabilization_count = 5 51 | sddip_stop_stabilization_count = 1000 52 | 53 | sddip_no_improvement_tolerance = 0.00001 54 | 55 | sddip_primary_cut_type = "sb" 56 | sddip_n_samples_primary = 3 57 | sddip_secondary_cut_type = "l" 58 | sddip_n_samples_secondary = 1 59 | 60 | sddip_projection_big_m = 10_000 61 | 62 | sddip_n_samples_final_ub = 300 63 | 64 | dual_solver_stop_tolerance = 0.00001 65 | dual_solver_time_limit = 300 66 | dual_solver_max_iterations = 5000 67 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "sddip" 3 | version = "0.1.0" 4 | description = "Stochastic Dual Dynamic Integer Programming" 5 | authors = ["Leo Schleier <43878374+leoschleier@users.noreply.github.com>"] 6 | license = "MIT" 7 | readme = "docs/README.md" 8 | keywords = ["sddip"] 9 | homepage = "https://github.com/leoschleier/sddip" 10 | # See: https://pypi.org/classifiers/ 11 | classifiers = [ 12 | "Programming Language :: Python :: 3.12", 13 | ] 14 | 15 | [tool.poetry.dependencies] 16 | python = "~3.12" 17 | pandas = "^2.2.3" 18 | gurobipy = "^12.0.0" 19 | scipy = "^1.14.1" 20 | matplotlib = "^3.10.0" 21 | numpy = "^2.2.1" 22 | 23 | [tool.poetry.group.dev.dependencies] 24 | ruff = "^0.7.4" 25 | pyright = "^1.1.391" 26 | pytest = "^8.3.4" 27 | 28 | [build-system] 29 | requires = ["poetry-core"] 30 | build-backend = "poetry.core.masonry.api" 31 | 32 | [tool.pyright] 33 | venvPath = "." 34 | venv = ".venv" 35 | typeCheckingMode = "basic" 36 | pythonVersion = "3.12" 37 | 38 | [tool.ruff] 39 | line-length = 79 40 | target-version = "py312" 41 | 42 | [tool.ruff.lint] 43 | select = ["ALL"] 44 | ignore = [ 45 | "ANN401", # Use of typing.Any 46 | "COM812", # Missing trailing comma (formatter) 47 | "ISC001", # Single line implicit string concatenation (formatter) 48 | ] 49 | fixable = ["ALL"] 50 | 51 | [tool.ruff.lint.per-file-ignores] 52 | "__init__.py" = ["E401"] # Unused import 53 | "tests/*" = ["S101"] # Use of assert detected 54 | 55 | [tool.ruff.lint.pycodestyle] 56 | max-doc-length = 72 57 | 58 | [tool.ruff.lint.pydocstyle] 59 | convention = "google" 60 | 61 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n03/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd5 Pd2 Pd3 Pd4 Re1 Re2 Re3 Re4 Re5 2 | 1 1 1.0 0 0 98.85665966829141 109.36003492597482 48.136511200501126 0 0 0 0 0 3 | 2 1 0.3333333333333333 0 0 144.2264946095125 146.7655922529687 70.08106642425822 0 0 0 0 0 4 | 2 2 0.3333333333333333 0 0 165.60649735311353 152.1643750783422 63.36493899377336 0 0 0 0 0 5 | 2 3 0.3333333333333333 0 0 132.17883177318396 153.44223441210667 81.08356971140546 0 0 0 0 0 6 | 3 1 0.3333333333333333 0 0 270.3956850096598 204.36239561880845 132.70046494443548 0 0 0 0 0 7 | 3 2 0.3333333333333333 0 0 201.6729501085769 241.12943289363707 116.06569463699488 0 0 0 0 0 8 | 3 3 0.3333333333333333 0 0 202.33228555562118 274.0240626430948 138.17143750948355 0 0 0 0 0 9 | 4 1 0.3333333333333333 0 0 242.0884854586224 206.8755868153022 112.03817769789111 0 0 0 0 0 10 | 4 2 0.3333333333333333 0 0 232.92006931103745 216.62424493936567 135.58569387654785 0 0 0 0 0 11 | 4 3 0.3333333333333333 0 0 270.8987058837072 213.35323694131714 135.77957454504119 0 0 0 0 0 12 | 5 1 0.3333333333333333 0 0 232.73829655108332 237.38123709866568 133.05438988883472 0 0 0 0 0 13 | 5 2 0.3333333333333333 0 0 259.2479048960274 199.6378393092971 101.27028425003873 0 0 0 0 0 14 | 5 3 0.3333333333333333 0 0 273.488472169884 214.7490977508724 99.10312801112292 0 0 0 0 0 15 | 6 1 0.3333333333333333 0 0 261.45599379630244 223.33306021630875 97.78334785610276 0 0 0 0 0 16 | 6 2 0.3333333333333333 0 0 260.9613682239832 236.69834035089463 131.05564680736188 0 0 0 0 0 17 | 6 3 0.3333333333333333 0 0 221.69071037899843 271.068143037648 118.66757394652363 0 0 0 0 0 18 | -------------------------------------------------------------------------------- /sddip/sddip/storage.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pandas as pd 4 | 5 | 6 | class ResultStorage: 7 | def __init__( 8 | self, result_keys: list | None = None, label="results" 9 | ) -> None: 10 | if result_keys is None: 11 | result_keys = [] 12 | self.result_keys = result_keys 13 | self.label = label 14 | self.index_names = ("i", "k", "t") 15 | self.results = {} 16 | 17 | def add_result( 18 | self, 19 | iteration_index: int, 20 | sample_index: int, 21 | stage_index: int, 22 | results: dict, 23 | ) -> None: 24 | self.results[iteration_index, sample_index, stage_index] = results 25 | 26 | def get_result( 27 | self, iteration_index: int, sample_index: int, stage_index: int 28 | ): 29 | return self.results[iteration_index, sample_index, stage_index] 30 | 31 | def get_stage_result(self, stage_index: int): 32 | df = self.to_dataframe() 33 | return df.query("t == %i" % (stage_index)).to_dict("list") 34 | 35 | def get_iteration_result(self, iteration: int): 36 | df = self.to_dataframe() 37 | return df.query("i == %i" % (iteration)).to_dict("list") 38 | 39 | def to_dataframe(self): 40 | """Create a pandas DataFrame from the results dictionary.""" 41 | if self.results: 42 | results = self.results 43 | else: 44 | results = {("n/a", "n/a", "n/a"): {"n/a": "n/a"}} 45 | 46 | df = pd.DataFrame.from_dict(results, orient="index") 47 | return df.rename_axis(self.index_names) 48 | 49 | def create_empty_result_dict(self): 50 | return {key: [] for key in self.result_keys} 51 | 52 | def export_results(self, results_dir: str) -> None: 53 | df = self.to_dataframe() 54 | df.to_csv(os.path.join(results_dir, f"{self.label}.csv"), sep="\t") 55 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n03/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd2 Pd3 Pd4 Pd5 Pd6 Re1 Re3 Re4 Re5 Re6 Re2 2 | 1 1 1.0 0 0 0 22.99145519886469 32.48157316431194 25.874318815597317 0 0 0 0 0 22.388171834306302 3 | 2 1 0.3333333333333333 0 0 0 45.76954856204125 44.94003981129214 38.66807718582738 0 0 0 0 0 47.59360959722311 4 | 2 2 0.3333333333333333 0 0 0 45.24213367535734 47.82458815400166 35.4816241814413 0 0 0 0 0 57.212966321103174 5 | 2 3 0.3333333333333333 0 0 0 33.65834069676555 34.62924364781376 41.99947785861773 0 0 0 0 0 57.52100754496913 6 | 3 1 0.3333333333333333 0 0 0 62.44026329597218 68.1753092409239 60.24054965583056 0 0 0 0 0 32.3664195648413 7 | 3 2 0.3333333333333333 0 0 0 65.01711059241624 78.54254527372757 62.28013919773277 0 0 0 0 0 30.914265414606653 8 | 3 3 0.3333333333333333 0 0 0 71.62234215528976 72.41675437059996 74.19007937857481 0 0 0 0 0 27.930306173284198 9 | 4 1 0.3333333333333333 0 0 0 71.68725011225607 65.84721123738134 59.58532948556861 0 0 0 0 0 40.453271101826566 10 | 4 2 0.3333333333333333 0 0 0 78.14707456545355 56.3689399818402 61.80607548860647 0 0 0 0 0 46.34273519958623 11 | 4 3 0.3333333333333333 0 0 0 75.86825119881098 70.36705728969547 63.2494853012438 0 0 0 0 0 49.52660993460082 12 | 5 1 0.3333333333333333 0 0 0 57.98711736079076 52.94010087049153 69.71086067726885 0 0 0 0 0 55.94005227192003 13 | 5 2 0.3333333333333333 0 0 0 69.0429142654195 67.01362809243876 71.96734823280664 0 0 0 0 0 58.71497641733796 14 | 5 3 0.3333333333333333 0 0 0 53.000349526539964 65.05577258558894 76.30194972988909 0 0 0 0 0 71.38279708214742 15 | 6 1 0.3333333333333333 0 0 0 63.58476442677674 81.90703457204873 68.39971622745969 0 0 0 0 0 64.34840435821242 16 | 6 2 0.3333333333333333 0 0 0 57.60724955980449 66.7902682468828 67.85136122696332 0 0 0 0 0 51.898065763385 17 | 6 3 0.3333333333333333 0 0 0 57.13288125487718 72.57280147773395 70.44945147298132 0 0 0 0 0 71.11015175186589 18 | -------------------------------------------------------------------------------- /data/01_test_cases/supplementary/load_profiles/h0_summer_workday.txt: -------------------------------------------------------------------------------- 1 | time h0 2 | 00:15:00 86.3 3 | 00:30:00 76.9 4 | 00:45:00 68.8 5 | 01:00:00 62.4 6 | 01:15:00 58 7 | 01:30:00 55.3 8 | 01:45:00 53.6 9 | 02:00:00 52.4 10 | 02:15:00 51.3 11 | 02:30:00 50.3 12 | 02:45:00 49.2 13 | 03:00:00 48.3 14 | 03:15:00 47.5 15 | 03:30:00 46.9 16 | 03:45:00 46.5 17 | 04:00:00 46.6 18 | 04:15:00 47.1 19 | 04:30:00 48 20 | 04:45:00 49.3 21 | 05:00:00 50.8 22 | 05:15:00 52.7 23 | 05:30:00 55.6 24 | 05:45:00 60.5 25 | 06:00:00 68.2 26 | 06:15:00 79.2 27 | 06:30:00 92 28 | 06:45:00 104.7 29 | 07:00:00 115.7 30 | 07:15:00 123.5 31 | 07:30:00 128.6 32 | 07:45:00 132 33 | 08:00:00 134.8 34 | 08:15:00 137.8 35 | 08:30:00 140.7 36 | 08:45:00 143.2 37 | 09:00:00 144.8 38 | 09:15:00 145.3 39 | 09:30:00 144.9 40 | 09:45:00 143.8 41 | 10:00:00 142.3 42 | 10:15:00 140.8 43 | 10:30:00 139.5 44 | 10:45:00 138.5 45 | 11:00:00 138.2 46 | 11:15:00 138.6 47 | 11:30:00 140.1 48 | 11:45:00 142.6 49 | 12:00:00 146.5 50 | 12:15:00 151.5 51 | 12:30:00 156.7 52 | 12:45:00 160.7 53 | 13:00:00 162.3 54 | 13:15:00 160.5 55 | 13:30:00 156.1 56 | 13:45:00 150.2 57 | 14:00:00 144 58 | 14:15:00 138.4 59 | 14:30:00 133.6 60 | 14:45:00 129.4 61 | 15:00:00 125.7 62 | 15:15:00 122.4 63 | 15:30:00 119.6 64 | 15:45:00 117.4 65 | 16:00:00 115.7 66 | 16:15:00 114.6 67 | 16:30:00 114.2 68 | 16:45:00 114.6 69 | 17:00:00 115.7 70 | 17:15:00 117.6 71 | 17:30:00 120.3 72 | 17:45:00 123.9 73 | 18:00:00 128.2 74 | 18:15:00 133.2 75 | 18:30:00 138.9 76 | 18:45:00 145.1 77 | 19:00:00 151.5 78 | 19:15:00 157.9 79 | 19:30:00 163.8 80 | 19:45:00 168.3 81 | 20:00:00 170.6 82 | 20:15:00 170.4 83 | 20:30:00 168.3 84 | 20:45:00 165.3 85 | 21:00:00 162.3 86 | 21:15:00 160.1 87 | 21:30:00 158.4 88 | 21:45:00 156.8 89 | 22:00:00 154.8 90 | 22:15:00 151.9 91 | 22:30:00 147.9 92 | 22:45:00 142.5 93 | 23:00:00 135.7 94 | 23:15:00 127.2 95 | 23:30:00 117.5 96 | 23:45:00 107.1 97 | 00:00:00 96.5 98 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/raw/branch_data.txt: -------------------------------------------------------------------------------- 1 | fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 2 | 1 2 0.02 0.06 0.03 130 130 130 0 0 1 -360 360 3 | 1 3 0.05 0.19 0.02 130 130 130 0 0 1 -360 360 4 | 2 4 0.06 0.17 0.02 65 65 65 0 0 1 -360 360 5 | 3 4 0.01 0.04 0 130 130 130 0 0 1 -360 360 6 | 2 5 0.05 0.2 0.02 130 130 130 0 0 1 -360 360 7 | 2 6 0.06 0.18 0.02 65 65 65 0 0 1 -360 360 8 | 4 6 0.01 0.04 0 90 90 90 0 0 1 -360 360 9 | 5 7 0.05 0.12 0.01 70 70 70 0 0 1 -360 360 10 | 6 7 0.03 0.08 0.01 130 130 130 0 0 1 -360 360 11 | 6 8 0.01 0.04 0 32 32 32 0 0 1 -360 360 12 | 6 9 0 0.21 0 65 65 65 0 0 1 -360 360 13 | 6 10 0 0.56 0 32 32 32 0 0 1 -360 360 14 | 9 11 0 0.21 0 65 65 65 0 0 1 -360 360 15 | 9 10 0 0.11 0 65 65 65 0 0 1 -360 360 16 | 4 12 0 0.26 0 65 65 65 0 0 1 -360 360 17 | 12 13 0 0.14 0 65 65 65 0 0 1 -360 360 18 | 12 14 0.12 0.26 0 32 32 32 0 0 1 -360 360 19 | 12 15 0.07 0.13 0 32 32 32 0 0 1 -360 360 20 | 12 16 0.09 0.2 0 32 32 32 0 0 1 -360 360 21 | 14 15 0.22 0.2 0 16 16 16 0 0 1 -360 360 22 | 16 17 0.08 0.19 0 16 16 16 0 0 1 -360 360 23 | 15 18 0.11 0.22 0 16 16 16 0 0 1 -360 360 24 | 18 19 0.06 0.13 0 16 16 16 0 0 1 -360 360 25 | 19 20 0.03 0.07 0 32 32 32 0 0 1 -360 360 26 | 10 20 0.09 0.21 0 32 32 32 0 0 1 -360 360 27 | 10 17 0.03 0.08 0 32 32 32 0 0 1 -360 360 28 | 10 21 0.03 0.07 0 32 32 32 0 0 1 -360 360 29 | 10 22 0.07 0.15 0 32 32 32 0 0 1 -360 360 30 | 21 22 0.01 0.02 0 32 32 32 0 0 1 -360 360 31 | 15 23 0.1 0.2 0 16 16 16 0 0 1 -360 360 32 | 22 24 0.12 0.18 0 16 16 16 0 0 1 -360 360 33 | 23 24 0.13 0.27 0 16 16 16 0 0 1 -360 360 34 | 24 25 0.19 0.33 0 16 16 16 0 0 1 -360 360 35 | 25 26 0.25 0.38 0 16 16 16 0 0 1 -360 360 36 | 25 27 0.11 0.21 0 16 16 16 0 0 1 -360 360 37 | 28 27 0 0.4 0 65 65 65 0 0 1 -360 360 38 | 27 29 0.22 0.42 0 16 16 16 0 0 1 -360 360 39 | 27 30 0.32 0.6 0 16 16 16 0 0 1 -360 360 40 | 29 30 0.24 0.45 0 16 16 16 0 0 1 -360 360 41 | 8 28 0.06 0.2 0.02 32 32 32 0 0 1 -360 360 42 | 6 28 0.02 0.06 0.01 32 32 32 0 0 1 -360 360 -------------------------------------------------------------------------------- /data/01_test_cases/WB5/info/WB5.m: -------------------------------------------------------------------------------- 1 | function mpc = WB5 2 | %% 5 bus case in MATPOWER format 3 | % W. A. Bukhsh, Feb 2013 4 | %% References: 5 | % [1] W. A. Bukhsh, Andreas Grothey, Ken McKinnon, Paul trodden, "Local Solutions of Optimal Power Flow Problem" 6 | % submitted to IEEE Transactions on Power Systems, 2013 7 | % [2] W. A. Bukhsh, Andreas Grothey, Ken McKinnon, Paul trodden, "Local Solutions of Optimal Power Flow Problem" 8 | % Technical Report ERGO, 2011 9 | %% MATPOWER Case Format : Version 2 10 | mpc.version = '2'; 11 | 12 | %%----- Power Flow Data -----%% 13 | %% system MVA base 14 | mpc.baseMVA = 100; 15 | 16 | %% bus data 17 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 18 | mpc.bus = [ 19 | 1 3 0 0 0 0 1 1.0 0 345 1 1.05 0.95; 20 | 2 1 130 20 0 0 1 1.0 -10 345 1 1.05 0.95; 21 | 3 1 130 20 0 0 1 1.0 -20 345 1 1.05 0.95; 22 | 4 1 65 10 0 0 1 1.0 -135 345 1 1.05 0.95; 23 | 5 2 0 0 0 0 1 1.0 -140 345 1 1.05 0.95; 24 | 25 | ]; 26 | %% generator data 27 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 28 | mpc.gen = [ 29 | 1 500 50 1800 -30 1 100 1 5000 0 0 0 0 0 0 0 0 0 0 0 0; 30 | 5 0 0 1800 -30 1 100 1 5000 0 0 0 0 0 0 0 0 0 0 0 0; 31 | 32 | 33 | ]; 34 | 35 | %% branch data 36 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 37 | mpc.branch = [ 38 | 1 2 0.04 0.09 0.0 2500 2500 2500 0 0 1 -360 360; 39 | 1 3 0.05 0.10 0.0 2500 2500 2500 0 0 1 -360 360; 40 | 2 4 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360; 41 | 3 5 0.55 0.90 0.45 2500 2500 2500 0 0 1 -360 360; 42 | 4 5 0.06 0.1 0.0 2500 2500 2500 0 0 1 -360 360; 43 | 2 3 0.07 0.09 0.0 2500 2500 2500 0 0 1 -360 360; 44 | 45 | ]; 46 | 47 | %%----- OPF Data -----%% 48 | %% area data 49 | % area refbus 50 | mpc.areas = [ 51 | 1 5; 52 | ]; 53 | 54 | %% generator cost data 55 | % 1 startup shutdown n x1 y1 ... xn yn 56 | % 2 startup shutdown n c(n-1) ... c0 57 | mpc.gencost = [ 58 | 2 2 0 3 0 4.00 0; 59 | 2 2 0 3 0 1.00 0; 60 | 61 | ]; 62 | -------------------------------------------------------------------------------- /sddip/sddip/sddip_logging.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | from datetime import datetime 4 | from time import time 5 | 6 | import gurobipy as gp 7 | 8 | from sddip import config 9 | 10 | 11 | class LogManager: 12 | def __init__(self) -> None: 13 | pass 14 | 15 | def create_log_dir(self, dir_label: str) -> str: 16 | now_str = datetime.today().strftime("%Y%m%d%H%M%S") 17 | dir_name = f"{dir_label}_{now_str}" 18 | log_dir = config.RESULTS_DIR / dir_name 19 | os.makedirs(log_dir) 20 | 21 | return log_dir 22 | 23 | def create_subdirectory(self, dir_name: str, sub_dir_name: str) -> None: 24 | dir_to_create = dir_name / sub_dir_name 25 | os.makedirs(dir_to_create) 26 | 27 | 28 | class RuntimeLogger: 29 | def __init__(self, log_dir: str, tag: str = "") -> None: 30 | if tag: 31 | tag = f"_{tag}" 32 | self.runtime_file_path = os.path.join(log_dir, f"runtime{tag}.json") 33 | self.runtime_dict = {} 34 | self.global_start_time = None 35 | 36 | def start(self) -> None: 37 | self.global_start_time = time() 38 | 39 | def log_task_end(self, task_name: str, task_start_time: float) -> None: 40 | task_runtime = time() - task_start_time 41 | self.runtime_dict.update({task_name: task_runtime}) 42 | 43 | def log_experiment_end(self) -> None: 44 | self.log_task_end("global_runtime", self.global_start_time) 45 | json.dump( 46 | self.runtime_dict, open(self.runtime_file_path, "w"), indent=4 47 | ) 48 | 49 | 50 | class GurobiLogger: 51 | def __init__(self, log_dir: str) -> None: 52 | self.gurobi_log_dir = os.path.join(log_dir, "gurobi") 53 | os.makedirs(self.gurobi_log_dir) 54 | 55 | def log_model(self, model: gp.Model, label: str) -> None: 56 | model_file_path = os.path.join( 57 | self.gurobi_log_dir, f"{label}_model.lp" 58 | ) 59 | solution_file_path = os.path.join( 60 | self.gurobi_log_dir, f"{label}_model.sol" 61 | ) 62 | 63 | model.write(model_file_path) 64 | model.write(solution_file_path) 65 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/info/case6ww.m: -------------------------------------------------------------------------------- 1 | function mpc = case6ww 2 | %CASE6WW Power flow data for 6 bus, 3 gen case from Wood & Wollenberg. 3 | % Please see CASEFORMAT for details on the case file format. 4 | % 5 | % This is the 6 bus example from pp. 104, 112, 119, 123-124, 549 of 6 | % "Power Generation, Operation, and Control, 2nd Edition", 7 | % by Allen. J. Wood and Bruce F. Wollenberg, John Wiley & Sons, NY, Jan 1996. 8 | 9 | % MATPOWER 10 | 11 | %% MATPOWER Case Format : Version 2 12 | mpc.version = '2'; 13 | 14 | %%----- Power Flow Data -----%% 15 | %% system MVA base 16 | mpc.baseMVA = 100; 17 | 18 | %% bus data 19 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 20 | mpc.bus = [ 21 | 1 3 0 0 0 0 1 1.05 0 230 1 1.05 1.05; 22 | 2 2 0 0 0 0 1 1.05 0 230 1 1.05 1.05; 23 | 3 2 0 0 0 0 1 1.07 0 230 1 1.07 1.07; 24 | 4 1 70 70 0 0 1 1 0 230 1 1.05 0.95; 25 | 5 1 70 70 0 0 1 1 0 230 1 1.05 0.95; 26 | 6 1 70 70 0 0 1 1 0 230 1 1.05 0.95; 27 | ]; 28 | 29 | %% generator data 30 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 31 | mpc.gen = [ 32 | 1 0 0 100 -100 1.05 100 1 200 50 0 0 0 0 0 0 0 0 0 0 0; 33 | 2 50 0 100 -100 1.05 100 1 150 37.5 0 0 0 0 0 0 0 0 0 0 0; 34 | 3 60 0 100 -100 1.07 100 1 180 45 0 0 0 0 0 0 0 0 0 0 0; 35 | ]; 36 | 37 | %% branch data 38 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 39 | mpc.branch = [ 40 | 1 2 0.1 0.2 0.04 40 40 40 0 0 1 -360 360; 41 | 1 4 0.05 0.2 0.04 60 60 60 0 0 1 -360 360; 42 | 1 5 0.08 0.3 0.06 40 40 40 0 0 1 -360 360; 43 | 2 3 0.05 0.25 0.06 40 40 40 0 0 1 -360 360; 44 | 2 4 0.05 0.1 0.02 60 60 60 0 0 1 -360 360; 45 | 2 5 0.1 0.3 0.04 30 30 30 0 0 1 -360 360; 46 | 2 6 0.07 0.2 0.05 90 90 90 0 0 1 -360 360; 47 | 3 5 0.12 0.26 0.05 70 70 70 0 0 1 -360 360; 48 | 3 6 0.02 0.1 0.02 80 80 80 0 0 1 -360 360; 49 | 4 5 0.2 0.4 0.08 20 20 20 0 0 1 -360 360; 50 | 5 6 0.1 0.3 0.06 40 40 40 0 0 1 -360 360; 51 | ]; 52 | 53 | %%----- OPF Data -----%% 54 | %% generator cost data 55 | % 1 startup shutdown n x1 y1 ... xn yn 56 | % 2 startup shutdown n c(n-1) ... c0 57 | mpc.gencost = [ 58 | 2 0 0 3 0.00533 11.669 213.1; 59 | 2 0 0 3 0.00889 10.333 200; 60 | 2 0 0 3 0.00741 10.833 240; 61 | ]; 62 | -------------------------------------------------------------------------------- /sddip/scripts/gather_latest_results.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | from collections.abc import Iterable 3 | from pathlib import Path 4 | 5 | from sddip import config 6 | 7 | 8 | def main() -> None: 9 | n = 1 10 | 11 | log_files = config.LOGS_DIR.glob("*.txt") 12 | runtime_log_dirs = config.LOGS_DIR.glob("./log_*") 13 | bm_logs_dirs = config.LOGS_DIR.glob("./BM_log_*") 14 | results_dirs = config.RESULTS_DIR.glob("./results_*") 15 | 16 | latest_log_files = get_last(n, log_files) 17 | latest_runtime_log_dirs = get_last(n, runtime_log_dirs) 18 | latest_bm_log_dirs = get_last(n, bm_logs_dirs) 19 | latest_results_dirs = get_last(n, results_dirs) 20 | 21 | working_dir = Path.cwd() 22 | temp_dir = working_dir / "temp" 23 | 24 | for log, rt, bm, res in zip( 25 | latest_log_files, 26 | latest_runtime_log_dirs, 27 | latest_bm_log_dirs, 28 | latest_results_dirs, 29 | strict=False, 30 | ): 31 | test_case, stages, realizations = get_test_case_info(log) 32 | target_dir = temp_dir / test_case / f"t{stages}_n{realizations}" 33 | target_dir.mkdir(parents=True, exist_ok=True) 34 | shutil.copyfile(log, target_dir / "logs.txt") 35 | shutil.copytree(rt, target_dir / "runtime", dirs_exist_ok=True) 36 | shutil.copytree(bm, target_dir / "bundle_method", dirs_exist_ok=True) 37 | shutil.copytree(res, target_dir / "results", dirs_exist_ok=True) 38 | 39 | 40 | def get_last(n: int, l: Iterable) -> list: 41 | last_n = list(l)[-n:] 42 | if type(last_n) == list: 43 | return last_n 44 | return [last_n] 45 | 46 | 47 | def get_test_case_info(log_file: Path): 48 | with open(log_file, encoding="utf-8") as file: 49 | content = file.read() 50 | for line in content.split("\n"): 51 | if "Test case:" in line: 52 | run_info = line.split(": ")[-1].split(",") 53 | test_case = run_info[0] 54 | stages = run_info[1].split("=")[-1] 55 | realizations = run_info[2].split("=")[-1] 56 | 57 | return test_case, stages, realizations 58 | 59 | msg = "No test case info found." 60 | raise ValueError(msg) 61 | 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | # Result data 132 | data/02_results/* 133 | data/03_logs/* 134 | 135 | # VSCode 136 | .vscode 137 | 138 | # Gurobi files 139 | *.lp 140 | *.ilp 141 | 142 | # Temp directory 143 | temp/ 144 | 145 | # Session files 146 | sessions/* 147 | !sessions/demo.toml 148 | 149 | 150 | -------------------------------------------------------------------------------- /sddip/scripts/create_scenarios.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import pandas as pd 4 | 5 | from sddip.sddip import scenarios 6 | 7 | 8 | def create_scenario_data( 9 | t: int, n: int, test_case_dir: Path, base_case_dir: Path | None = None 10 | ) -> None: 11 | """Create scenario data for the given test case. 12 | 13 | Args: 14 | t: The number of stages. 15 | n: The number of scenarios. 16 | test_case_dir: The path to the test case directory. 17 | base_case_dir: The path to the base case directory. 18 | 19 | """ 20 | base_case_dir = base_case_dir or test_case_dir 21 | 22 | bus_file_path = base_case_dir / "bus_data.txt" 23 | renewables_file_path = base_case_dir / "ren_data.txt" 24 | 25 | for f in [bus_file_path, renewables_file_path]: 26 | if not f.exists(): 27 | msg = f"Path '{f.resolve().absolute()}' does not exist." 28 | raise ValueError(msg) 29 | 30 | test_case_dir.mkdir(exist_ok=True, parents=True) 31 | 32 | scenario_file_path = test_case_dir / "scenario_data.txt" 33 | 34 | bus_df = pd.read_csv(bus_file_path, delimiter=r"\s+") 35 | renewables_df = pd.read_csv(renewables_file_path, delimiter=r"\s+") 36 | 37 | demands = bus_df["Pd"].values.tolist() 38 | 39 | re_max_frac = renewables_df["max_frac"].values.tolist() 40 | 41 | n_buses = len(demands) 42 | 43 | demand_buses = [b for b in range(n_buses) if demands[b] != 0] 44 | 45 | max_demand_value_targets = [2 * d for d in demands if d != 0] 46 | 47 | renewables_buses = [b for b in range(n_buses) if re_max_frac[b] != 0] 48 | 49 | # Generate scenarios 50 | sc_generator = scenarios.ScenarioGenerator(t, n) 51 | 52 | # Demand scenarios 53 | demand_scenario_df = sc_generator.generate_demand_scenario_dataframe( 54 | n_buses, demand_buses, max_demand_value_targets, 0.2 55 | ) 56 | 57 | # Renewables scenarios 58 | min_values = [0] * len(renewables_buses) 59 | max_values = [frac * sum(demands) for frac in re_max_frac if frac != 0] 60 | start_values = [0.1 * m for m in max_values] 61 | step_sizes = [1 / 3 * m for m in max_values] 62 | 63 | renewables_scenario_df = ( 64 | sc_generator.generate_renewables_scenario_dataframe( 65 | n_buses, 66 | renewables_buses, 67 | start_values, 68 | step_sizes, 69 | min_values, 70 | max_values, 71 | 0.3, 72 | 0.2, 73 | ) 74 | ) 75 | renewables_scenario_df = renewables_scenario_df.drop( 76 | ["t", "n", "p"], axis=1 77 | ) 78 | 79 | scenario_df = pd.concat( 80 | [demand_scenario_df, renewables_scenario_df], axis=1 81 | ) 82 | 83 | scenario_df.to_csv(scenario_file_path, sep="\t", index=False) 84 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t06_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd5 Pd2 Pd3 Pd4 Re1 Re2 Re3 Re4 Re5 2 | 1 1 1.0 0 0 103.82292154804423 92.465093065287 40.98671051865462 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 173.30338505547206 151.3188333928056 62.265830669020424 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 120.91132384889318 132.72198505935057 77.8994657900224 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 137.82011105636929 117.96383558702408 76.15254232454089 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 169.88464984979572 126.92898119120525 66.97964721455135 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 146.74224834104717 153.41969214782716 81.79577389131661 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 161.1169812313035 160.17107342685676 69.72455773310544 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 218.86365553618666 203.17545106204733 104.74647829193256 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 209.40787985338181 232.5265455276203 94.5698802242145 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 213.00455842344982 256.9333234424617 122.37879943931064 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 282.3307153460509 247.03724603877637 105.87315728102915 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 276.8625262150073 206.27570962162082 115.98214961619945 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 282.7406556707489 205.62375370355204 132.0943345603722 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 252.98137429847722 203.77434718703074 102.65574726972476 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 271.23466434291237 242.42878021443295 114.62859926102172 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 194.74211243366582 236.89106632596165 129.62458607196123 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 272.81159812757403 264.31286316593344 95.01192661085386 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 270.0259590697359 230.92025644960734 104.59761971134026 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 274.2403716236139 235.92305948697967 110.47055902631227 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 211.04401826202076 276.5371162936009 98.03345907010204 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 212.77899186443005 198.334477201985 112.641242186838 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 223.4125839633948 192.5417816932575 93.5485025241599 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 251.90244024261804 243.96682938731055 115.67566636571934 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 243.94330909543882 256.4701638987341 129.2087274659483 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 270.58658884819107 213.96272214514266 94.3963363538048 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 248.3327506110181 285.4495293588319 123.5214980937824 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 257.191513707333 290.8539469706457 102.32392121055986 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 222.84332001639964 238.95485638879265 135.78910993703954 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 266.1957808338832 216.73594622035148 136.4456530413995 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 244.30195075695897 256.0138114221812 127.23242198021336 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 263.1938694762698 287.6903931915226 137.5565707757686 0 0 0 0 0 33 | -------------------------------------------------------------------------------- /sddip/sddip/tree.py: -------------------------------------------------------------------------------- 1 | class Node: 2 | def __init__( 3 | self, stage: int, index: int, realization: int, parent: "Node" = None 4 | ) -> None: 5 | self.stage = stage 6 | self.index = index 7 | self.realization = realization 8 | self.parent = parent 9 | self.children = [] 10 | 11 | def set_children(self, children: list) -> None: 12 | self.children = children 13 | 14 | def get_ancestors(self, horizon: int | None = None): 15 | n_ancestors = horizon if horizon else self.stage 16 | ancestors = [] 17 | 18 | current_node = self 19 | for _ in range(n_ancestors): 20 | current_node = current_node.parent 21 | ancestors.append(current_node) 22 | 23 | return ancestors 24 | 25 | 26 | class ScenarioTree: 27 | def __init__(self, n_realizations_per_stage: list[int]) -> None: 28 | self.n_stages = len(n_realizations_per_stage) 29 | self.n_nodes_per_stage = [1] 30 | self.root = Node(0, 0, 0) 31 | self.nodes = [[self.root]] 32 | self._build_tree(n_realizations_per_stage) 33 | 34 | def _build_tree(self, n_realizations_per_stage: list[int]) -> None: 35 | for t in range(1, self.n_stages): 36 | node_index = 0 37 | stage_nodes = [] 38 | for n in self.nodes[t - 1]: 39 | children = [] 40 | for r in range(n_realizations_per_stage[t]): 41 | children.append(Node(t, node_index, r, n)) 42 | node_index += 1 43 | n.set_children(children) 44 | stage_nodes += children 45 | self.nodes.append(stage_nodes) 46 | 47 | self.n_nodes_per_stage = [len(s) for s in self.nodes] 48 | 49 | def __str__(self) -> str: 50 | total_number_of_nodes = sum(self.n_nodes_per_stage) 51 | return f"ScenarioTree: Stages = {self.n_stages}, Nodes = {total_number_of_nodes}" 52 | 53 | def get_node(self, stage, index): 54 | return self.nodes[stage][index] 55 | 56 | def get_stage_nodes(self, stage): 57 | return self.nodes[stage] 58 | 59 | 60 | class Stage: 61 | def __init__(self, stage_num, n_nodes, params=None) -> None: 62 | self.stage_num = stage_num 63 | self.nodes = [Node(i, self.stage_num) for i in range(n_nodes)] 64 | self.cut_gradients = [] 65 | self.cut_intercepts = [] 66 | 67 | def __iter__(self): 68 | return IterableWrapper(self.nodes) 69 | 70 | def __reversed__(self): 71 | return IterableWrapper(self.nodes, True) 72 | 73 | def get_node(self, node_num: int): 74 | return self.nodes[node_num] 75 | 76 | 77 | class IterableWrapper: 78 | def __init__(self, iterable, reversed=False) -> None: 79 | self.iterable = iterable 80 | self.reversed = reversed 81 | self.index = -1 if reversed else 0 82 | 83 | def __next__(self): 84 | try: 85 | result = self.iterable[self.index] 86 | except IndexError: 87 | raise StopIteration 88 | self.index += -1 if self.reversed else +1 89 | return result 90 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t06_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd2 Pd3 Pd4 Pd5 Pd6 Re1 Re2 Re3 Re4 Re5 Re6 2 | 1 1 1.0 0 0 0 58.549929101295675 46.40009246939782 46.56239665689433 0 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 0 70.52128149298582 61.61602662132391 62.89640803854442 0 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 0 88.67186779979642 70.52591838467836 82.2493733324893 0 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 0 86.70959310348596 73.06464675818867 63.92230971439664 0 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 0 67.56222300892863 64.71158629398984 88.22894166288953 0 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 0 87.54774466674199 88.82935685955671 69.23387211918812 0 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 0 89.88009189599516 82.21026644753638 66.17186939678587 0 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 0 134.78092964759307 114.18668012552428 116.23642763897058 0 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 0 116.63393285930529 142.8726696289783 120.75495463046553 0 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 0 104.5909431822741 142.07346291845735 111.56364918451237 0 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 0 103.37056220654065 123.70764637970417 134.75703538119723 0 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 0 129.46540030317732 151.44834669505926 106.8022258470257 0 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 0 139.49825721925453 136.15297452019936 149.20324593979348 0 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 0 137.39836993565325 127.4231547143699 108.15934889860942 0 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 0 135.28383449247235 119.20130434241639 135.128741218793 0 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 0 107.29138008856337 146.95017361355679 131.1380894073377 0 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 0 143.34472098729947 106.3384957937984 148.7385075673344 0 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 0 119.77604088079279 109.90441342485579 139.50693905369073 0 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 0 124.16490359223029 101.63390170389927 127.49651841506318 0 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 0 105.01339594825458 118.12591012121524 115.45816965147081 0 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 0 110.95057145499378 131.60357136634883 101.71860241637853 0 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 0 112.11577681132839 124.35766269103199 98.0823571115248 0 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 0 110.65580798193639 101.20985757799284 132.45017676507095 0 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 0 99.96212664188715 127.24832601102693 104.8955421644207 0 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 0 121.9023268322392 126.84140613523867 136.9555284780522 0 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 0 147.9392057978251 155.1347498149402 131.2798094594545 0 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 0 114.43431836799076 124.15306840616334 150.37615724862425 0 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 0 122.41924671348531 117.23627097991634 132.12946043124563 0 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 0 131.99354994615607 144.42660371215484 134.73891520605576 0 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 0 147.1663897281942 145.98846016569695 153.20826850058683 0 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 0 136.84387134798177 117.99656485045199 139.55612642715954 0 0 0 0 0 0 33 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/raw/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 15 -5 0.955 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 3 | 4 0 0 300 -300 0.998 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 4 | 6 0 0 50 -13 0.99 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 8 0 0 300 -300 1.015 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 10 450 0 200 -147 1.05 100 1 550 0 0 0 0 0 0 0 0 0 0 0 0 7 | 12 85 0 120 -35 0.99 100 1 185 0 0 0 0 0 0 0 0 0 0 0 0 8 | 15 0 0 30 -10 0.97 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 9 | 18 0 0 50 -16 0.973 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 10 | 19 0 0 24 -8 0.962 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 11 | 24 0 0 300 -300 0.992 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 12 | 25 220 0 140 -47 1.05 100 1 320 0 0 0 0 0 0 0 0 0 0 0 0 13 | 26 314 0 1000 -1000 1.015 100 1 414 0 0 0 0 0 0 0 0 0 0 0 0 14 | 27 0 0 300 -300 0.968 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 15 | 31 7 0 300 -300 0.967 100 1 107 0 0 0 0 0 0 0 0 0 0 0 0 16 | 32 0 0 42 -14 0.963 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 17 | 34 0 0 24 -8 0.984 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 18 | 36 0 0 24 -8 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 19 | 40 0 0 300 -300 0.97 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 20 | 42 0 0 300 -300 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 21 | 46 19 0 100 -100 1.005 100 1 119 0 0 0 0 0 0 0 0 0 0 0 0 22 | 49 204 0 210 -85 1.025 100 1 304 0 0 0 0 0 0 0 0 0 0 0 0 23 | 54 48 0 300 -300 0.955 100 1 148 0 0 0 0 0 0 0 0 0 0 0 0 24 | 55 0 0 23 -8 0.952 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 25 | 56 0 0 15 -8 0.954 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 26 | 59 155 0 180 -60 0.985 100 1 255 0 0 0 0 0 0 0 0 0 0 0 0 27 | 61 160 0 300 -100 0.995 100 1 260 0 0 0 0 0 0 0 0 0 0 0 0 28 | 62 0 0 20 -20 0.998 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 29 | 65 391 0 200 -67 1.005 100 1 491 0 0 0 0 0 0 0 0 0 0 0 0 30 | 66 392 0 200 -67 1.05 100 1 492 0 0 0 0 0 0 0 0 0 0 0 0 31 | 69 516.4 0 300 -300 1.035 100 1 805.2 0 0 0 0 0 0 0 0 0 0 0 0 32 | 70 0 0 32 -10 0.984 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 33 | 72 0 0 100 -100 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 34 | 73 0 0 100 -100 0.991 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 35 | 74 0 0 9 -6 0.958 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 36 | 76 0 0 23 -8 0.943 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 37 | 77 0 0 70 -20 1.006 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 38 | 80 477 0 280 -165 1.04 100 1 577 0 0 0 0 0 0 0 0 0 0 0 0 39 | 85 0 0 23 -8 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 40 | 87 4 0 1000 -100 1.015 100 1 104 0 0 0 0 0 0 0 0 0 0 0 0 41 | 89 607 0 300 -210 1.005 100 1 707 0 0 0 0 0 0 0 0 0 0 0 0 42 | 90 0 0 300 -300 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 43 | 91 0 0 100 -100 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 44 | 92 0 0 9 -3 0.99 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 45 | 99 0 0 100 -100 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 46 | 100 252 0 155 -50 1.017 100 1 352 0 0 0 0 0 0 0 0 0 0 0 0 47 | 103 40 0 40 -15 1.01 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 48 | 104 0 0 23 -8 0.971 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 49 | 105 0 0 23 -8 0.965 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 50 | 107 0 0 200 -200 0.952 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 51 | 110 0 0 23 -8 0.973 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 52 | 111 36 0 1000 -100 0.98 100 1 136 0 0 0 0 0 0 0 0 0 0 0 0 53 | 112 0 0 1000 -100 0.975 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 54 | 113 0 0 200 -100 0.993 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 55 | 116 0 0 1000 -1000 1.005 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/gen_data.txt: -------------------------------------------------------------------------------- 1 | bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 2 | 1 0 0 15 -5 0.955 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 3 | 4 0 0 300 -300 0.998 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 4 | 6 0 0 50 -13 0.99 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 5 | 8 0 0 300 -300 1.015 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 6 | 10 450 0 200 -147 1.05 100 1 550 0 0 0 0 0 0 0 0 0 0 0 0 7 | 12 85 0 120 -35 0.99 100 1 185 0 0 0 0 0 0 0 0 0 0 0 0 8 | 15 0 0 30 -10 0.97 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 9 | 18 0 0 50 -16 0.973 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 10 | 19 0 0 24 -8 0.962 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 11 | 24 0 0 300 -300 0.992 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 12 | 25 220 0 140 -47 1.05 100 1 320 0 0 0 0 0 0 0 0 0 0 0 0 13 | 26 314 0 1000 -1000 1.015 100 1 414 0 0 0 0 0 0 0 0 0 0 0 0 14 | 27 0 0 300 -300 0.968 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 15 | 31 7 0 300 -300 0.967 100 1 107 0 0 0 0 0 0 0 0 0 0 0 0 16 | 32 0 0 42 -14 0.963 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 17 | 34 0 0 24 -8 0.984 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 18 | 36 0 0 24 -8 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 19 | 40 0 0 300 -300 0.97 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 20 | 42 0 0 300 -300 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 21 | 46 19 0 100 -100 1.005 100 1 119 0 0 0 0 0 0 0 0 0 0 0 0 22 | 49 204 0 210 -85 1.025 100 1 304 0 0 0 0 0 0 0 0 0 0 0 0 23 | 54 48 0 300 -300 0.955 100 1 148 0 0 0 0 0 0 0 0 0 0 0 0 24 | 55 0 0 23 -8 0.952 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 25 | 56 0 0 15 -8 0.954 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 26 | 59 155 0 180 -60 0.985 100 1 255 0 0 0 0 0 0 0 0 0 0 0 0 27 | 61 160 0 300 -100 0.995 100 1 260 0 0 0 0 0 0 0 0 0 0 0 0 28 | 62 0 0 20 -20 0.998 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 29 | 65 391 0 200 -67 1.005 100 1 491 0 0 0 0 0 0 0 0 0 0 0 0 30 | 66 392 0 200 -67 1.05 100 1 492 0 0 0 0 0 0 0 0 0 0 0 0 31 | 69 516.4 0 300 -300 1.035 100 1 805.2 0 0 0 0 0 0 0 0 0 0 0 0 32 | 70 0 0 32 -10 0.984 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 33 | 72 0 0 100 -100 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 34 | 73 0 0 100 -100 0.991 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 35 | 74 0 0 9 -6 0.958 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 36 | 76 0 0 23 -8 0.943 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 37 | 77 0 0 70 -20 1.006 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 38 | 80 477 0 280 -165 1.04 100 1 577 0 0 0 0 0 0 0 0 0 0 0 0 39 | 85 0 0 23 -8 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 40 | 87 4 0 1000 -100 1.015 100 1 104 0 0 0 0 0 0 0 0 0 0 0 0 41 | 89 607 0 300 -210 1.005 100 1 707 0 0 0 0 0 0 0 0 0 0 0 0 42 | 90 0 0 300 -300 0.985 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 43 | 91 0 0 100 -100 0.98 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 44 | 92 0 0 9 -3 0.99 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 45 | 99 0 0 100 -100 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 46 | 100 252 0 155 -50 1.017 100 1 352 0 0 0 0 0 0 0 0 0 0 0 0 47 | 103 40 0 40 -15 1.01 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0 48 | 104 0 0 23 -8 0.971 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 49 | 105 0 0 23 -8 0.965 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 50 | 107 0 0 200 -200 0.952 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 51 | 110 0 0 23 -8 0.973 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 52 | 111 36 0 1000 -100 0.98 100 1 136 0 0 0 0 0 0 0 0 0 0 0 0 53 | 112 0 0 1000 -100 0.975 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 54 | 113 0 0 200 -100 0.993 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 55 | 116 0 0 1000 -1000 1.005 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n03/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd7 Pd8 Pd2 Pd3 Pd4 Pd5 Pd6 Pd9 Pd10 Pd11 Pd12 Pd13 Pd14 Re1 Re2 Re3 Re4 Re5 Re6 Re7 Re8 Re9 Re10 Re11 Re12 Re13 Re14 2 | 1 1 1.0 0 0 0 11.411917636605061 61.408336552391646 27.12215997649581 2.0482683954859913 3.9884165901337707 20.092940933493644 2.831568425693354 0.0 0.8263566048389611 7.642685343496324 8.802483619917842 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 1 0.3333333333333333 0 0 0 17.858081318708194 119.41755756344283 48.36833131126834 2.6325819867061853 6.749053362731205 27.43842942657164 5.50735985294874 0.0 1.329189682545893 8.247098801661847 12.993361806069855 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 | 2 2 0.3333333333333333 0 0 0 22.047171449346397 108.29313986166134 41.13752585414111 3.4630153821481646 6.100611256556837 29.727289641867962 4.216792339032877 0.0 1.0914235467671227 8.322397993863687 10.044892658964057 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 2 3 0.3333333333333333 0 0 0 22.427821812102536 123.26635211173365 49.1508933968655 3.020321190746128 7.6774100035009285 25.527723766435415 5.231946243618623 0.0 1.395646346434285 10.881021457048936 10.910393789279256 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 3 1 0.3333333333333333 0 0 0 32.37374841433478 202.91705348557244 96.42504058000172 5.935458191580342 13.850337340946897 50.71060328247342 6.69845357674863 0.0 1.8765408786517395 18.61084587289748 19.826741098340943 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 3 2 0.3333333333333333 0 0 0 26.903742829684532 154.60148416306257 71.3784471162042 4.4162028436528615 11.228007834558715 55.41282463143755 7.413680068171783 0.0 2.3075323100121055 14.055172464839593 17.47817387275937 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 | 3 3 0.3333333333333333 0 0 0 34.90665025708459 146.86419789997822 86.64865153825345 4.736960254963298 13.259643402889642 48.262440525062765 7.696904700529354 0.0 2.5211061124376015 18.687395296725498 15.637680438815192 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 | 4 1 0.3333333333333333 0 0 0 29.751782871501018 177.44047128179778 98.59157596561484 5.694246437026742 11.44383585192241 41.79510821602266 8.061330667632983 0.0 2.5378559330766866 19.57963245447676 21.625827012871174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 | 4 2 0.3333333333333333 0 0 0 35.72019098826716 165.0085497895265 90.92840127787728 5.510658667364399 11.4401695610328 45.02466428934638 7.2752980352305165 0.0 2.2892514587854964 16.938550210282834 20.002438956343116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 | 4 3 0.3333333333333333 0 0 0 28.92679792743565 167.28274570012331 73.69056192143876 4.270890453866771 11.039364400207724 39.59466506320684 7.96801353072888 0.0 1.8042433531489532 18.268336830010075 19.77526564628803 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | 5 1 0.3333333333333333 0 0 0 34.210786355711456 143.22461099324366 79.63184051088699 4.548589608896708 12.849939828998512 46.7455307838566 7.621752075970111 0.0 2.295110707268077 17.219410472565464 17.877478332623546 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | 5 2 0.3333333333333333 0 0 0 25.416686751476913 153.4761269227492 88.94460371492981 5.153143273866014 10.152471041591316 40.75228084739938 6.91745030267761 0.0 1.8354871502120664 16.352260435074733 20.462606124230955 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | 5 3 0.3333333333333333 0 0 0 35.142139541702484 188.70655672303738 80.54031070301689 4.910086240303579 11.971028908660543 42.929151634340805 8.312313842731818 0.0 1.9956700727419558 12.766703343786315 20.009243861285263 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 | 6 1 0.3333333333333333 0 0 0 32.24763512230557 145.44802575630786 77.33554062198462 6.1818482021996 12.476340332099818 54.756415923072616 6.925034401188116 0.0 2.229679680261393 17.034139154874975 23.257733298217396 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 | 6 2 0.3333333333333333 0 0 0 33.79424526656406 181.6003343580744 100.54662073788468 4.33518845173334 13.61947500167635 50.47586095914097 8.440566464169017 0.0 2.276414941895188 18.27409432012581 20.582745726937702 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 | 6 3 0.3333333333333333 0 0 0 37.95343658044536 190.31307500666128 90.81854864439504 4.6508668990880535 13.031644657805469 52.80452799799931 8.201244295562518 0.0 2.4666887151239716 18.98744506038081 18.354712607632415 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t08_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd5 Pd2 Pd3 Pd4 Re1 Re2 Re3 Re4 Re5 2 | 1 1 1.0 0 0 110.96294121957122 92.40207363495827 51.2265827902004 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 74.37367576293472 73.81722222190737 46.73509869377385 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 72.81626037960251 77.48484942103914 39.21362019500168 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 78.93036386614831 81.55363328609312 42.464718174018294 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 66.78573753697688 66.95846402723151 44.3569203823871 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 70.88585487243344 73.68007044208026 40.46682500401361 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 95.10995604075703 65.94746222410676 42.47768052167597 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 194.24479847608265 228.51795390724052 99.93906872409494 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 187.1582392335579 191.531013532982 96.10732644410258 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 228.59423684612406 212.3979782163485 75.56592668417312 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 157.81602562116774 224.16769925813853 92.97048910506415 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 191.7842435116372 212.7959543109979 77.46567589807394 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 175.61942851568563 205.55359925121758 81.3698766963988 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 254.0210893538785 214.41137520673018 95.20788895419156 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 266.96917336170225 203.31489608073855 105.24861937973085 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 245.4928677919334 188.08548378506958 125.01773511801593 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 256.00588299403853 186.7016916842856 88.78789274733387 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 208.2538046712017 237.24596856004746 124.18398788652365 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 247.43562396113995 203.5810720037329 97.81905261555318 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 216.63805326395263 201.9827696205091 121.38464110976727 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 203.5797736212271 214.5067281711676 104.67703377232844 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 254.5691892458785 219.96078059640237 110.9909753479462 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 241.53798536459098 240.01161453433343 94.9658054277262 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 190.78652280418152 249.41309775245605 98.91136716693069 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 271.3561919972042 225.90372895748365 129.41941236336788 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 224.81810796278353 217.45576618018063 98.96711294278428 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 169.44501398086848 195.62242546759097 94.53897164159072 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 153.98583119401067 218.70290076322578 76.95343355337181 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 169.79534674944665 162.99430276855642 104.38963481154482 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 176.2543672319875 190.91362426076913 84.65659649953044 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 196.03575395121877 158.75209397700468 83.67043753328556 0 0 0 0 0 33 | 7 1 0.16666666666666666 0 0 249.75273182678225 289.68133232792826 103.45296234774787 0 0 0 0 0 34 | 7 2 0.16666666666666666 0 0 238.12797562584223 208.55619943476995 112.12683715361847 0 0 0 0 0 35 | 7 3 0.16666666666666666 0 0 229.9715579897368 227.38459799708713 115.46324834135726 0 0 0 0 0 36 | 7 4 0.16666666666666666 0 0 212.84009712286246 205.3607330659488 123.28256961948392 0 0 0 0 0 37 | 7 5 0.16666666666666666 0 0 277.03163804789057 234.26063664325082 143.28868571405218 0 0 0 0 0 38 | 7 6 0.16666666666666666 0 0 209.95558248615305 241.02875799369573 139.5415729682444 0 0 0 0 0 39 | 8 1 0.16666666666666666 0 0 223.33065660572515 226.0062384797142 120.91872094692465 0 0 0 0 0 40 | 8 2 0.16666666666666666 0 0 234.27245081142345 197.02764870175116 105.01882768450923 0 0 0 0 0 41 | 8 3 0.16666666666666666 0 0 227.40305972790063 188.51517090825243 121.41699070895035 0 0 0 0 0 42 | 8 4 0.16666666666666666 0 0 192.69797515428425 221.88177334770705 104.54395518442645 0 0 0 0 0 43 | 8 5 0.16666666666666666 0 0 206.31320000321435 206.09890193602155 116.55841256590324 0 0 0 0 0 44 | 8 6 0.16666666666666666 0 0 175.21881022662868 226.09400549689818 92.0266460207812 0 0 0 0 0 45 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t08_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd2 Pd3 Pd4 Pd5 Pd6 Re1 Re2 Re3 Re4 Re5 Re6 2 | 1 1 1.0 0 0 0 46.736447429743 46.07037615285572 43.81848140997016 0 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 0 48.739508729040296 35.17165018746705 35.012542677304396 0 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 0 45.86080098535898 40.42858951361797 40.00056762154397 0 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 0 42.18076903091213 40.638047922067024 49.01838419914906 0 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 0 37.1641689247311 43.299402264667094 41.3486618643053 0 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 0 39.46896246677012 40.97535017152541 38.12312521672624 0 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 0 41.78409147467517 34.96206811902463 39.723650164978615 0 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 0 118.02457725270426 86.97463712675817 96.60477148861912 0 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 0 88.06271666670172 83.45550960068792 107.2905831750603 0 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 0 99.86824372525457 105.04759062548736 111.06502992314971 0 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 0 108.14191063900643 111.1436909877165 116.85020422493118 0 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 0 90.71536465992429 92.99580930119834 90.38531596911209 0 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 0 95.44879177821305 85.57562506400792 88.61057642269677 0 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 0 98.23914984371382 102.69130503780076 107.38235043201166 0 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 0 130.47051041753275 125.9717782998919 134.14218075882093 0 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 0 103.3140520327495 135.2558342320141 123.38007574430301 0 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 0 106.0390121866488 115.26792186325619 121.14923234325005 0 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 0 126.44158370243842 136.60144446087654 117.51600443365287 0 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 0 96.7204501894006 131.0641045596404 106.47112989915982 0 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 0 134.49175311293757 132.76470464417565 138.8548599480705 0 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 0 97.06098344660516 120.98566443247162 136.9696693128982 0 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 0 103.33012365708973 132.16358981792894 132.31443521514433 0 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 0 97.83036484941768 103.89201479194676 105.33222239900115 0 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 0 125.57536318753922 103.13557324327766 139.6919533886791 0 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 0 114.45186634810445 121.44278764163039 144.09913203612896 0 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 0 82.1770219077781 105.8449882086463 84.98085661322457 0 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 0 106.74615280481792 105.89491530663751 86.15409594968123 0 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 0 113.74609127741755 103.14476392526926 85.8455990597236 0 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 0 82.42662504427706 98.97899523716018 94.09827168368022 0 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 0 87.44050063765587 87.77603630110629 99.85102845897794 0 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 0 112.44121562115633 115.52412505209223 110.6124453430227 0 0 0 0 0 0 33 | 7 1 0.16666666666666666 0 0 0 155.64028456076895 148.29175444678327 127.61883038880214 0 0 0 0 0 0 34 | 7 2 0.16666666666666666 0 0 0 140.15504158361716 105.92621145741332 115.75038129381257 0 0 0 0 0 0 35 | 7 3 0.16666666666666666 0 0 0 137.61830203790674 138.13487074852353 154.38652822375195 0 0 0 0 0 0 36 | 7 4 0.16666666666666666 0 0 0 125.49524637097768 116.84393442952336 132.8810994674618 0 0 0 0 0 0 37 | 7 5 0.16666666666666666 0 0 0 148.13098751388486 126.3632980699002 130.0412945612631 0 0 0 0 0 0 38 | 7 6 0.16666666666666666 0 0 0 152.7687977469699 113.48869283282414 124.47842488247541 0 0 0 0 0 0 39 | 8 1 0.16666666666666666 0 0 0 119.64511365563024 109.75108133353658 114.08201338133374 0 0 0 0 0 0 40 | 8 2 0.16666666666666666 0 0 0 108.2678113580769 106.72101544181467 129.99784301286053 0 0 0 0 0 0 41 | 8 3 0.16666666666666666 0 0 0 96.66188875202126 98.90675928459648 99.85762521533258 0 0 0 0 0 0 42 | 8 4 0.16666666666666666 0 0 0 119.01410207458878 92.02606470781578 104.96726947915224 0 0 0 0 0 0 43 | 8 5 0.16666666666666666 0 0 0 122.35156592110305 97.20119230778853 99.8496884115898 0 0 0 0 0 0 44 | 8 6 0.16666666666666666 0 0 0 106.98188334942263 100.7322492093355 127.36749463359322 0 0 0 0 0 0 45 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # sddip 2 | 3 | Implementation of the (dynamic) stochastic dual dynamic integer programming 4 | (SDDiP) algorithm. 5 | 6 | ## (Dynamic) SDDIP Algorithm 7 | 8 | Multistage stochastic mixed-integer linear problems (MSMILPs) are non-convex, 9 | usually of large scale, and hard to solve. This calls for decomposition 10 | approaches to keep the solution process computationally tractable. 11 | 12 | Recently, the set of decomposition approaches has been extended by stochastic 13 | dual dynamic integer programming (SDDiP) [1]. Constructing outer approximations 14 | of the value functions using so-called Lagrangian cuts, this method can solve 15 | MSMILPs with binary state variables exactly. Performing a binary approximation 16 | of general mixed-integer state variables, SDDiP is applicable to a broader 17 | class of MSMILPs. The binarization of variables is fixed and carried out in 18 | advance. However, this requires knowledge about problem-specific parameters 19 | which may be hard to gain in practice. A recent proposal [2] is to use a more 20 | sophisticated binarization approach where the approximation is applied 21 | temporarily and refined dynamically. For this purpose, by projection, 22 | non-convex Lagrangian cuts are created that are applicable in binary and 23 | mixed-integer state space. 24 | 25 | The present work combines SDDiP and the dynamic binarization approach in a 26 | dynamic SDDiP algorithm. This project includes an implementation of the dynamic 27 | SDDiP algorithm as well as of the classical SDDiP approach. Both algorithms are 28 | being used to solve instances of the multistage stochastic unit commitment 29 | problem. 30 | 31 | ## Setup 32 | 33 | We use [Poetry](https://github.com/python-poetry/poetry) for packaging and 34 | dependency management. Please use `poetry install` to create a new virtual 35 | environment and to install the dependencies (including development 36 | requirements) specified in the `pyproject.toml` and the `poetry.lock` file. 37 | 38 | The above will also perform an editable install of the `sddip` package. 39 | Therefore, when activating the virtual environment with the `poetry shell` 40 | command, you will already be able to use the `sddip` command line interface. 41 | 42 | Run `python -m sddip -h` to get an overview of the options that the `sddip` 43 | command line interface provides. 44 | 45 | ## Test Sessions 46 | 47 | To start a new test session, use the following command: 48 | 49 | ```bash 50 | python -m sddip --session 51 | ``` 52 | 53 | By default, the `sddip` package will attempt to load the session config from 54 | a `session.toml` file in the current working directory. The optional 55 | `--session` argument enables you to select an alternative session config. 56 | 57 | In the session config you can specify a sequence of test cases that will be 58 | executed within one session. 59 | 60 | A seed for the random number generator used in the scenario sampling can be set 61 | as follows: 62 | 63 | ```bash 64 | python -m sddip --seed 65 | ``` 66 | 67 | ## Test Creation 68 | 69 | To create a new test case, use the following command: 70 | 71 | ```bash 72 | python -m sddip create --test-case --test-base -t -n 73 | ``` 74 | 75 | With `--test-case`, you can specify the path to the target directory that will 76 | contain the files with the data defining the new test case. This will create 77 | new directories if the specified path does not exist yet. 78 | 79 | The optional argument `--test-base` specifies the directory which should 80 | contain the files defining the test system. In the current setup, this 81 | directory is usually called `raw/`. 82 | If a test base directory is given, all files from this directory will be copied 83 | to the target test case directory. 84 | If not specified, the test generation 85 | engine will try to draw the base data from the target test case directory. 86 | 87 | Specify the number of stages with `--stages` or `-t` and the number of 88 | realizations per stage with `--realizations` or `-n`. These parameters will be 89 | used for the scenario creation. 90 | 91 | The test generation engine will also generate the supplementary data, e.g., 92 | the generators' minimum up- and downtime, and ramp rates. This step can also be 93 | triggered separately from the above with the following command: 94 | 95 | ```bash 96 | python -m sddip create --supplementary 97 | ``` 98 | 99 | ## References 100 | 101 | [1] Zou, J., Ahmed, S., and Sun, X. A. Stochastic dual dynamic integer 102 | programming. Mathematical Programming 175, 461–502 (2019). 103 | 104 | [2] Füllner, C., and Rebennack, S. Non-convex Nested Benders Decomposition 105 | Mathematical Programming 196, 987–1024 (2022). 106 | -------------------------------------------------------------------------------- /notebooks/archive/results.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Results" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import ast\n", 17 | "import os\n", 18 | "\n", 19 | "import numpy as np\n", 20 | "import pandas as pd" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "from sddip import config" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "## Choose results folder !!!" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [ 45 | "# Choose results folder\n", 46 | "results_folder = \"results_2022_03_04__14_32_13\"" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "ps = \"primal_solutions.csv\"\n", 56 | "ds = \"dual_solutions.csv\"\n", 57 | "cc = \"cut_coefficients.csv\"\n", 58 | "dual_solver = \"dual_solver.csv\"\n", 59 | "\n", 60 | "results_dir = os.path.join(config.solutions_dir, results_folder)\n", 61 | "\n", 62 | "ps_dir = os.path.join(results_dir, ps)\n", 63 | "ds_dir = os.path.join(results_dir, ds)\n", 64 | "cc_dir = os.path.join(results_dir, cc)\n", 65 | "dual_solver_dir = os.path.join(results_dir, dual_solver)" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "ps_df = pd.read_csv(ps_dir, sep=\"\\t\")\n", 75 | "ps_df" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "ds_df = pd.read_csv(ds_dir, sep=\"\\t\")\n", 85 | "ds_df" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": null, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "cc_df = pd.read_csv(cc_dir, sep=\"\\t\")\n", 95 | "cc_df" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "dual_solver_df = pd.read_csv(dual_solver_dir, sep=\"\\t\")\n", 105 | "dual_solver_df" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [ 114 | "dual_solver_df[\"iterations\"] = dual_solver_df.iterations.apply(\n", 115 | " lambda x: ast.literal_eval(str(x))\n", 116 | ")\n", 117 | "dual_solver_df[\"solver_time\"] = dual_solver_df.solver_time.apply(\n", 118 | " lambda x: ast.literal_eval(str(x))\n", 119 | ")" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": null, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "solver_times = np.array(dual_solver_df.solver_time.values.tolist())\n", 129 | "solver_times" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "iterations = np.array(dual_solver_df.iterations.tolist())\n", 139 | "iterations" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [ 148 | "np.sum(solver_times, axis=1)" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": null, 154 | "metadata": {}, 155 | "outputs": [], 156 | "source": [ 157 | "solver_times_adjusted = np.divide(solver_times, iterations)\n", 158 | "np.sum(solver_times_adjusted, axis=1)" 159 | ] 160 | } 161 | ], 162 | "metadata": { 163 | "interpreter": { 164 | "hash": "abe42ade3e87b4e6c3c5745962b526975dbcf6574cac0f27c7eb88f5d6f3bab5" 165 | }, 166 | "kernelspec": { 167 | "display_name": "Python 3.10.0 64-bit ('optimization': conda)", 168 | "language": "python", 169 | "name": "python3" 170 | }, 171 | "language_info": { 172 | "codemirror_mode": { 173 | "name": "ipython", 174 | "version": 3 175 | }, 176 | "file_extension": ".py", 177 | "mimetype": "text/x-python", 178 | "name": "python", 179 | "nbconvert_exporter": "python", 180 | "pygments_lexer": "ipython3", 181 | "version": "3.9.7" 182 | }, 183 | "orig_nbformat": 4 184 | }, 185 | "nbformat": 4, 186 | "nbformat_minor": 2 187 | } 188 | -------------------------------------------------------------------------------- /sddip/sddip/utils.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | 3 | import numpy as np 4 | 5 | 6 | class Graph: 7 | def __init__(self, nodes: list, edges: list) -> None: 8 | self.edges = edges 9 | self.nodes = nodes 10 | 11 | def incidence_matrix(self): 12 | incidence_matrix = np.zeros((len(self.edges), len(self.nodes))) 13 | line_index = 0 14 | for edge in self.edges: 15 | incidence_matrix[line_index, edge[0] - 1] = 1 16 | incidence_matrix[line_index, edge[1] - 1] = -1 17 | line_index += 1 18 | return incidence_matrix 19 | 20 | 21 | class Binarizer: 22 | def binary_expansion(self, x, upper_bound, precision): 23 | bin_multipliers = self.calc_binary_multipliers_from_precision( 24 | upper_bound, precision 25 | ) 26 | 27 | return self.get_best_binary_approximation(x, bin_multipliers) 28 | 29 | def binary_expansion_from_n_binaries(self, x, upper_bound, n_binaries): 30 | bin_multipliers = self.calc_binary_multipliers_from_n_binaries( 31 | upper_bound, n_binaries 32 | ) 33 | 34 | return self.get_best_binary_approximation(x, bin_multipliers) 35 | 36 | def binary_expansion_from_multipliers(self, x, binary_multipliers): 37 | return self.get_best_binary_approximation(x, binary_multipliers) 38 | 39 | def get_best_binary_approximation(self, x, binary_multipliers): 40 | lower_approximation_vars = self.calc_binary_lower_approximation( 41 | x, binary_multipliers 42 | ) 43 | 44 | # None, if all binary variables of lower approximation equal 1 45 | upper_approximation_vars = self.calc_binary_upper_approximation( 46 | lower_approximation_vars 47 | ) 48 | 49 | best_appr_vars = lower_approximation_vars 50 | 51 | # Choose approximation with the lowest error 52 | if upper_approximation_vars is not None: 53 | binary_multipliers = np.array(binary_multipliers) 54 | lower_approximation_vars = np.array(lower_approximation_vars) 55 | upper_approximation_vars = np.array(upper_approximation_vars) 56 | 57 | bin_appr_lower = lower_approximation_vars.dot(binary_multipliers) 58 | bin_appr_upper = upper_approximation_vars.dot(binary_multipliers) 59 | 60 | error_appr = x - bin_appr_lower 61 | error_appr_alt = bin_appr_upper - x 62 | 63 | if error_appr_alt < error_appr: 64 | best_appr_vars = upper_approximation_vars 65 | 66 | return (list(best_appr_vars), list(binary_multipliers)) 67 | 68 | def calc_binary_multipliers_from_precision( 69 | self, upper_bound: float, precision: float 70 | ): 71 | n_bin_vars = int(np.log2(upper_bound / precision)) + 1 72 | 73 | return self.calc_binary_multipliers(precision, n_bin_vars) 74 | 75 | def calc_binary_multipliers_from_n_binaries( 76 | self, upper_bound: float, n_binaries: int 77 | ): 78 | precision = self.calc_precision_from_n_binaries( 79 | upper_bound, n_binaries 80 | ) 81 | 82 | return self.calc_binary_multipliers(precision, n_binaries) 83 | 84 | def calc_binary_multipliers(self, precision: float, n_binaries: int): 85 | return [precision * 2**i for i in range(n_binaries)] 86 | 87 | def calc_precision_from_n_binaries( 88 | self, upper_bound: float, n_binaries: int 89 | ): 90 | return upper_bound / (sum([2 ** (k) for k in range(n_binaries)])) 91 | 92 | def calc_max_abs_error(self, precision: int): 93 | if 0 > precision > 1: 94 | msg = "Precision should be between 0 and 1." 95 | raise ValueError(msg) 96 | return precision / 2 97 | 98 | def calc_binary_lower_approximation( 99 | self, x: float, binary_multipliers: list 100 | ): 101 | bin_vars = [] 102 | 103 | for b in reversed(binary_multipliers): 104 | v = 0 105 | if x >= b: 106 | v = 1 107 | x -= b 108 | bin_vars.insert(0, v) 109 | 110 | return bin_vars 111 | 112 | def calc_binary_upper_approximation(self, lower_approximation_vars): 113 | first_zero_index = None 114 | 115 | with contextlib.suppress(ValueError): 116 | first_zero_index = lower_approximation_vars.index(0) 117 | 118 | upper_approximation_vars = None 119 | 120 | if first_zero_index is not None: 121 | upper_approximation_vars = lower_approximation_vars.copy() 122 | upper_approximation_vars[:first_zero_index] = [ 123 | 0 124 | ] * first_zero_index 125 | upper_approximation_vars[first_zero_index] = 1 126 | 127 | return upper_approximation_vars 128 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/info/case14.m: -------------------------------------------------------------------------------- 1 | function mpc = case14 2 | %CASE14 Power flow data for IEEE 14 bus test case. 3 | % Please see CASEFORMAT for details on the case file format. 4 | % This data was converted from IEEE Common Data Format 5 | % (ieee14cdf.txt) on 15-Oct-2014 by cdf2matp, rev. 2393 6 | % See end of file for warnings generated during conversion. 7 | % 8 | % Converted from IEEE CDF file from: 9 | % http://www.ee.washington.edu/research/pstca/ 10 | % 11 | % 08/19/93 UW ARCHIVE 100.0 1962 W IEEE 14 Bus Test Case 12 | 13 | % MATPOWER 14 | 15 | %% MATPOWER Case Format : Version 2 16 | mpc.version = '2'; 17 | 18 | %%----- Power Flow Data -----%% 19 | %% system MVA base 20 | mpc.baseMVA = 100; 21 | 22 | %% bus data 23 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 24 | mpc.bus = [ 25 | 1 3 0 0 0 0 1 1.06 0 0 1 1.06 0.94; 26 | 2 2 21.7 12.7 0 0 1 1.045 -4.98 0 1 1.06 0.94; 27 | 3 2 94.2 19 0 0 1 1.01 -12.72 0 1 1.06 0.94; 28 | 4 1 47.8 -3.9 0 0 1 1.019 -10.33 0 1 1.06 0.94; 29 | 5 1 7.6 1.6 0 0 1 1.02 -8.78 0 1 1.06 0.94; 30 | 6 2 11.2 7.5 0 0 1 1.07 -14.22 0 1 1.06 0.94; 31 | 7 1 0 0 0 0 1 1.062 -13.37 0 1 1.06 0.94; 32 | 8 2 0 0 0 0 1 1.09 -13.36 0 1 1.06 0.94; 33 | 9 1 29.5 16.6 0 19 1 1.056 -14.94 0 1 1.06 0.94; 34 | 10 1 9 5.8 0 0 1 1.051 -15.1 0 1 1.06 0.94; 35 | 11 1 3.5 1.8 0 0 1 1.057 -14.79 0 1 1.06 0.94; 36 | 12 1 6.1 1.6 0 0 1 1.055 -15.07 0 1 1.06 0.94; 37 | 13 1 13.5 5.8 0 0 1 1.05 -15.16 0 1 1.06 0.94; 38 | 14 1 14.9 5 0 0 1 1.036 -16.04 0 1 1.06 0.94; 39 | ]; 40 | 41 | %% generator data 42 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 43 | mpc.gen = [ 44 | 1 232.4 -16.9 10 0 1.06 100 1 332.4 0 0 0 0 0 0 0 0 0 0 0 0; 45 | 2 40 42.4 50 -40 1.045 100 1 140 0 0 0 0 0 0 0 0 0 0 0 0; 46 | 3 0 23.4 40 0 1.01 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0; 47 | 6 0 12.2 24 -6 1.07 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0; 48 | 8 0 17.4 24 -6 1.09 100 1 100 0 0 0 0 0 0 0 0 0 0 0 0; 49 | ]; 50 | 51 | %% branch data 52 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 53 | mpc.branch = [ 54 | 1 2 0.01938 0.05917 0.0528 0 0 0 0 0 1 -360 360; 55 | 1 5 0.05403 0.22304 0.0492 0 0 0 0 0 1 -360 360; 56 | 2 3 0.04699 0.19797 0.0438 0 0 0 0 0 1 -360 360; 57 | 2 4 0.05811 0.17632 0.034 0 0 0 0 0 1 -360 360; 58 | 2 5 0.05695 0.17388 0.0346 0 0 0 0 0 1 -360 360; 59 | 3 4 0.06701 0.17103 0.0128 0 0 0 0 0 1 -360 360; 60 | 4 5 0.01335 0.04211 0 0 0 0 0 0 1 -360 360; 61 | 4 7 0 0.20912 0 0 0 0 0.978 0 1 -360 360; 62 | 4 9 0 0.55618 0 0 0 0 0.969 0 1 -360 360; 63 | 5 6 0 0.25202 0 0 0 0 0.932 0 1 -360 360; 64 | 6 11 0.09498 0.1989 0 0 0 0 0 0 1 -360 360; 65 | 6 12 0.12291 0.25581 0 0 0 0 0 0 1 -360 360; 66 | 6 13 0.06615 0.13027 0 0 0 0 0 0 1 -360 360; 67 | 7 8 0 0.17615 0 0 0 0 0 0 1 -360 360; 68 | 7 9 0 0.11001 0 0 0 0 0 0 1 -360 360; 69 | 9 10 0.03181 0.0845 0 0 0 0 0 0 1 -360 360; 70 | 9 14 0.12711 0.27038 0 0 0 0 0 0 1 -360 360; 71 | 10 11 0.08205 0.19207 0 0 0 0 0 0 1 -360 360; 72 | 12 13 0.22092 0.19988 0 0 0 0 0 0 1 -360 360; 73 | 13 14 0.17093 0.34802 0 0 0 0 0 0 1 -360 360; 74 | ]; 75 | 76 | %%----- OPF Data -----%% 77 | %% generator cost data 78 | % 1 startup shutdown n x1 y1 ... xn yn 79 | % 2 startup shutdown n c(n-1) ... c0 80 | mpc.gencost = [ 81 | 2 0 0 3 0.0430292599 20 0; 82 | 2 0 0 3 0.25 20 0; 83 | 2 0 0 3 0.01 40 0; 84 | 2 0 0 3 0.01 40 0; 85 | 2 0 0 3 0.01 40 0; 86 | ]; 87 | 88 | %% bus names 89 | mpc.bus_name = { 90 | 'Bus 1 HV'; 91 | 'Bus 2 HV'; 92 | 'Bus 3 HV'; 93 | 'Bus 4 HV'; 94 | 'Bus 5 HV'; 95 | 'Bus 6 LV'; 96 | 'Bus 7 ZV'; 97 | 'Bus 8 TV'; 98 | 'Bus 9 LV'; 99 | 'Bus 10 LV'; 100 | 'Bus 11 LV'; 101 | 'Bus 12 LV'; 102 | 'Bus 13 LV'; 103 | 'Bus 14 LV'; 104 | }; 105 | 106 | % Warnings from cdf2matp conversion: 107 | % 108 | % ***** check the title format in the first line of the cdf file. 109 | % ***** Qmax = Qmin at generator at bus 1 (Qmax set to Qmin + 10) 110 | % ***** MVA limit of branch 1 - 2 not given, set to 0 111 | % ***** MVA limit of branch 1 - 5 not given, set to 0 112 | % ***** MVA limit of branch 2 - 3 not given, set to 0 113 | % ***** MVA limit of branch 2 - 4 not given, set to 0 114 | % ***** MVA limit of branch 2 - 5 not given, set to 0 115 | % ***** MVA limit of branch 3 - 4 not given, set to 0 116 | % ***** MVA limit of branch 4 - 5 not given, set to 0 117 | % ***** MVA limit of branch 4 - 7 not given, set to 0 118 | % ***** MVA limit of branch 4 - 9 not given, set to 0 119 | % ***** MVA limit of branch 5 - 6 not given, set to 0 120 | % ***** MVA limit of branch 6 - 11 not given, set to 0 121 | % ***** MVA limit of branch 6 - 12 not given, set to 0 122 | % ***** MVA limit of branch 6 - 13 not given, set to 0 123 | % ***** MVA limit of branch 7 - 8 not given, set to 0 124 | % ***** MVA limit of branch 7 - 9 not given, set to 0 125 | % ***** MVA limit of branch 9 - 10 not given, set to 0 126 | % ***** MVA limit of branch 9 - 14 not given, set to 0 127 | % ***** MVA limit of branch 10 - 11 not given, set to 0 128 | % ***** MVA limit of branch 12 - 13 not given, set to 0 129 | % ***** MVA limit of branch 13 - 14 not given, set to 0 130 | -------------------------------------------------------------------------------- /data/01_test_cases/case30/info/case30.m: -------------------------------------------------------------------------------- 1 | function mpc = case30 2 | %CASE30 Power flow data for 30 bus, 6 generator case. 3 | % Please see CASEFORMAT for details on the case file format. 4 | % 5 | % Based on data from ... 6 | % Alsac, O. & Stott, B., "Optimal Load Flow with Steady State Security", 7 | % IEEE Transactions on Power Apparatus and Systems, Vol. PAS 93, No. 3, 8 | % 1974, pp. 745-751. 9 | % ... with branch parameters rounded to nearest 0.01, shunt values divided 10 | % by 100 and shunt on bus 10 moved to bus 5, load at bus 5 zeroed out. 11 | % Generator locations, costs and limits and bus areas were taken from ... 12 | % Ferrero, R.W., Shahidehpour, S.M., Ramesh, V.C., "Transaction analysis 13 | % in deregulated power systems using game theory", IEEE Transactions on 14 | % Power Systems, Vol. 12, No. 3, Aug 1997, pp. 1340-1347. 15 | % Generator Q limits were derived from Alsac & Stott, using their Pmax 16 | % capacities. V limits and line |S| limits taken from Alsac & Stott. 17 | 18 | % MATPOWER 19 | 20 | %% MATPOWER Case Format : Version 2 21 | mpc.version = '2'; 22 | 23 | %%----- Power Flow Data -----%% 24 | %% system MVA base 25 | mpc.baseMVA = 100; 26 | 27 | %% bus data 28 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 29 | mpc.bus = [ 30 | 1 3 0 0 0 0 1 1 0 135 1 1.05 0.95; 31 | 2 2 21.7 12.7 0 0 1 1 0 135 1 1.1 0.95; 32 | 3 1 2.4 1.2 0 0 1 1 0 135 1 1.05 0.95; 33 | 4 1 7.6 1.6 0 0 1 1 0 135 1 1.05 0.95; 34 | 5 1 0 0 0 0.19 1 1 0 135 1 1.05 0.95; 35 | 6 1 0 0 0 0 1 1 0 135 1 1.05 0.95; 36 | 7 1 22.8 10.9 0 0 1 1 0 135 1 1.05 0.95; 37 | 8 1 30 30 0 0 1 1 0 135 1 1.05 0.95; 38 | 9 1 0 0 0 0 1 1 0 135 1 1.05 0.95; 39 | 10 1 5.8 2 0 0 3 1 0 135 1 1.05 0.95; 40 | 11 1 0 0 0 0 1 1 0 135 1 1.05 0.95; 41 | 12 1 11.2 7.5 0 0 2 1 0 135 1 1.05 0.95; 42 | 13 2 0 0 0 0 2 1 0 135 1 1.1 0.95; 43 | 14 1 6.2 1.6 0 0 2 1 0 135 1 1.05 0.95; 44 | 15 1 8.2 2.5 0 0 2 1 0 135 1 1.05 0.95; 45 | 16 1 3.5 1.8 0 0 2 1 0 135 1 1.05 0.95; 46 | 17 1 9 5.8 0 0 2 1 0 135 1 1.05 0.95; 47 | 18 1 3.2 0.9 0 0 2 1 0 135 1 1.05 0.95; 48 | 19 1 9.5 3.4 0 0 2 1 0 135 1 1.05 0.95; 49 | 20 1 2.2 0.7 0 0 2 1 0 135 1 1.05 0.95; 50 | 21 1 17.5 11.2 0 0 3 1 0 135 1 1.05 0.95; 51 | 22 2 0 0 0 0 3 1 0 135 1 1.1 0.95; 52 | 23 2 3.2 1.6 0 0 2 1 0 135 1 1.1 0.95; 53 | 24 1 8.7 6.7 0 0.04 3 1 0 135 1 1.05 0.95; 54 | 25 1 0 0 0 0 3 1 0 135 1 1.05 0.95; 55 | 26 1 3.5 2.3 0 0 3 1 0 135 1 1.05 0.95; 56 | 27 2 0 0 0 0 3 1 0 135 1 1.1 0.95; 57 | 28 1 0 0 0 0 1 1 0 135 1 1.05 0.95; 58 | 29 1 2.4 0.9 0 0 3 1 0 135 1 1.05 0.95; 59 | 30 1 10.6 1.9 0 0 3 1 0 135 1 1.05 0.95; 60 | ]; 61 | 62 | %% generator data 63 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 64 | mpc.gen = [ 65 | 1 23.54 0 150 -20 1 100 1 80 0 0 0 0 0 0 0 0 0 0 0 0; 66 | 2 60.97 0 60 -20 1 100 1 80 0 0 0 0 0 0 0 0 0 0 0 0; 67 | 22 21.59 0 62.5 -15 1 100 1 50 0 0 0 0 0 0 0 0 0 0 0 0; 68 | 27 26.91 0 48.7 -15 1 100 1 55 0 0 0 0 0 0 0 0 0 0 0 0; 69 | 23 19.2 0 40 -10 1 100 1 30 0 0 0 0 0 0 0 0 0 0 0 0; 70 | 13 37 0 44.7 -15 1 100 1 40 0 0 0 0 0 0 0 0 0 0 0 0; 71 | ]; 72 | 73 | %% branch data 74 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 75 | mpc.branch = [ 76 | 1 2 0.02 0.06 0.03 130 130 130 0 0 1 -360 360; 77 | 1 3 0.05 0.19 0.02 130 130 130 0 0 1 -360 360; 78 | 2 4 0.06 0.17 0.02 65 65 65 0 0 1 -360 360; 79 | 3 4 0.01 0.04 0 130 130 130 0 0 1 -360 360; 80 | 2 5 0.05 0.2 0.02 130 130 130 0 0 1 -360 360; 81 | 2 6 0.06 0.18 0.02 65 65 65 0 0 1 -360 360; 82 | 4 6 0.01 0.04 0 90 90 90 0 0 1 -360 360; 83 | 5 7 0.05 0.12 0.01 70 70 70 0 0 1 -360 360; 84 | 6 7 0.03 0.08 0.01 130 130 130 0 0 1 -360 360; 85 | 6 8 0.01 0.04 0 32 32 32 0 0 1 -360 360; 86 | 6 9 0 0.21 0 65 65 65 0 0 1 -360 360; 87 | 6 10 0 0.56 0 32 32 32 0 0 1 -360 360; 88 | 9 11 0 0.21 0 65 65 65 0 0 1 -360 360; 89 | 9 10 0 0.11 0 65 65 65 0 0 1 -360 360; 90 | 4 12 0 0.26 0 65 65 65 0 0 1 -360 360; 91 | 12 13 0 0.14 0 65 65 65 0 0 1 -360 360; 92 | 12 14 0.12 0.26 0 32 32 32 0 0 1 -360 360; 93 | 12 15 0.07 0.13 0 32 32 32 0 0 1 -360 360; 94 | 12 16 0.09 0.2 0 32 32 32 0 0 1 -360 360; 95 | 14 15 0.22 0.2 0 16 16 16 0 0 1 -360 360; 96 | 16 17 0.08 0.19 0 16 16 16 0 0 1 -360 360; 97 | 15 18 0.11 0.22 0 16 16 16 0 0 1 -360 360; 98 | 18 19 0.06 0.13 0 16 16 16 0 0 1 -360 360; 99 | 19 20 0.03 0.07 0 32 32 32 0 0 1 -360 360; 100 | 10 20 0.09 0.21 0 32 32 32 0 0 1 -360 360; 101 | 10 17 0.03 0.08 0 32 32 32 0 0 1 -360 360; 102 | 10 21 0.03 0.07 0 32 32 32 0 0 1 -360 360; 103 | 10 22 0.07 0.15 0 32 32 32 0 0 1 -360 360; 104 | 21 22 0.01 0.02 0 32 32 32 0 0 1 -360 360; 105 | 15 23 0.1 0.2 0 16 16 16 0 0 1 -360 360; 106 | 22 24 0.12 0.18 0 16 16 16 0 0 1 -360 360; 107 | 23 24 0.13 0.27 0 16 16 16 0 0 1 -360 360; 108 | 24 25 0.19 0.33 0 16 16 16 0 0 1 -360 360; 109 | 25 26 0.25 0.38 0 16 16 16 0 0 1 -360 360; 110 | 25 27 0.11 0.21 0 16 16 16 0 0 1 -360 360; 111 | 28 27 0 0.4 0 65 65 65 0 0 1 -360 360; 112 | 27 29 0.22 0.42 0 16 16 16 0 0 1 -360 360; 113 | 27 30 0.32 0.6 0 16 16 16 0 0 1 -360 360; 114 | 29 30 0.24 0.45 0 16 16 16 0 0 1 -360 360; 115 | 8 28 0.06 0.2 0.02 32 32 32 0 0 1 -360 360; 116 | 6 28 0.02 0.06 0.01 32 32 32 0 0 1 -360 360; 117 | ]; 118 | 119 | %%----- OPF Data -----%% 120 | %% generator cost data 121 | % 1 startup shutdown n x1 y1 ... xn yn 122 | % 2 startup shutdown n c(n-1) ... c0 123 | mpc.gencost = [ 124 | 2 0 0 3 0.02 2 0; 125 | 2 0 0 3 0.0175 1.75 0; 126 | 2 0 0 3 0.0625 1 0; 127 | 2 0 0 3 0.00834 3.25 0; 128 | 2 0 0 3 0.025 3 0; 129 | 2 0 0 3 0.025 3 0; 130 | ]; 131 | -------------------------------------------------------------------------------- /data/01_test_cases/case118/raw/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 2 51 27 0 0 1 0.955 10.67 138 1 1.06 0.94 3 | 2 1 20 9 0 0 1 0.971 11.22 138 1 1.06 0.94 4 | 3 1 39 10 0 0 1 0.968 11.56 138 1 1.06 0.94 5 | 4 2 39 12 0 0 1 0.998 15.28 138 1 1.06 0.94 6 | 5 1 0 0 0 -40 1 1.002 15.73 138 1 1.06 0.94 7 | 6 2 52 22 0 0 1 0.99 13 138 1 1.06 0.94 8 | 7 1 19 2 0 0 1 0.989 12.56 138 1 1.06 0.94 9 | 8 2 28 0 0 0 1 1.015 20.77 345 1 1.06 0.94 10 | 9 1 0 0 0 0 1 1.043 28.02 345 1 1.06 0.94 11 | 10 2 0 0 0 0 1 1.05 35.61 345 1 1.06 0.94 12 | 11 1 70 23 0 0 1 0.985 12.72 138 1 1.06 0.94 13 | 12 2 47 10 0 0 1 0.99 12.2 138 1 1.06 0.94 14 | 13 1 34 16 0 0 1 0.968 11.35 138 1 1.06 0.94 15 | 14 1 14 1 0 0 1 0.984 11.5 138 1 1.06 0.94 16 | 15 2 90 30 0 0 1 0.97 11.23 138 1 1.06 0.94 17 | 16 1 25 10 0 0 1 0.984 11.91 138 1 1.06 0.94 18 | 17 1 11 3 0 0 1 0.995 13.74 138 1 1.06 0.94 19 | 18 2 60 34 0 0 1 0.973 11.53 138 1 1.06 0.94 20 | 19 2 45 25 0 0 1 0.963 11.05 138 1 1.06 0.94 21 | 20 1 18 3 0 0 1 0.958 11.93 138 1 1.06 0.94 22 | 21 1 14 8 0 0 1 0.959 13.52 138 1 1.06 0.94 23 | 22 1 10 5 0 0 1 0.97 16.08 138 1 1.06 0.94 24 | 23 1 7 3 0 0 1 1 21 138 1 1.06 0.94 25 | 24 2 13 0 0 0 1 0.992 20.89 138 1 1.06 0.94 26 | 25 2 0 0 0 0 1 1.05 27.93 138 1 1.06 0.94 27 | 26 2 0 0 0 0 1 1.015 29.71 345 1 1.06 0.94 28 | 27 2 71 13 0 0 1 0.968 15.35 138 1 1.06 0.94 29 | 28 1 17 7 0 0 1 0.962 13.62 138 1 1.06 0.94 30 | 29 1 24 4 0 0 1 0.963 12.63 138 1 1.06 0.94 31 | 30 1 0 0 0 0 1 0.968 18.79 345 1 1.06 0.94 32 | 31 2 43 27 0 0 1 0.967 12.75 138 1 1.06 0.94 33 | 32 2 59 23 0 0 1 0.964 14.8 138 1 1.06 0.94 34 | 33 1 23 9 0 0 1 0.972 10.63 138 1 1.06 0.94 35 | 34 2 59 26 0 14 1 0.986 11.3 138 1 1.06 0.94 36 | 35 1 33 9 0 0 1 0.981 10.87 138 1 1.06 0.94 37 | 36 2 31 17 0 0 1 0.98 10.87 138 1 1.06 0.94 38 | 37 1 0 0 0 -25 1 0.992 11.77 138 1 1.06 0.94 39 | 38 1 0 0 0 0 1 0.962 16.91 345 1 1.06 0.94 40 | 39 1 27 11 0 0 1 0.97 8.41 138 1 1.06 0.94 41 | 40 2 66 23 0 0 1 0.97 7.35 138 1 1.06 0.94 42 | 41 1 37 10 0 0 1 0.967 6.92 138 1 1.06 0.94 43 | 42 2 96 23 0 0 1 0.985 8.53 138 1 1.06 0.94 44 | 43 1 18 7 0 0 1 0.978 11.28 138 1 1.06 0.94 45 | 44 1 16 8 0 10 1 0.985 13.82 138 1 1.06 0.94 46 | 45 1 53 22 0 10 1 0.987 15.67 138 1 1.06 0.94 47 | 46 2 28 10 0 10 1 1.005 18.49 138 1 1.06 0.94 48 | 47 1 34 0 0 0 1 1.017 20.73 138 1 1.06 0.94 49 | 48 1 20 11 0 15 1 1.021 19.93 138 1 1.06 0.94 50 | 49 2 87 30 0 0 1 1.025 20.94 138 1 1.06 0.94 51 | 50 1 17 4 0 0 1 1.001 18.9 138 1 1.06 0.94 52 | 51 1 17 8 0 0 1 0.967 16.28 138 1 1.06 0.94 53 | 52 1 18 5 0 0 1 0.957 15.32 138 1 1.06 0.94 54 | 53 1 23 11 0 0 1 0.946 14.35 138 1 1.06 0.94 55 | 54 2 113 32 0 0 1 0.955 15.26 138 1 1.06 0.94 56 | 55 2 63 22 0 0 1 0.952 14.97 138 1 1.06 0.94 57 | 56 2 84 18 0 0 1 0.954 15.16 138 1 1.06 0.94 58 | 57 1 12 3 0 0 1 0.971 16.36 138 1 1.06 0.94 59 | 58 1 12 3 0 0 1 0.959 15.51 138 1 1.06 0.94 60 | 59 2 277 113 0 0 1 0.985 19.37 138 1 1.06 0.94 61 | 60 1 78 3 0 0 1 0.993 23.15 138 1 1.06 0.94 62 | 61 2 0 0 0 0 1 0.995 24.04 138 1 1.06 0.94 63 | 62 2 77 14 0 0 1 0.998 23.43 138 1 1.06 0.94 64 | 63 1 0 0 0 0 1 0.969 22.75 345 1 1.06 0.94 65 | 64 1 0 0 0 0 1 0.984 24.52 345 1 1.06 0.94 66 | 65 2 0 0 0 0 1 1.005 27.65 345 1 1.06 0.94 67 | 66 2 39 18 0 0 1 1.05 27.48 138 1 1.06 0.94 68 | 67 1 28 7 0 0 1 1.02 24.84 138 1 1.06 0.94 69 | 68 1 0 0 0 0 1 1.003 27.55 345 1 1.06 0.94 70 | 69 3 0 0 0 0 1 1.035 30 138 1 1.06 0.94 71 | 70 2 66 20 0 0 1 0.984 22.58 138 1 1.06 0.94 72 | 71 1 0 0 0 0 1 0.987 22.15 138 1 1.06 0.94 73 | 72 2 12 0 0 0 1 0.98 20.98 138 1 1.06 0.94 74 | 73 2 6 0 0 0 1 0.991 21.94 138 1 1.06 0.94 75 | 74 2 68 27 0 12 1 0.958 21.64 138 1 1.06 0.94 76 | 75 1 47 11 0 0 1 0.967 22.91 138 1 1.06 0.94 77 | 76 2 68 36 0 0 1 0.943 21.77 138 1 1.06 0.94 78 | 77 2 61 28 0 0 1 1.006 26.72 138 1 1.06 0.94 79 | 78 1 71 26 0 0 1 1.003 26.42 138 1 1.06 0.94 80 | 79 1 39 32 0 20 1 1.009 26.72 138 1 1.06 0.94 81 | 80 2 130 26 0 0 1 1.04 28.96 138 1 1.06 0.94 82 | 81 1 0 0 0 0 1 0.997 28.1 345 1 1.06 0.94 83 | 82 1 54 27 0 20 1 0.989 27.24 138 1 1.06 0.94 84 | 83 1 20 10 0 10 1 0.985 28.42 138 1 1.06 0.94 85 | 84 1 11 7 0 0 1 0.98 30.95 138 1 1.06 0.94 86 | 85 2 24 15 0 0 1 0.985 32.51 138 1 1.06 0.94 87 | 86 1 21 10 0 0 1 0.987 31.14 138 1 1.06 0.94 88 | 87 2 0 0 0 0 1 1.015 31.4 161 1 1.06 0.94 89 | 88 1 48 10 0 0 1 0.987 35.64 138 1 1.06 0.94 90 | 89 2 0 0 0 0 1 1.005 39.69 138 1 1.06 0.94 91 | 90 2 163 42 0 0 1 0.985 33.29 138 1 1.06 0.94 92 | 91 2 10 0 0 0 1 0.98 33.31 138 1 1.06 0.94 93 | 92 2 65 10 0 0 1 0.993 33.8 138 1 1.06 0.94 94 | 93 1 12 7 0 0 1 0.987 30.79 138 1 1.06 0.94 95 | 94 1 30 16 0 0 1 0.991 28.64 138 1 1.06 0.94 96 | 95 1 42 31 0 0 1 0.981 27.67 138 1 1.06 0.94 97 | 96 1 38 15 0 0 1 0.993 27.51 138 1 1.06 0.94 98 | 97 1 15 9 0 0 1 1.011 27.88 138 1 1.06 0.94 99 | 98 1 34 8 0 0 1 1.024 27.4 138 1 1.06 0.94 100 | 99 2 42 0 0 0 1 1.01 27.04 138 1 1.06 0.94 101 | 100 2 37 18 0 0 1 1.017 28.03 138 1 1.06 0.94 102 | 101 1 22 15 0 0 1 0.993 29.61 138 1 1.06 0.94 103 | 102 1 5 3 0 0 1 0.991 32.3 138 1 1.06 0.94 104 | 103 2 23 16 0 0 1 1.001 24.44 138 1 1.06 0.94 105 | 104 2 38 25 0 0 1 0.971 21.69 138 1 1.06 0.94 106 | 105 2 31 26 0 20 1 0.965 20.57 138 1 1.06 0.94 107 | 106 1 43 16 0 0 1 0.962 20.32 138 1 1.06 0.94 108 | 107 2 50 12 0 6 1 0.952 17.53 138 1 1.06 0.94 109 | 108 1 2 1 0 0 1 0.967 19.38 138 1 1.06 0.94 110 | 109 1 8 3 0 0 1 0.967 18.93 138 1 1.06 0.94 111 | 110 2 39 30 0 6 1 0.973 18.09 138 1 1.06 0.94 112 | 111 2 0 0 0 0 1 0.98 19.74 138 1 1.06 0.94 113 | 112 2 68 13 0 0 1 0.975 14.99 138 1 1.06 0.94 114 | 113 2 6 0 0 0 1 0.993 13.74 138 1 1.06 0.94 115 | 114 1 8 3 0 0 1 0.96 14.46 138 1 1.06 0.94 116 | 115 1 22 7 0 0 1 0.96 14.46 138 1 1.06 0.94 117 | 116 2 184 0 0 0 1 1.005 27.12 138 1 1.06 0.94 118 | 117 1 20 8 0 0 1 0.974 10.67 138 1 1.06 0.94 119 | 118 1 33 15 0 0 1 0.949 21.92 138 1 1.06 0.94 -------------------------------------------------------------------------------- /data/01_test_cases/case118/t12_n06/bus_data.txt: -------------------------------------------------------------------------------- 1 | bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 2 | 1 2 51 27 0 0 1 0.955 10.67 138 1 1.06 0.94 3 | 2 1 20 9 0 0 1 0.971 11.22 138 1 1.06 0.94 4 | 3 1 39 10 0 0 1 0.968 11.56 138 1 1.06 0.94 5 | 4 2 39 12 0 0 1 0.998 15.28 138 1 1.06 0.94 6 | 5 1 0 0 0 -40 1 1.002 15.73 138 1 1.06 0.94 7 | 6 2 52 22 0 0 1 0.99 13 138 1 1.06 0.94 8 | 7 1 19 2 0 0 1 0.989 12.56 138 1 1.06 0.94 9 | 8 2 28 0 0 0 1 1.015 20.77 345 1 1.06 0.94 10 | 9 1 0 0 0 0 1 1.043 28.02 345 1 1.06 0.94 11 | 10 2 0 0 0 0 1 1.05 35.61 345 1 1.06 0.94 12 | 11 1 70 23 0 0 1 0.985 12.72 138 1 1.06 0.94 13 | 12 2 47 10 0 0 1 0.99 12.2 138 1 1.06 0.94 14 | 13 1 34 16 0 0 1 0.968 11.35 138 1 1.06 0.94 15 | 14 1 14 1 0 0 1 0.984 11.5 138 1 1.06 0.94 16 | 15 2 90 30 0 0 1 0.97 11.23 138 1 1.06 0.94 17 | 16 1 25 10 0 0 1 0.984 11.91 138 1 1.06 0.94 18 | 17 1 11 3 0 0 1 0.995 13.74 138 1 1.06 0.94 19 | 18 2 60 34 0 0 1 0.973 11.53 138 1 1.06 0.94 20 | 19 2 45 25 0 0 1 0.963 11.05 138 1 1.06 0.94 21 | 20 1 18 3 0 0 1 0.958 11.93 138 1 1.06 0.94 22 | 21 1 14 8 0 0 1 0.959 13.52 138 1 1.06 0.94 23 | 22 1 10 5 0 0 1 0.97 16.08 138 1 1.06 0.94 24 | 23 1 7 3 0 0 1 1 21 138 1 1.06 0.94 25 | 24 2 13 0 0 0 1 0.992 20.89 138 1 1.06 0.94 26 | 25 2 0 0 0 0 1 1.05 27.93 138 1 1.06 0.94 27 | 26 2 0 0 0 0 1 1.015 29.71 345 1 1.06 0.94 28 | 27 2 71 13 0 0 1 0.968 15.35 138 1 1.06 0.94 29 | 28 1 17 7 0 0 1 0.962 13.62 138 1 1.06 0.94 30 | 29 1 24 4 0 0 1 0.963 12.63 138 1 1.06 0.94 31 | 30 1 0 0 0 0 1 0.968 18.79 345 1 1.06 0.94 32 | 31 2 43 27 0 0 1 0.967 12.75 138 1 1.06 0.94 33 | 32 2 59 23 0 0 1 0.964 14.8 138 1 1.06 0.94 34 | 33 1 23 9 0 0 1 0.972 10.63 138 1 1.06 0.94 35 | 34 2 59 26 0 14 1 0.986 11.3 138 1 1.06 0.94 36 | 35 1 33 9 0 0 1 0.981 10.87 138 1 1.06 0.94 37 | 36 2 31 17 0 0 1 0.98 10.87 138 1 1.06 0.94 38 | 37 1 0 0 0 -25 1 0.992 11.77 138 1 1.06 0.94 39 | 38 1 0 0 0 0 1 0.962 16.91 345 1 1.06 0.94 40 | 39 1 27 11 0 0 1 0.97 8.41 138 1 1.06 0.94 41 | 40 2 66 23 0 0 1 0.97 7.35 138 1 1.06 0.94 42 | 41 1 37 10 0 0 1 0.967 6.92 138 1 1.06 0.94 43 | 42 2 96 23 0 0 1 0.985 8.53 138 1 1.06 0.94 44 | 43 1 18 7 0 0 1 0.978 11.28 138 1 1.06 0.94 45 | 44 1 16 8 0 10 1 0.985 13.82 138 1 1.06 0.94 46 | 45 1 53 22 0 10 1 0.987 15.67 138 1 1.06 0.94 47 | 46 2 28 10 0 10 1 1.005 18.49 138 1 1.06 0.94 48 | 47 1 34 0 0 0 1 1.017 20.73 138 1 1.06 0.94 49 | 48 1 20 11 0 15 1 1.021 19.93 138 1 1.06 0.94 50 | 49 2 87 30 0 0 1 1.025 20.94 138 1 1.06 0.94 51 | 50 1 17 4 0 0 1 1.001 18.9 138 1 1.06 0.94 52 | 51 1 17 8 0 0 1 0.967 16.28 138 1 1.06 0.94 53 | 52 1 18 5 0 0 1 0.957 15.32 138 1 1.06 0.94 54 | 53 1 23 11 0 0 1 0.946 14.35 138 1 1.06 0.94 55 | 54 2 113 32 0 0 1 0.955 15.26 138 1 1.06 0.94 56 | 55 2 63 22 0 0 1 0.952 14.97 138 1 1.06 0.94 57 | 56 2 84 18 0 0 1 0.954 15.16 138 1 1.06 0.94 58 | 57 1 12 3 0 0 1 0.971 16.36 138 1 1.06 0.94 59 | 58 1 12 3 0 0 1 0.959 15.51 138 1 1.06 0.94 60 | 59 2 277 113 0 0 1 0.985 19.37 138 1 1.06 0.94 61 | 60 1 78 3 0 0 1 0.993 23.15 138 1 1.06 0.94 62 | 61 2 0 0 0 0 1 0.995 24.04 138 1 1.06 0.94 63 | 62 2 77 14 0 0 1 0.998 23.43 138 1 1.06 0.94 64 | 63 1 0 0 0 0 1 0.969 22.75 345 1 1.06 0.94 65 | 64 1 0 0 0 0 1 0.984 24.52 345 1 1.06 0.94 66 | 65 2 0 0 0 0 1 1.005 27.65 345 1 1.06 0.94 67 | 66 2 39 18 0 0 1 1.05 27.48 138 1 1.06 0.94 68 | 67 1 28 7 0 0 1 1.02 24.84 138 1 1.06 0.94 69 | 68 1 0 0 0 0 1 1.003 27.55 345 1 1.06 0.94 70 | 69 3 0 0 0 0 1 1.035 30 138 1 1.06 0.94 71 | 70 2 66 20 0 0 1 0.984 22.58 138 1 1.06 0.94 72 | 71 1 0 0 0 0 1 0.987 22.15 138 1 1.06 0.94 73 | 72 2 12 0 0 0 1 0.98 20.98 138 1 1.06 0.94 74 | 73 2 6 0 0 0 1 0.991 21.94 138 1 1.06 0.94 75 | 74 2 68 27 0 12 1 0.958 21.64 138 1 1.06 0.94 76 | 75 1 47 11 0 0 1 0.967 22.91 138 1 1.06 0.94 77 | 76 2 68 36 0 0 1 0.943 21.77 138 1 1.06 0.94 78 | 77 2 61 28 0 0 1 1.006 26.72 138 1 1.06 0.94 79 | 78 1 71 26 0 0 1 1.003 26.42 138 1 1.06 0.94 80 | 79 1 39 32 0 20 1 1.009 26.72 138 1 1.06 0.94 81 | 80 2 130 26 0 0 1 1.04 28.96 138 1 1.06 0.94 82 | 81 1 0 0 0 0 1 0.997 28.1 345 1 1.06 0.94 83 | 82 1 54 27 0 20 1 0.989 27.24 138 1 1.06 0.94 84 | 83 1 20 10 0 10 1 0.985 28.42 138 1 1.06 0.94 85 | 84 1 11 7 0 0 1 0.98 30.95 138 1 1.06 0.94 86 | 85 2 24 15 0 0 1 0.985 32.51 138 1 1.06 0.94 87 | 86 1 21 10 0 0 1 0.987 31.14 138 1 1.06 0.94 88 | 87 2 0 0 0 0 1 1.015 31.4 161 1 1.06 0.94 89 | 88 1 48 10 0 0 1 0.987 35.64 138 1 1.06 0.94 90 | 89 2 0 0 0 0 1 1.005 39.69 138 1 1.06 0.94 91 | 90 2 163 42 0 0 1 0.985 33.29 138 1 1.06 0.94 92 | 91 2 10 0 0 0 1 0.98 33.31 138 1 1.06 0.94 93 | 92 2 65 10 0 0 1 0.993 33.8 138 1 1.06 0.94 94 | 93 1 12 7 0 0 1 0.987 30.79 138 1 1.06 0.94 95 | 94 1 30 16 0 0 1 0.991 28.64 138 1 1.06 0.94 96 | 95 1 42 31 0 0 1 0.981 27.67 138 1 1.06 0.94 97 | 96 1 38 15 0 0 1 0.993 27.51 138 1 1.06 0.94 98 | 97 1 15 9 0 0 1 1.011 27.88 138 1 1.06 0.94 99 | 98 1 34 8 0 0 1 1.024 27.4 138 1 1.06 0.94 100 | 99 2 42 0 0 0 1 1.01 27.04 138 1 1.06 0.94 101 | 100 2 37 18 0 0 1 1.017 28.03 138 1 1.06 0.94 102 | 101 1 22 15 0 0 1 0.993 29.61 138 1 1.06 0.94 103 | 102 1 5 3 0 0 1 0.991 32.3 138 1 1.06 0.94 104 | 103 2 23 16 0 0 1 1.001 24.44 138 1 1.06 0.94 105 | 104 2 38 25 0 0 1 0.971 21.69 138 1 1.06 0.94 106 | 105 2 31 26 0 20 1 0.965 20.57 138 1 1.06 0.94 107 | 106 1 43 16 0 0 1 0.962 20.32 138 1 1.06 0.94 108 | 107 2 50 12 0 6 1 0.952 17.53 138 1 1.06 0.94 109 | 108 1 2 1 0 0 1 0.967 19.38 138 1 1.06 0.94 110 | 109 1 8 3 0 0 1 0.967 18.93 138 1 1.06 0.94 111 | 110 2 39 30 0 6 1 0.973 18.09 138 1 1.06 0.94 112 | 111 2 0 0 0 0 1 0.98 19.74 138 1 1.06 0.94 113 | 112 2 68 13 0 0 1 0.975 14.99 138 1 1.06 0.94 114 | 113 2 6 0 0 0 1 0.993 13.74 138 1 1.06 0.94 115 | 114 1 8 3 0 0 1 0.96 14.46 138 1 1.06 0.94 116 | 115 1 22 7 0 0 1 0.96 14.46 138 1 1.06 0.94 117 | 116 2 184 0 0 0 1 1.005 27.12 138 1 1.06 0.94 118 | 117 1 20 8 0 0 1 0.974 10.67 138 1 1.06 0.94 119 | 118 1 33 15 0 0 1 0.949 21.92 138 1 1.06 0.94 -------------------------------------------------------------------------------- /sddip/session.py: -------------------------------------------------------------------------------- 1 | """Execute a test session.""" 2 | 3 | import logging 4 | import random as rdm 5 | import time 6 | import zoneinfo 7 | from dataclasses import dataclass, field 8 | from datetime import datetime as dt 9 | from pathlib import Path 10 | from typing import Any, Literal 11 | 12 | from sddip import config 13 | from sddip.sddip import ( 14 | common, 15 | dualsolver, 16 | sddipclassical, 17 | sddipdynamic, 18 | ) 19 | 20 | logger = logging.getLogger(__name__) 21 | 22 | type Seed = int | float | str | bytes | bytearray | None 23 | 24 | @dataclass 25 | class TestSetup: 26 | name: str 27 | path: Path 28 | algorithm: Literal["sddip", "dsddip"] 29 | 30 | sddip_n_binaries: int = field(default=5) 31 | 32 | sddip_max_iterations: int = field(default=100) 33 | sddip_time_limit: int = field(default=5 * 60) 34 | 35 | sddip_refinment_stabilization_count: int = field(default=5) 36 | sddip_stop_stabilization_count: int = field(default=1000) 37 | 38 | sddip_no_improvement_tolerance: float = field(default=10**-6) 39 | 40 | sddip_primary_cut_type: str = field(default="sb") 41 | sddip_n_samples_primary: int = field(default=3) 42 | sddip_secondary_cut_type: str = field(default="l") 43 | sddip_n_samples_secondary: int = field(default=1) 44 | 45 | sddip_projection_big_m: float = field(default=10**4) 46 | 47 | sddip_n_samples_final_ub: int = field(default=300) 48 | 49 | dual_solver_stop_tolerance: float = field(default=10**-6) 50 | dual_solver_time_limit: int = field(default=5 * 60) 51 | dual_solver_max_iterations: int = field(default=5000) 52 | 53 | seed: Seed = field(default_factory=lambda: int(time.time())) 54 | 55 | @classmethod 56 | def from_dict(cls, d: dict[str, Any], /) -> "TestSetup": 57 | """Create a `TestSetup` object from a dictionary.""" 58 | d["path"] = Path(d["path"]) 59 | return cls(**d) 60 | 61 | 62 | Setup = list[TestSetup] 63 | 64 | 65 | 66 | def start(setup: Setup, seed: Seed=None) -> None: 67 | """Start the test session.""" 68 | log_manager = LogManager() 69 | for _test_setup in setup: 70 | start_time_str = dt.now( 71 | tz=zoneinfo.ZoneInfo("Europe/Berlin") 72 | ).strftime("%Y%m%d%H%M%S") 73 | results_dir = ( 74 | config.RESULTS_DIR / f"{start_time_str}_{_test_setup.name}" 75 | ) 76 | results_dir.mkdir(parents=True, exist_ok=True) 77 | log_manager.set_up_logger(results_dir / "sddip.log") 78 | 79 | if seed is not None: 80 | _test_setup.seed = seed 81 | 82 | run(_test_setup, str(results_dir)) 83 | 84 | 85 | def run(setup: TestSetup, results_dir: str) -> None: 86 | """Execute a single test.""" 87 | logger.info("Test case: %s", setup.name) 88 | logger.info("Seed: %s", setup.seed) 89 | rdm.seed(setup.seed) 90 | 91 | dual_solver = dualsolver.BundleMethod( 92 | setup.dual_solver_max_iterations, 93 | setup.dual_solver_stop_tolerance, 94 | results_dir, 95 | predicted_ascent="abs", 96 | time_limit=setup.dual_solver_time_limit, 97 | ) 98 | 99 | match setup.algorithm: 100 | case "sddip": 101 | algo = sddipclassical.Algorithm( 102 | setup.path, 103 | results_dir, 104 | dual_solver=dual_solver, 105 | ) 106 | case "dsddip": 107 | algo = sddipdynamic.Algorithm( 108 | setup.path, 109 | results_dir, 110 | dual_solver=dual_solver, 111 | ) 112 | algo.big_m = setup.sddip_projection_big_m 113 | algo.refinement_stabilization_count = ( 114 | setup.sddip_refinment_stabilization_count 115 | ) 116 | algo.sos = False 117 | 118 | algo.n_binaries = setup.sddip_n_binaries 119 | 120 | algo.primary_cut_mode = common.CutType.from_str( 121 | setup.sddip_primary_cut_type 122 | ) 123 | algo.n_samples_primary = setup.sddip_n_samples_primary 124 | algo.secondary_cut_mode = common.CutType.from_str( 125 | setup.sddip_secondary_cut_type 126 | ) 127 | algo.n_samples_secondary = setup.sddip_n_samples_secondary 128 | 129 | algo.time_limit_minutes = setup.sddip_time_limit 130 | 131 | # Tolerance over which an increase in the lower bound is considered 132 | # as an improvement. 133 | algo.no_improvement_tolerance = setup.sddip_no_improvement_tolerance 134 | 135 | # Number of iterations after an non-improving lower bound is 136 | # considered stabilized. 137 | algo.stop_stabilization_count = setup.sddip_stop_stabilization_count 138 | algo.n_samples_final_ub = setup.sddip_n_samples_final_ub 139 | 140 | # Execution 141 | try: 142 | algo.run(setup.sddip_max_iterations) 143 | except KeyboardInterrupt: 144 | logger.warning("Shutdown request received. Exiting...") 145 | raise 146 | except Exception: 147 | logger.exception("Execution failed: %s") 148 | finally: 149 | try: 150 | # Manage results 151 | algo.bound_storage.export_results(results_dir) 152 | algo.ps_storage.export_results(results_dir) 153 | algo.ds_storage.export_results(results_dir) 154 | algo.dual_solver_storage.export_results(results_dir) 155 | 156 | if common.CutType.LAGRANGIAN in algo.cut_types_added: 157 | algo.cc_storage.export_results(results_dir) 158 | if algo.cut_types_added - {common.CutType.LAGRANGIAN}: 159 | algo.bc_storage.export_results(results_dir) 160 | 161 | except Exception: 162 | logger.exception("Export incomplete: %s") 163 | raise 164 | 165 | time.sleep(1) 166 | 167 | 168 | class LogManager: 169 | def __init__(self) -> None: 170 | self._fh: logging.FileHandler | None = None 171 | 172 | def set_up_logger(self, path: Path) -> None: 173 | """Set up logger.""" 174 | logger = logging.getLogger("sddip") 175 | if self._fh: 176 | logger.removeHandler(self._fh) 177 | self._fh = logging.FileHandler(path) 178 | logger.addHandler(self._fh) 179 | -------------------------------------------------------------------------------- /sddip/cli.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import contextlib 3 | import logging 4 | import logging.config 5 | import tomllib 6 | from pathlib import Path 7 | 8 | import sddip 9 | from sddip import session 10 | 11 | from .operators import extensive_runner 12 | from .scripts import ( 13 | clear_result_directories, 14 | copy_raw, 15 | create_scenarios, 16 | create_supplementary, 17 | gather_latest_results, 18 | ) 19 | 20 | logger = logging.getLogger(__name__) 21 | 22 | 23 | def main(argv: list[str]) -> None: 24 | """Run the command line interface.""" 25 | args = _parse_arguments(argv) 26 | 27 | match args.command: 28 | case "create": 29 | _init_logging(args.verbose, nofile=True) 30 | _create(args) 31 | case "sweep": 32 | _init_logging(args.verbose, nofile=True) 33 | _sweep(args) 34 | case _: 35 | _init_logging(args.verbose) 36 | logger.info("Execute SDDIP module") 37 | if args.extensive: 38 | logger.info("Start extensive model") 39 | extensive_runner.main() 40 | else: 41 | session_config = _load_session(args.session) 42 | logger.info("Start test session") 43 | session.start(setup=session_config, seed=args.seed) 44 | logger.info("Execution completed") 45 | 46 | 47 | def _parse_arguments(argv: list[str]) -> argparse.Namespace: 48 | """Parse the command line arguments.""" 49 | parser = _create_argument_parser() 50 | return parser.parse_args(argv) 51 | 52 | 53 | def _create_argument_parser() -> argparse.ArgumentParser: 54 | """Create an argument parser for the command line interface.""" 55 | parser = argparse.ArgumentParser(description="Dynamic SDDIP") 56 | 57 | parser.add_argument( 58 | "--session", 59 | type=Path, 60 | default="sessions/demo.toml", 61 | help="Path to the TOML file containing the session config", 62 | ) 63 | parser.add_argument( 64 | "--seed", 65 | type=str, 66 | default=None, 67 | help="Seed for the random number generator", 68 | ) 69 | parser.add_argument( 70 | "--extensive", 71 | action="store_true", 72 | help="Run script to solve the extensive model", 73 | ) 74 | parser.add_argument( 75 | "--verbose", action="store_true", help="Enable verbose logging" 76 | ) 77 | 78 | subparsers = parser.add_subparsers( 79 | title="Auxiliary functions", dest="command" 80 | ) 81 | 82 | create_sp = subparsers.add_parser( 83 | "create", help="Create data for a new test case" 84 | ) 85 | create_sp.add_argument( 86 | "--test-case", 87 | type=Path, 88 | required=True, 89 | default=None, 90 | help="Directory for test case data", 91 | ) 92 | create_sp.add_argument( 93 | "--test-base", 94 | type=Path, 95 | default=None, 96 | help="Directory with basic data for a test case", 97 | ) 98 | create_sp.add_argument( 99 | "--stages", "-t", type=int, default=None, help="Number of stages" 100 | ) 101 | create_sp.add_argument( 102 | "--realizations", 103 | "-n", 104 | type=int, 105 | default=None, 106 | help="Number of realizations per stage", 107 | ) 108 | create_sp.add_argument( 109 | "--supplementary", 110 | action="store_true", 111 | required=False, 112 | help="Create supplementary data only", 113 | ) 114 | 115 | sweep_sp = subparsers.add_parser("sweep", help="Sweep results") 116 | sweep_sp.add_argument( 117 | "--gather", action="store_true", help="Gather results" 118 | ) 119 | sweep_sp.add_argument( 120 | "--clean", action="store_true", help="Clean result directories" 121 | ) 122 | 123 | return parser 124 | 125 | 126 | def _init_logging(verbose: bool = False, nofile: bool = False) -> None: 127 | """Initialize the logging.""" 128 | loggers = sddip.logging.config["loggers"] 129 | if verbose: 130 | for l in loggers.values(): 131 | l["level"] = "DEBUG" 132 | if nofile: 133 | sddip.logging.config["handlers"].pop("file") 134 | for l in loggers.values(): 135 | handlers = l["handlers"] 136 | with contextlib.suppress(ValueError): 137 | handlers.remove("file") 138 | else: 139 | sddip.logging.create_logging_dir() 140 | 141 | logging.config.dictConfig(sddip.logging.config) 142 | 143 | 144 | def _load_session(path: Path) -> session.Setup: 145 | """Load the list of tests to run from the schedule file.""" 146 | with path.open("rb") as f: 147 | setup = tomllib.load(f) 148 | 149 | tests = setup.get("tests") 150 | 151 | if not tests: 152 | msg = "No test config found." 153 | raise Exception(msg) 154 | 155 | return [session.TestSetup.from_dict(case) for case in tests["cases"]] 156 | 157 | 158 | def _create(args: argparse.Namespace) -> None: 159 | """Create data for a new test case.""" 160 | if args.supplementary: 161 | create_supplementary.create_supplementary_data( 162 | source_dir=args.test_base or args.test_case, 163 | target_dir=args.test_case, 164 | ) 165 | elif args.stages and args.realizations: 166 | create_scenarios.create_scenario_data( 167 | args.stages, args.realizations, args.test_case, args.test_base 168 | ) 169 | create_supplementary.create_supplementary_data( 170 | source_dir=args.test_base or args.test_case, 171 | target_dir=args.test_case, 172 | ) 173 | else: 174 | msg = "Invalid arguments for number of stages and realizations." 175 | raise ValueError(msg) 176 | 177 | if args.test_base: 178 | copy_raw.move_files(args.test_base, args.test_case) 179 | 180 | 181 | def _sweep(args: argparse.Namespace) -> None: 182 | """Sweep results.""" 183 | if args.gather: 184 | gather_latest_results.main() 185 | elif args.clean: 186 | clear_result_directories.main() 187 | else: 188 | msg = "Invalid arguments for sweep command." 189 | raise ValueError(msg) 190 | -------------------------------------------------------------------------------- /sddip/sddip/ucmodelclassical.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import gurobipy as gp 4 | 5 | from .ucmodeldynamic import BackwardModelBuilder 6 | 7 | logger = logging.getLogger(__name__) 8 | 9 | 10 | class ClassicalModel(BackwardModelBuilder): 11 | def __init__( 12 | self, 13 | n_buses: int, 14 | n_lines: int, 15 | n_generators: int, 16 | n_storages: int, 17 | generators_at_bus: list, 18 | storages_at_bus: list, 19 | backsight_periods: list, 20 | lp_relax: bool = False, 21 | ) -> None: 22 | super().__init__( 23 | n_buses, 24 | n_lines, 25 | n_generators, 26 | n_storages, 27 | generators_at_bus, 28 | storages_at_bus, 29 | backsight_periods, 30 | lp_relax, 31 | ) 32 | self.lp_relax = lp_relax 33 | 34 | def binary_approximation( 35 | self, y_bin_multipliers, soc_bin_multipliers 36 | ) -> None: 37 | self.y_bin_states = [] 38 | self.soc_bin_states = [] 39 | n_y_bin_vars = [len(bin_mult) for bin_mult in y_bin_multipliers] 40 | n_soc_bin_vars = [len(bin_mult) for bin_mult in soc_bin_multipliers] 41 | 42 | var_type = gp.GRB.CONTINUOUS if self.lp_relax else gp.GRB.BINARY 43 | 44 | g = 1 45 | for n_y in n_y_bin_vars: 46 | self.y_bin_states.append( 47 | self.model.addVars( 48 | n_y, vtype=var_type, lb=0, ub=1, name=f"y_bin_{g}" 49 | ) 50 | ) 51 | g += 1 52 | 53 | s = 1 54 | for n_soc in n_soc_bin_vars: 55 | self.soc_bin_states.append( 56 | self.model.addVars( 57 | n_soc, vtype=var_type, lb=0, ub=1, name=f"soc_bin_{s}" 58 | ) 59 | ) 60 | s += 1 61 | 62 | self.y_bin_states_flattened = [ 63 | y_bin_var 64 | for y_tuple_dict in self.y_bin_states 65 | for y_bin_var in y_tuple_dict.values() 66 | ] 67 | 68 | self.soc_bin_states_flattened = [ 69 | soc_bin_var 70 | for soc_tuple_dict in self.soc_bin_states 71 | for soc_bin_var in soc_tuple_dict.values() 72 | ] 73 | 74 | self.model.addConstrs( 75 | ( 76 | gp.LinExpr( 77 | y_bin_multipliers[g], self.y_bin_states[g].select("*") 78 | ) 79 | == self.y[g] 80 | for g in range(self.n_generators) 81 | ), 82 | name="y_bin_appr", 83 | ) 84 | 85 | self.model.addConstrs( 86 | ( 87 | gp.LinExpr( 88 | soc_bin_multipliers[s], self.soc_bin_states[s].select("*") 89 | ) 90 | == self.soc[s] 91 | for s in range(self.n_storages) 92 | ), 93 | name="soc_bin_appr", 94 | ) 95 | self.update_model() 96 | 97 | def add_sddip_copy_constraints( 98 | self, 99 | x_binary_trial_point: list, 100 | y_binary_trial_point: list, 101 | x_bs_binary_trial_point: list[list], 102 | soc_binary_trial_point: list, 103 | ) -> None: 104 | self.add_relaxation( 105 | x_binary_trial_point, 106 | y_binary_trial_point, 107 | x_bs_binary_trial_point, 108 | soc_binary_trial_point, 109 | ) 110 | self.sddip_copy_constrs = [] 111 | for term in self.relaxed_terms: 112 | self.sddip_copy_constrs.append( 113 | self.model.addConstr(term == 0, "sddip-copy") 114 | ) 115 | 116 | def relax_sddip_copy_constraints( 117 | self, 118 | x_binary_trial_point: list, 119 | y_binary_trial_point: list, 120 | x_bs_binary_trial_point: list[list], 121 | soc_binary_trial_point: list, 122 | ) -> None: 123 | self.add_relaxation( 124 | x_binary_trial_point, 125 | y_binary_trial_point, 126 | x_bs_binary_trial_point, 127 | soc_binary_trial_point, 128 | ) 129 | 130 | def add_cut_constraints( 131 | self, 132 | cut_intercepts: list, 133 | cut_gradients: list, 134 | ) -> None: 135 | state_variables = ( 136 | self.x 137 | + self.y_bin_states_flattened 138 | + [var for gen_bs in self.x_bs for var in gen_bs] 139 | + self.soc_bin_states_flattened 140 | ) 141 | 142 | id = 0 143 | for intercept, gradient in zip( 144 | cut_intercepts, cut_gradients, strict=False 145 | ): 146 | # Cut constraint 147 | self.model.addConstr( 148 | ( 149 | self.theta 150 | >= intercept + gp.LinExpr(gradient, state_variables) 151 | ), 152 | f"cut_{id}", 153 | ) 154 | id += 1 155 | 156 | def add_benders_cuts( 157 | self, cut_intercepts: list, cut_gradients: list, trial_points: list 158 | ) -> None: 159 | state_variables = ( 160 | self.x 161 | + self.y_bin_states_flattened 162 | + [var for gen_bs in self.x_bs for var in gen_bs] 163 | + self.soc_bin_states_flattened 164 | ) 165 | 166 | n_state_variables = len(state_variables) 167 | 168 | for intercept, gradient, trial_point in zip( 169 | cut_intercepts, cut_gradients, trial_points, strict=False 170 | ): 171 | if n_state_variables != len(trial_point): 172 | logger.warning("Trial point: %s", trial_point) 173 | msg = "Number of state variables must be equal to the number of trial points." 174 | raise ValueError(msg) 175 | 176 | self.model.addConstr( 177 | ( 178 | self.theta 179 | >= intercept 180 | + gp.quicksum( 181 | gradient[i] * (state_variables[i] - trial_point[i]) 182 | for i in range(n_state_variables) 183 | ) 184 | ), 185 | "cut", 186 | ) 187 | -------------------------------------------------------------------------------- /data/01_test_cases/WB5/t12_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd5 Pd2 Pd3 Pd4 Re1 Re2 Re3 Re4 Re5 2 | 1 1 1.0 0 0 102.6693428160126 100.69991990938561 55.120494165844235 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 82.81068037717948 85.24076602637386 40.58141042560221 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 69.5377760227248 83.72365460183549 32.21182215902832 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 70.45922727122843 72.33685622493608 35.913286958168015 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 64.12969941874081 75.07123781476103 35.700744693022614 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 84.1626683555114 78.64630141338965 40.22589488039637 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 66.98205945458426 86.54199597732259 31.431917919431115 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 81.02330081326308 88.50815094794594 34.250314663171366 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 80.60164238294708 85.74968826348886 47.42074020348023 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 93.81336149458953 84.51366007397267 45.545239388729044 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 96.4006982430463 73.21417994903219 36.627269773461975 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 71.26766120349859 86.55895806049512 46.42640956011163 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 71.14273983471888 92.33757639164469 46.75155888221136 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 148.71245254214296 174.5635489501382 85.92708492220788 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 195.14561559425707 205.16332290255366 96.34204865758811 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 147.27675171033556 163.0841536542256 94.88941924630907 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 193.53206103103858 158.45103648255053 100.3160992739578 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 142.06213600244223 165.40565866193927 71.4137434381739 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 159.42982930773275 146.0718482469365 98.15350275357383 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 256.9634420335432 261.7567861024066 106.80871483116921 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 259.57800676742954 182.64009597518495 110.20782242525244 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 197.41247967154624 221.68337072140034 120.05741492737593 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 223.7377947813113 189.58351375655795 104.01064728986323 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 260.70913266105805 220.7265839170461 118.51511044910325 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 183.7524540368582 234.08579031197655 116.50835150930097 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 202.30405397047133 251.24258975805634 110.70066764145231 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 244.59192713919072 255.40137346279533 109.65435382207207 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 190.8657035384028 260.19957258285524 100.93646643477388 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 238.2039332566859 251.34112939230695 84.45265446853114 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 253.21452660168688 194.176915294797 95.33395584992408 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 215.3776798319255 181.18979301147883 89.25156134651044 0 0 0 0 0 33 | 7 1 0.16666666666666666 0 0 200.8289267339839 271.5762704836466 127.89649990789269 0 0 0 0 0 34 | 7 2 0.16666666666666666 0 0 201.64796472331383 216.01482209197437 111.94853129956404 0 0 0 0 0 35 | 7 3 0.16666666666666666 0 0 266.4300952971724 222.13715574467088 129.40470796381635 0 0 0 0 0 36 | 7 4 0.16666666666666666 0 0 237.60530616703696 202.78754956523525 93.55237671035276 0 0 0 0 0 37 | 7 5 0.16666666666666666 0 0 274.9855183985903 272.8012288859887 112.14111303685507 0 0 0 0 0 38 | 7 6 0.16666666666666666 0 0 216.00421083628657 207.19980010154825 112.55150442277002 0 0 0 0 0 39 | 8 1 0.16666666666666666 0 0 188.1581436582387 212.42483988429905 80.38888010870083 0 0 0 0 0 40 | 8 2 0.16666666666666666 0 0 197.36968231270325 208.62870158227804 74.80024100555305 0 0 0 0 0 41 | 8 3 0.16666666666666666 0 0 214.67572421669604 156.68975544891944 93.50349417674526 0 0 0 0 0 42 | 8 4 0.16666666666666666 0 0 165.59330625657554 216.06385634979915 87.83020963272132 0 0 0 0 0 43 | 8 5 0.16666666666666666 0 0 200.42044701411598 177.83699962739155 88.49414729684838 0 0 0 0 0 44 | 8 6 0.16666666666666666 0 0 192.74754657157268 173.12514780848787 101.10920769044209 0 0 0 0 0 45 | 9 1 0.16666666666666666 0 0 186.3307448034033 176.6602857349771 73.58494146719909 0 0 0 0 0 46 | 9 2 0.16666666666666666 0 0 155.89884343178662 168.81008499621436 94.09763623769385 0 0 0 0 0 47 | 9 3 0.16666666666666666 0 0 161.83500890619825 167.04852240735477 97.04646830107521 0 0 0 0 0 48 | 9 4 0.16666666666666666 0 0 146.84423833111885 151.8048277897078 82.64105396250854 0 0 0 0 0 49 | 9 5 0.16666666666666666 0 0 176.75809445301334 160.4716412467687 89.66948337951379 0 0 0 0 0 50 | 9 6 0.16666666666666666 0 0 166.72900098758316 179.6976490542874 92.86772704515633 0 0 0 0 0 51 | 10 1 0.16666666666666666 0 0 237.34218683934435 274.2612361180021 94.07764571596455 0 0 0 0 0 52 | 10 2 0.16666666666666666 0 0 230.9031158557638 282.1077434697147 122.27681237022355 0 0 0 0 0 53 | 10 3 0.16666666666666666 0 0 210.20003124459615 207.42072623509154 119.57507505160659 0 0 0 0 0 54 | 10 4 0.16666666666666666 0 0 224.77764261230206 236.02527311608614 107.66739282136415 0 0 0 0 0 55 | 10 5 0.16666666666666666 0 0 271.990486721169 190.7512197530241 102.97122209850404 0 0 0 0 0 56 | 10 6 0.16666666666666666 0 0 222.33940957375944 234.77903038892111 114.89029475331374 0 0 0 0 0 57 | 11 1 0.16666666666666666 0 0 212.97771197831798 221.60968689724467 126.4031396392222 0 0 0 0 0 58 | 11 2 0.16666666666666666 0 0 276.8749850755002 236.31476481116383 130.43277349216987 0 0 0 0 0 59 | 11 3 0.16666666666666666 0 0 230.08163151064443 206.79346408469485 143.46353538217767 0 0 0 0 0 60 | 11 4 0.16666666666666666 0 0 259.96191103412076 292.7695297079581 123.64626984587514 0 0 0 0 0 61 | 11 5 0.16666666666666666 0 0 223.8270818432593 261.57608326864 118.86690528619438 0 0 0 0 0 62 | 11 6 0.16666666666666666 0 0 203.92965254590007 231.6078394100835 138.07174112042384 0 0 0 0 0 63 | 12 1 0.16666666666666666 0 0 217.8255706826856 208.71397655112213 90.83955807362233 0 0 0 0 0 64 | 12 2 0.16666666666666666 0 0 188.2432906250894 171.24173712281097 97.02461992239773 0 0 0 0 0 65 | 12 3 0.16666666666666666 0 0 234.56460326956213 232.63424212704786 111.2504686875159 0 0 0 0 0 66 | 12 4 0.16666666666666666 0 0 201.71840373451323 182.17831136745 102.05233830078866 0 0 0 0 0 67 | 12 5 0.16666666666666666 0 0 220.99123430550617 237.46770657355748 78.72681231469335 0 0 0 0 0 68 | 12 6 0.16666666666666666 0 0 195.53616388807697 163.79935322337406 92.57262124964709 0 0 0 0 0 69 | -------------------------------------------------------------------------------- /data/01_test_cases/case14/t06_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd7 Pd8 Pd2 Pd3 Pd4 Pd5 Pd6 Pd9 Pd10 Pd11 Pd12 Pd13 Pd14 Re1 Re2 Re3 Re4 Re5 Re6 Re7 Re8 Re9 Re10 Re11 Re12 Re13 Re14 2 | 1 1 1.0 0 0 0 12.560373013421032 80.20858517236061 29.074088093188266 2.2719715810814707 5.512902455709789 19.095886663721902 3.0810611020426357 0.0 0.9286923970791154 6.27846368348872 6.830170439978324 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 | 2 1 0.16666666666666666 0 0 0 16.306793914863214 91.14384543480237 49.31809174937077 3.5959954764762214 7.082808851705793 31.615180733229703 4.724148280386673 0.0 1.4484103211142947 10.03107319116811 13.079800767674485 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 | 2 2 0.16666666666666666 0 0 0 22.03665999958991 101.9663001758613 53.378599442115316 3.2151611811767644 8.364204908835182 29.32041151958099 4.843231811770975 0.0 1.3314067225383235 10.863322071713135 10.667105754889581 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 2 3 0.16666666666666666 0 0 0 16.47987587441726 94.51676304668044 52.02224019433442 3.436077322083386 6.75104177670499 28.50547843363472 3.7955832132997345 0.0 1.0289993817085403 11.29726373647885 12.78434394040385 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 2 4 0.16666666666666666 0 0 0 19.264632231570015 88.17498116588212 58.447190660192135 3.5525939063800593 7.856729870383946 23.47580088894091 4.926446170235846 0.0 1.3943810920730857 8.291624909871901 11.903485001681334 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 2 5 0.16666666666666666 0 0 0 15.855396713102529 114.62224637181089 58.139106899206716 2.551624293115249 8.541762135891585 28.424797992757558 4.303443139782972 0.0 1.1574321538261092 9.972115271856504 13.099024345763386 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 | 2 6 0.16666666666666666 0 0 0 20.182846235821287 90.2604710239951 46.09981285556814 3.388725762142123 8.369525261406128 33.38376042279985 4.847484887057707 0.0 1.0888552672529206 10.304596914036855 13.53011142152001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 | 3 1 0.16666666666666666 0 0 0 31.11443388897438 195.5491157529793 90.14163558091855 6.034970793120137 14.46752279787988 47.00944213056822 8.609383000372008 0.0 2.001416994436249 17.19516441197587 22.1548747823545 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 | 3 2 0.16666666666666666 0 0 0 38.52651870723048 208.10160341803635 89.25430147534748 5.971780633605585 10.033968735452532 47.20649850063294 8.344902365758998 0.0 1.8443235832245846 16.209350610844904 22.20474170110196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 | 3 3 0.16666666666666666 0 0 0 27.902014450208604 171.3568395324566 91.31356840460887 5.487362305374318 12.00966423226339 51.26661934097094 6.621373451949918 0.0 1.7982688638286033 14.680869024339065 21.546928814698372 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | 3 4 0.16666666666666666 0 0 0 27.829482130339642 147.56698621245405 81.80688058275815 5.796740173011288 11.050910014831974 42.188544106216256 9.063883380861801 0.0 2.362114606104072 16.74168347119123 16.27720332848244 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | 3 5 0.16666666666666666 0 0 0 36.43493834210141 186.89963854957966 83.17158260909154 5.706907421351698 9.777335008538737 50.70910020170568 8.741130071481093 0.0 2.415962424631886 13.791213451163955 20.137062410536203 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | 3 6 0.16666666666666666 0 0 0 32.62179310795422 139.64519038129646 76.80694614807959 4.204999933417301 12.225418464040452 56.92808198709951 9.322182496198959 0.0 2.002684951171578 15.476465940272519 19.558249024000617 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 | 4 1 0.16666666666666666 0 0 0 36.58991064068064 160.55242485812192 68.4902058333854 5.209299756173823 13.441745319680225 55.03414772716979 6.354674460148265 0.0 2.3470741624017144 18.581676066140158 15.944878913715442 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 | 4 2 0.16666666666666666 0 0 0 30.79212025886659 172.07695031456808 69.08901982115015 5.051980664321681 9.949580057397682 42.87024990892046 7.867931335851321 0.0 2.233301222777871 19.590138144107605 20.141960324767716 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 | 4 3 0.16666666666666666 0 0 0 34.523915786685016 202.62918033045776 66.6172955283833 4.766162558505806 9.840745243090291 39.47033921810709 8.538287135894208 0.0 2.0593171497821294 15.48169168298557 18.295270281824745 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 | 4 4 0.16666666666666666 0 0 0 29.598355822760496 185.81489437433441 69.13729513315175 5.046844395593379 12.392107624124304 48.79685387713242 6.189869533934965 0.0 2.05020322787832 18.703649263180516 16.130867896820654 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 | 4 5 0.16666666666666666 0 0 0 37.2880804314867 157.36009773520973 94.43532090654764 4.713092106956555 10.19658452368664 40.10446317582277 6.6219913297421655 0.0 2.5384855471181735 18.607551329987594 16.91441996548082 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 | 4 6 0.16666666666666666 0 0 0 36.32589743859319 174.0941876377976 90.49087024592342 4.588910718437558 10.403445934526001 40.29658078831136 7.712910243591019 0.0 2.2428792176731887 17.220653075076626 15.313415030729868 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 | 5 1 0.16666666666666666 0 0 0 30.957924767401504 187.60654298476095 65.51392185541282 4.112171792326522 10.19941764558909 37.413934464308625 7.601754900680971 0.0 2.4098651610254476 16.050712856839827 19.34221704185371 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22 | 5 2 0.16666666666666666 0 0 0 36.46268968999828 142.35240104521878 84.29531644954373 4.526855370854935 10.071385462231593 45.007873416746754 6.412003260396627 0.0 1.7176725843032792 14.89567609569402 21.29831794786674 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 | 5 3 0.16666666666666666 0 0 0 32.00523306095788 144.50800216605074 77.36297704613756 4.751312114831522 11.786643796635541 39.509978055982195 8.496952812351104 0.0 2.452245503708047 18.132233235277376 16.00440774220562 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24 | 5 4 0.16666666666666666 0 0 0 30.02171343811965 134.46043604722666 67.37318983528341 5.684408849592306 13.694812152249892 48.3191287204757 7.4239766149302575 0.0 1.8267996442498653 14.980163808773865 15.549749606423342 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 | 5 5 0.16666666666666666 0 0 0 30.03251909882603 169.7638253048696 70.81413295294708 4.423844116337363 9.900054314183604 40.58685035072979 7.84380014494041 0.0 1.943813259446598 17.909531072072337 18.782362510663983 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 | 5 6 0.16666666666666666 0 0 0 29.530558092595392 184.55148768081995 73.40322816266074 4.96516480657089 13.001148182249274 41.35814150376987 8.971808603233775 0.0 2.03553645237976 15.5591679579147 16.842144715623142 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27 | 6 1 0.16666666666666666 0 0 0 39.70288465995955 208.96782594004495 80.99495563046112 5.183080432942203 10.731411458251705 49.948658790555996 7.09581484516908 0.0 1.7935367169923295 15.776393211284866 19.049112625106762 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 | 6 2 0.16666666666666666 0 0 0 28.068712212668125 207.45379689340308 89.35414387355637 4.358158649262061 11.776019605143878 49.26827439872277 7.791889051392108 0.0 1.9909313652139669 14.311292714931243 17.756908308128217 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 | 6 3 0.16666666666666666 0 0 0 37.004592758255924 178.95317095522643 70.28751760398676 5.539484154842839 10.40646974467244 49.26528394899042 8.621814752112561 0.0 1.8185381456403154 13.613659009363051 17.38936947196859 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 | 6 4 0.16666666666666666 0 0 0 33.57085130670534 209.41745780687614 101.44647239585845 6.085586663640422 14.115058577037978 46.80218579095327 7.850560596323917 0.0 2.369455194021319 19.62076849737066 20.968580938762063 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 | 6 5 0.16666666666666666 0 0 0 28.361762904445786 162.48940855694903 91.49808702881933 5.947085033819519 13.25560816720811 54.21473565857882 7.644176342158768 0.0 1.9641549822224311 19.146461284688726 21.98230781414997 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 | 6 6 0.16666666666666666 0 0 0 26.92991852790883 155.8341388134857 74.51348831946005 4.299086853398992 13.064679880677053 54.98725335448167 9.018626121988586 0.0 2.0831269885880452 17.235123163240537 22.04179872386215 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33 | -------------------------------------------------------------------------------- /data/01_test_cases/case6ww/t12_n06/scenario_data.txt: -------------------------------------------------------------------------------- 1 | t n p Pd1 Pd2 Pd3 Pd4 Pd5 Pd6 Re1 Re3 Re4 Re5 Re6 Re2 2 | 1 1 1.0 0 0 0 53.09480150659728 48.42704410437854 46.442219045383915 0 0 0 0 0 0.0 3 | 2 1 0.16666666666666666 0 0 0 32.17722859695114 33.585497777481734 38.49537338908876 0 0 0 0 0 17.77042741702926 4 | 2 2 0.16666666666666666 0 0 0 34.28860807104187 31.55144588492233 38.92360731121274 0 0 0 0 0 20.996949444229855 5 | 2 3 0.16666666666666666 0 0 0 37.58473734536137 40.795342084374944 46.438530292117115 0 0 0 0 0 17.720665314951262 6 | 2 4 0.16666666666666666 0 0 0 39.67393979343163 42.49405032620574 42.144256294991806 0 0 0 0 0 23.776759942336998 7 | 2 5 0.16666666666666666 0 0 0 35.89624126268521 38.614297543543884 36.392757225591005 0 0 0 0 0 21.636561532256547 8 | 2 6 0.16666666666666666 0 0 0 43.98212380753767 38.08049771972337 32.2844136871515 0 0 0 0 0 22.047707106125937 9 | 3 1 0.16666666666666666 0 0 0 36.36257540025791 45.191011185180955 41.508871658887855 0 0 0 0 0 37.1740515714373 10 | 3 2 0.16666666666666666 0 0 0 37.48554527641889 41.930881407439884 51.60079366810284 0 0 0 0 0 43.229511858838634 11 | 3 3 0.16666666666666666 0 0 0 39.98841757849486 43.546722375846244 51.16581176236665 0 0 0 0 0 44.502235741721826 12 | 3 4 0.16666666666666666 0 0 0 38.33507053070154 36.01760044328176 35.53855692691873 0 0 0 0 0 34.394693809525194 13 | 3 5 0.16666666666666666 0 0 0 42.742944255774766 48.429954363209085 48.63343658149572 0 0 0 0 0 45.65411688620629 14 | 3 6 0.16666666666666666 0 0 0 41.572875107656515 36.923185935028265 49.95690385479886 0 0 0 0 0 48.704972646148654 15 | 4 1 0.16666666666666666 0 0 0 105.63359871072026 87.96760925404107 74.4623315250501 0 0 0 0 0 21.15913234457393 16 | 4 2 0.16666666666666666 0 0 0 74.65863613783874 104.23046960124458 106.31826746223562 0 0 0 0 0 17.414006303433702 17 | 4 3 0.16666666666666666 0 0 0 85.33792740536548 74.6918533337078 89.5228199976312 0 0 0 0 0 17.23878904308121 18 | 4 4 0.16666666666666666 0 0 0 98.75313332917858 85.85889641577967 84.52160146338265 0 0 0 0 0 24.54930536855083 19 | 4 5 0.16666666666666666 0 0 0 78.35613879444372 78.26839049167879 84.33469191104092 0 0 0 0 0 21.31707906444636 20 | 4 6 0.16666666666666666 0 0 0 77.84159764488132 106.85706012479696 88.0788321948807 0 0 0 0 0 17.775460311813333 21 | 5 1 0.16666666666666666 0 0 0 112.69494291391058 104.75535685450464 110.65956528651013 0 0 0 0 0 34.95902433629403 22 | 5 2 0.16666666666666666 0 0 0 96.18328028645828 117.50952093442928 136.02146437230698 0 0 0 0 0 40.07600224521904 23 | 5 3 0.16666666666666666 0 0 0 105.9641878640438 105.8052463230392 128.2391105006857 0 0 0 0 0 45.54191174736717 24 | 5 4 0.16666666666666666 0 0 0 114.97258845772927 106.9058094594846 106.08501781330068 0 0 0 0 0 47.00060766410758 25 | 5 5 0.16666666666666666 0 0 0 127.72538249233048 108.0047762732205 104.75256103641397 0 0 0 0 0 43.161289105795845 26 | 5 6 0.16666666666666666 0 0 0 122.45250750197297 106.7361107999279 96.66118637587913 0 0 0 0 0 39.608555702822855 27 | 6 1 0.16666666666666666 0 0 0 94.41981975695008 99.46812901307179 100.78113141422581 0 0 0 0 0 63.58719800001163 28 | 6 2 0.16666666666666666 0 0 0 98.96710508815501 133.7567471195399 120.90558683454219 0 0 0 0 0 52.52846885865835 29 | 6 3 0.16666666666666666 0 0 0 106.92530571618369 124.20459937333122 115.22497548551802 0 0 0 0 0 73.67260593946045 30 | 6 4 0.16666666666666666 0 0 0 131.90654660811245 131.57347574007412 121.61283260580717 0 0 0 0 0 53.07558788048255 31 | 6 5 0.16666666666666666 0 0 0 90.44726691355937 110.08091314034885 132.59983323396878 0 0 0 0 0 56.29221816357587 32 | 6 6 0.16666666666666666 0 0 0 127.33973672968081 99.37793634500741 116.83634970198142 0 0 0 0 0 67.4211177216519 33 | 7 1 0.16666666666666666 0 0 0 108.20878862643377 145.11648064396516 145.77002455152123 0 0 0 0 0 54.199871092598144 34 | 7 2 0.16666666666666666 0 0 0 142.25524914850982 106.01631882272903 126.81757034137505 0 0 0 0 0 56.62756651548089 35 | 7 3 0.16666666666666666 0 0 0 110.39983922068771 141.60444453938075 138.94722675408912 0 0 0 0 0 61.17910253291162 36 | 7 4 0.16666666666666666 0 0 0 138.8362976481963 109.59760564886064 112.03430495736069 0 0 0 0 0 54.91941588132348 37 | 7 5 0.16666666666666666 0 0 0 148.2424072645081 144.3906653062897 101.18001621241322 0 0 0 0 0 54.57908854682098 38 | 7 6 0.16666666666666666 0 0 0 118.34046813821172 125.36276972712477 122.43077460815505 0 0 0 0 0 58.670201136189796 39 | 8 1 0.16666666666666666 0 0 0 89.62147896805573 106.5032767611869 83.47531103986934 0 0 0 0 0 35.343895233247665 40 | 8 2 0.16666666666666666 0 0 0 86.7038629419761 80.48236078356479 117.16013014370677 0 0 0 0 0 48.0605082486212 41 | 8 3 0.16666666666666666 0 0 0 88.87728945890922 99.8924550323418 83.20215250866015 0 0 0 0 0 40.42872912332146 42 | 8 4 0.16666666666666666 0 0 0 109.16332730465012 97.78304263110289 115.71934245194085 0 0 0 0 0 37.19387570011752 43 | 8 5 0.16666666666666666 0 0 0 119.74097605763666 85.96366689272278 115.95423826328266 0 0 0 0 0 34.74549022503659 44 | 8 6 0.16666666666666666 0 0 0 106.36062687798989 91.63736792931581 109.90556655032535 0 0 0 0 0 45.605647267136916 45 | 9 1 0.16666666666666666 0 0 0 76.70167632644461 84.538454036093 99.1010151909825 0 0 0 0 0 72.24646396745926 46 | 9 2 0.16666666666666666 0 0 0 79.11790787501295 81.19484331811468 100.04707010163995 0 0 0 0 0 69.25831398207947 47 | 9 3 0.16666666666666666 0 0 0 79.3769433178373 105.82077203889463 105.52347350069437 0 0 0 0 0 75.14595950512447 48 | 9 4 0.16666666666666666 0 0 0 107.24732446732496 100.91859615291538 103.0883937833013 0 0 0 0 0 55.82766053939317 49 | 9 5 0.16666666666666666 0 0 0 111.60853174907926 87.07407411155668 90.29330798947063 0 0 0 0 0 54.09956558112525 50 | 9 6 0.16666666666666666 0 0 0 91.95221506277618 106.55342176286338 113.04563873855666 0 0 0 0 0 66.2977413504969 51 | 10 1 0.16666666666666666 0 0 0 107.20994956054913 109.00809440217506 147.70017743745206 0 0 0 0 0 73.85755809789534 52 | 10 2 0.16666666666666666 0 0 0 139.52451694881168 116.84856440325856 107.00013997566094 0 0 0 0 0 75.2543240812652 53 | 10 3 0.16666666666666666 0 0 0 110.13012206678745 100.00525848827867 126.90003403363116 0 0 0 0 0 69.53424870550542 54 | 10 4 0.16666666666666666 0 0 0 101.39180640386613 102.45425408584376 124.99079378063729 0 0 0 0 0 52.68096895664979 55 | 10 5 0.16666666666666666 0 0 0 125.1758684702829 102.2225787786843 103.63943410827613 0 0 0 0 0 65.80112904510496 56 | 10 6 0.16666666666666666 0 0 0 106.2129523106098 143.08538220632255 115.16359381426818 0 0 0 0 0 61.212642030465894 57 | 11 1 0.16666666666666666 0 0 0 115.60529733364676 131.29031642338543 115.26310597359146 0 0 0 0 0 44.3086557904017 58 | 11 2 0.16666666666666666 0 0 0 126.90342780500043 112.94677970873832 115.06595956850029 0 0 0 0 0 35.39434017957271 59 | 11 3 0.16666666666666666 0 0 0 153.90340739913376 150.34263938563763 113.64584382546512 0 0 0 0 0 37.61152520438549 60 | 11 4 0.16666666666666666 0 0 0 147.8576436909647 109.27147105077985 144.97307184529188 0 0 0 0 0 40.313148912945664 61 | 11 5 0.16666666666666666 0 0 0 152.70455917642593 108.55648381337404 112.45583228051052 0 0 0 0 0 44.449245961045186 62 | 11 6 0.16666666666666666 0 0 0 138.10869249480533 147.32088694099934 150.9631570424558 0 0 0 0 0 46.28353084134306 63 | 12 1 0.16666666666666666 0 0 0 101.47037857246428 117.66745935145906 87.72934709585888 0 0 0 0 0 69.90863166411135 64 | 12 2 0.16666666666666666 0 0 0 99.41900583575516 88.87038887311229 90.99512771653345 0 0 0 0 0 52.739558945122845 65 | 12 3 0.16666666666666666 0 0 0 111.32675091571991 118.26541360891962 122.87809613246422 0 0 0 0 0 71.78966565792223 66 | 12 4 0.16666666666666666 0 0 0 114.5911788586612 95.65128503171219 99.96164300150913 0 0 0 0 0 65.72356353209786 67 | 12 5 0.16666666666666666 0 0 0 107.9446903192362 103.73257939761518 97.14491584482944 0 0 0 0 0 74.28551653592926 68 | 12 6 0.16666666666666666 0 0 0 108.85862997977637 94.7637231720877 85.68067415273705 0 0 0 0 0 61.278215248498626 69 | -------------------------------------------------------------------------------- /sddip/sddip/scenarios.py: -------------------------------------------------------------------------------- 1 | import random as rdm 2 | 3 | import numpy as np 4 | import pandas as pd 5 | 6 | from sddip import config 7 | 8 | 9 | class ScenarioGenerator: 10 | h0_load_profile = pd.read_csv(config.H0_LOAD_PROFILE_FILE, delimiter="\t") 11 | 12 | def __init__(self, n_stages, n_realizations_per_stage) -> None: 13 | if n_stages < 2: 14 | msg = "Number of stages must be greater than 1." 15 | raise ValueError(msg) 16 | if n_realizations_per_stage < 2: 17 | msg = "Number of realizations per stage must be greater than 1." 18 | raise ValueError(msg) 19 | self.h0_profile = ScenarioGenerator.h0_load_profile.h0.values.tolist() 20 | self.n_stages = n_stages 21 | self.n_realizations_per_stage = n_realizations_per_stage 22 | self.n_total_realizations = ( 23 | n_stages - 1 24 | ) * n_realizations_per_stage + 1 25 | 26 | self.reduction_factor = int(len(self.h0_load_profile) / n_stages) 27 | 28 | def generate_demand_scenario_dataframe( 29 | self, 30 | n_buses: int, 31 | demand_buses: list, 32 | max_value_targets: list, 33 | max_relative_variation: float, 34 | ) -> pd.DataFrame: 35 | if len(demand_buses) != len(max_value_targets): 36 | msg = "Number of maximum target values must equal the number of demand buses." 37 | raise ValueError(msg) 38 | 39 | reduced_profile = self.reduce_profile( 40 | self.h0_profile, self.reduction_factor 41 | ) 42 | 43 | base_profiles = [ 44 | self.scale_profile(reduced_profile, max(max_value - 10, 0)) 45 | for max_value in max_value_targets 46 | ] 47 | 48 | scenario_data = {"t": [1], "n": [1], "p": [1]} 49 | 50 | demand_bus_keys, no_demand_bus_keys = self.create_bus_keys( 51 | n_buses, demand_buses, "Pd" 52 | ) 53 | 54 | # Set loads for buses without demand 55 | for b in no_demand_bus_keys: 56 | scenario_data[b] = [0] * self.n_total_realizations 57 | 58 | # Set loads for the first (deterministic) stage 59 | for b in range(len(demand_buses)): 60 | scenario_data[demand_bus_keys[b]] = [ 61 | self.get_rdm_variation( 62 | base_profiles[b][0], max_relative_variation 63 | ) 64 | ] 65 | 66 | # Set loads for stages >1 67 | for t in range(1, self.n_stages): 68 | for n in range(1, self.n_realizations_per_stage + 1): 69 | scenario_data["t"].append(t + 1) 70 | scenario_data["n"].append(n) 71 | scenario_data["p"].append(1 / self.n_realizations_per_stage) 72 | for b in range(len(demand_buses)): 73 | scenario_data[demand_bus_keys[b]].append( 74 | self.get_rdm_variation( 75 | base_profiles[b][t], max_relative_variation 76 | ) 77 | ) 78 | 79 | return pd.DataFrame(scenario_data) 80 | 81 | def generate_renewables_scenario_dataframe( 82 | self, 83 | n_buses: int, 84 | renewables_buses: list, 85 | start_values: list, 86 | step_sizes: list, 87 | min_values: list, 88 | max_values: list, 89 | threshold: float, 90 | max_relative_variation: float, 91 | ) -> pd.DataFrame: 92 | if len(renewables_buses) != len(start_values): 93 | msg = "Number of list entries must equal the number of renewables buses." 94 | raise ValueError(msg) 95 | 96 | scenario_data = {"t": [1], "n": [1], "p": [1]} 97 | 98 | renewables_bus_keys, no_renewables_bus_keys = self.create_bus_keys( 99 | n_buses, renewables_buses, "Re" 100 | ) 101 | 102 | # Set geneartion for buses without renewables 103 | for b in no_renewables_bus_keys: 104 | scenario_data[b] = [0] * self.n_total_realizations 105 | 106 | # Generate base profiles 107 | base_profiles = [] 108 | for b in range(len(renewables_buses)): 109 | profile = self.random_walk( 110 | self.n_stages, 111 | start_values[b], 112 | step_sizes[b], 113 | min_values[b], 114 | max_values[b], 115 | threshold, 116 | ) 117 | base_profiles.append(profile) 118 | 119 | # Set generation for the first (deterministic) stage 120 | for b in range(len(renewables_buses)): 121 | scenario_data[renewables_bus_keys[b]] = [ 122 | self.get_rdm_variation( 123 | base_profiles[b][0], max_relative_variation 124 | ) 125 | ] 126 | 127 | # Set loads for stages >1 128 | for t in range(1, self.n_stages): 129 | for n in range(1, self.n_realizations_per_stage + 1): 130 | scenario_data["t"].append(t + 1) 131 | scenario_data["n"].append(n) 132 | scenario_data["p"].append(1 / self.n_realizations_per_stage) 133 | for b in range(len(renewables_buses)): 134 | scenario_data[renewables_bus_keys[b]].append( 135 | self.get_rdm_variation( 136 | base_profiles[b][t], max_relative_variation 137 | ) 138 | ) 139 | 140 | return pd.DataFrame(scenario_data) 141 | 142 | def random_walk( 143 | self, 144 | n_steps: int, 145 | start_value: float, 146 | step_size: float, 147 | min_value: float, 148 | max_value: float, 149 | threshold: float = 0.5, 150 | ) -> list: 151 | values = [] 152 | prev_value = start_value 153 | 154 | for _ in range(n_steps): 155 | new_value = 0 156 | probability = rdm.random() 157 | 158 | if probability >= threshold: 159 | new_value = prev_value + step_size 160 | else: 161 | new_value = prev_value - step_size 162 | 163 | if new_value > max_value: 164 | new_value = max_value 165 | elif new_value < min_value: 166 | new_value = min_value 167 | 168 | values.append(new_value) 169 | prev_value = new_value 170 | 171 | return values 172 | 173 | def create_bus_keys( 174 | self, n_buses: int, active_buses: list, label: str 175 | ) -> tuple: 176 | active_bus_keys = [] 177 | inactive_bus_keys = [] 178 | 179 | for b in range(n_buses): 180 | bus_key = f"{label}{b+1}" 181 | if b in active_buses: 182 | active_bus_keys.append(bus_key) 183 | else: 184 | inactive_bus_keys.append(bus_key) 185 | 186 | return (active_bus_keys, inactive_bus_keys) 187 | 188 | def get_rdm_variation( 189 | self, base_value: float, max_relative_variation: float 190 | ) -> float: 191 | return base_value + base_value * rdm.uniform( 192 | -max_relative_variation, max_relative_variation 193 | ) 194 | 195 | def reduce_profile(self, values: list, reduction_factor: int) -> list: 196 | if len(values) % reduction_factor != 0: 197 | msg = "Number of values to be reduced must be divisible by the reduction factor." 198 | raise ValueError(msg) 199 | 200 | values = np.array(values) 201 | 202 | return list(np.mean(values.reshape(-1, reduction_factor), axis=1)) 203 | 204 | def scale_profile(self, values: list, max_value_target: float) -> list: 205 | values = np.array(values) 206 | 207 | max_value = np.amax(values) 208 | 209 | scaling_factor = max_value_target / max_value 210 | 211 | return list(values * scaling_factor) 212 | 213 | 214 | class ScenarioSampler: 215 | def __init__(self, n_stages: int, n_realizations_per_stage: int) -> None: 216 | self.n_stages = n_stages 217 | self.n_realizations_per_stage = n_realizations_per_stage 218 | 219 | def generate_samples(self, n_samples: int) -> list: 220 | samples = [] 221 | for _ in range(n_samples): 222 | sample = [ 223 | rdm.randint(0, self.n_realizations_per_stage - 1) 224 | for _ in range(self.n_stages - 1) 225 | ] 226 | sample.insert(0, 0) 227 | samples.append(sample) 228 | 229 | return samples 230 | --------------------------------------------------------------------------------