Skip to content

Commit

Permalink
Merge pull request #135 from Electa-Git/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
hakanergun authored Dec 19, 2022
2 parents 8eb66f2 + 3322b43 commit 2e37be4
Show file tree
Hide file tree
Showing 53 changed files with 598 additions and 837 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.5'
- '1.6'
- '1'
- 'nightly'
os:
Expand All @@ -23,12 +23,12 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v2
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
Expand All @@ -43,6 +43,6 @@ jobs:
- uses: julia-actions/julia-runtest@latest
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
4 changes: 1 addition & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ on:
tags: '*'
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '0,5,10 13 * * *'
jobs:
docs:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@latest
with:
version: '1'
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ docs/site/
Manifest.toml

# Output of test scripts
test/data/output_files

# Figures generated by test scripts outside the standard dir
*.png
output/

# OS files
.DS_Store
Expand Down
30 changes: 10 additions & 20 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,34 @@ name = "FlexPlan"
uuid = "4dc3fedf-fcb4-4327-bce2-523fd266e8c9"
autors = ["Hakan Ergun", "Matteo Rossini", "Marco Rossi", "Damien Lapage", "Iver Bakken Sperstad", "Espen Flo Bødal", "Merkebu Zenebe Degefa", "Reinhilde D'hulst"]
repo = "https://github.com/electa-git/FlexPlan.jl"
version = "0.2.2"
version = "0.3.0"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
PowerModelsACDC = "ff45984e-d068-5f4c-9e32-c4133509d236"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[compat]
CSV = "0.9, 0.10"
Cbc = ">= 0.9"
DataFrames = "^1"
HiGHS = "0.3.2"
InfrastructureModels = "~0.6, ~0.7"
Ipopt = ">= 0.8"
JSON = "~0.21.1"
JuMP = "~0.22.0"
Juniper = ">= 0.8"
MathOptInterface = "=0.10.9"
Memento = "~1.0, ~1.1, ~1.2, ~1.3"
CSV = "0.10"
DataFrames = "1"
HiGHS = "0.3.2, 1"
InfrastructureModels = "0.6, 0.7"
JSON = "0.21.1"
JuMP = "0.22, 0.23, 1"
Memento = "1"
PowerModels = "0.19.6"
PowerModelsACDC = "=0.5.2"
SCS = ">= 0.8"
PowerModelsACDC = "0.6"
julia = "1.6"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["CSV", "Cbc", "DataFrames", "HiGHS", "Ipopt", "Juniper", "SCS", "Test"]
test = ["CSV", "DataFrames", "HiGHS", "Test"]
21 changes: 12 additions & 9 deletions docs/src/example_scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ A number of example scripts have been provided within `FlexPlan.jl` under `"Flex
The required packages for FlexPlan.jl are `PowerModels.jl` and `PowerModelsACDC.jl`. You can declare the packages as follows, and use short names to access specific functions without having to type the full package name every time.

``` julia
import PowerModels; const _PM = PowerModels
import PowerModelsACDC; const _PMACDC = PowerModelsACDC
import FlexPlan; const _FP = FlexPlan
import PowerModels as _PM
import PowerModelsACDC as _PMACDC
import FlexPlan as _FP
```
Any other additional package that you might need, e.g., for printing, plotting, exporting results etc. can be declared in the same way.

Also, the solution of the problem will require an MILP solver. As ```FlexPlan.jl``` is in the Julia / JuMP environment, it can be interfaced with any optimisation solver. You can declare and initialize the solver as follows:

``` julia
import Cbc
optimizer = _FP.optimizer_with_attributes(Cbc.Optimizer, "logLevel"=>0)
import HiGHS
optimizer = _FP.optimizer_with_attributes(HiGHS.Optimizer, "output_flag"=>false)
```

## Step 2: Input data
Expand All @@ -33,7 +33,8 @@ These test cases have been used in for the validation of the model in the FlexPl
The functions are named `load_*` where `*` is the name of a test case.
For example, `case6` can be loaded using:
```julia
include("test/io/load_case.jl")
const _FP_dir = dirname(dirname(pathof(_FP))) # Root directory of FlexPlan package
include(joinpath(_FP_dir,"test/io/load_case.jl"))
data = load_case6(; number_of_hours=24, number_of_scenarios=1, number_of_years=1)
```
Supported parameters are explained in `load_*` function documentation.
Expand All @@ -54,13 +55,14 @@ The procedure is as follows.

Here is some sample code to get started:
```julia
sn_data = _FP.parse_file("./test/data/case6/case6_2030.m")
const _FP_dir = dirname(dirname(pathof(_FP))) # Root directory of FlexPlan package
sn_data = _FP.parse_file(joinpath(_FP_dir,"test/data/case6/case6_2030.m"))
_FP.add_dimension!(sn_data, :hour, 24)
_FP.add_dimension!(sn_data, :scenario, Dict(1 => Dict{String,Any}("probability"=>1)))
_FP.add_dimension!(sn_data, :year, 1; metadata = Dict{String,Any}("scale_factor"=>1))
_FP.scale_data!(sn_data)

include("./test/io/create_profile.jl") # Functions to load sample time series. Use your own instead.
include(joinpath(_FP_dir,"test/io/create_profile.jl")) # Functions to load sample time series. Use your own instead.
sn_data, loadprofile, genprofile = create_profile_data_italy!(sn_data)
time_series = create_profile_data(24, sn_data, loadprofile, genprofile) # Your time series should have the same format as this `time_series` dict

Expand All @@ -84,7 +86,8 @@ Here is an example (using FlexPlan.jl sample data):
number_of_hours = 4
number_of_scenarios = 2
number_of_years = 1
include("./test/io/load_case.jl")
const _FP_dir = dirname(dirname(pathof(_FP))) # Root directory of FlexPlan package
include(joinpath(_FP_dir, "test/io/load_case.jl"))

# Transmission network data
t_data = load_case6(; number_of_hours, number_of_scenarios, number_of_years)
Expand Down
15 changes: 8 additions & 7 deletions examples/example_combined_td_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
using Memento
_LOGGER = Logger(first(splitext(basename(@__FILE__)))) # A logger for this script, also used by included files.

import PowerModels; const _PM = PowerModels
import PowerModelsACDC; const _PMACDC = PowerModelsACDC
import FlexPlan; const _FP = FlexPlan
include("../test/io/load_case.jl") # Include sample data from FlexPlan repository; you can of course also use your own data
import PowerModels as _PM
import PowerModelsACDC as _PMACDC
import FlexPlan as _FP
const _FP_dir = dirname(dirname(pathof(_FP))) # Root directory of FlexPlan package
include(joinpath(_FP_dir,"test/io/load_case.jl")) # Include sample data from FlexPlan repository; you can of course also use your own data


## Set up solver

import Cbc
optimizer = _FP.optimizer_with_attributes(Cbc.Optimizer, "logLevel"=>1, "threads"=>Threads.nthreads())
import HiGHS
optimizer = _FP.optimizer_with_attributes(HiGHS.Optimizer, "output_flag"=>false)
#import CPLEX
#optimizer = _FP.optimizer_with_attributes(CPLEX.Optimizer, "CPXPARAM_ScreenOutput"=>0)
direct_model = false # Whether to construct JuMP models using JuMP.direct_model() instead of JuMP.Model(). direct_model is only supported by some solvers.
Expand Down Expand Up @@ -61,6 +62,6 @@ d_data = [d_data_sub_1, d_data_sub_2]
## Solve problem

result = _FP.simple_stoch_flex_tnep(t_data, d_data, t_model_type, d_model_type, optimizer; t_setting, d_setting, direct_model)
@assert result["termination_status"] (_PM.OPTIMAL, _PM.LOCALLY_SOLVED) "$(result["optimizer"]) termination status: $(result["termination_status"])"
@assert result["termination_status"] (_FP.OPTIMAL, _FP.LOCALLY_SOLVED) "$(result["optimizer"]) termination status: $(result["termination_status"])"

notice(_LOGGER, "Script completed in $(round(time()-time_start;sigdigits=3)) seconds.")
37 changes: 13 additions & 24 deletions examples/example_stochastic_tnep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,32 @@

## Import relevant packages

import FlexPlan; const _FP = FlexPlan
import PowerModelsACDC; const _PMACDC = PowerModelsACDC # For DC grid
import PowerModels; const _PM = PowerModels # For AC grid and common functions

# Include sample data from FlexPlan repository; you can of course also use your own data
include("../test/io/create_profile.jl")
import PowerModels as _PM
import PowerModelsACDC as _PMACDC
import FlexPlan as _FP
const _FP_dir = dirname(dirname(pathof(_FP))) # Root directory of FlexPlan package
include(joinpath(_FP_dir,"test/io/create_profile.jl")) # Include sample data from FlexPlan repository; you can of course also use your own data

# Add solver packages
# > Note: solver packages are needed to handle communication between the solver and JuMP;
# > the commercial ones do not include the solver itself.
import Cbc
#import Ipopt
#import Juniper
#import SCS
#import Mosek
#import Gurobi

# Solver configuration
cbc = _FP.optimizer_with_attributes(Cbc.Optimizer, "logLevel"=>0)
#ipopt = _FP.optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-4, "print_level"=>0)
#juniper = _FP.optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>ipopt, "mip_solver"=>cbc, "time_limit"=>7200)
#scs = _FP.optimizer_with_attributes(SCS.Optimizer, "max_iters"=>100000)
#gurobi = Gurobi.Optimizer
#mosek = Mosek.Optimizer
optimizer = cbc
import HiGHS
optimizer = _FP.optimizer_with_attributes(HiGHS.Optimizer, "output_flag"=>false)
#import CPLEX
#optimizer = _FP.optimizer_with_attributes(CPLEX.Optimizer, "CPXPARAM_ScreenOutput"=>0)


## Input parameters

number_of_hours = 24 # Number of time points
planning_horizon = 10 # Years to scale generation costs
file = "./test/data/case6/case6_2030.m" # Input case, in Matpower m-file format: here 6-bus case with candidate AC, DC lines and candidate storage
file = joinpath(_FP_dir,"test/data/case6/case6_2030.m") # Input case, in Matpower m-file format: here 6-bus case with candidate AC, DC lines and candidate storage
scenario_properties = Dict(
1 => Dict{String,Any}("probability"=>0.5, "start"=>1514764800000), # 1514764800000 is 2018-01-01T00:00, needed by `create_profile_data_italy!` when `mc=false`
2 => Dict{String,Any}("probability"=>0.5, "start"=>1546300800000), # 1546300800000 is 2019-01-01T00:00, needed by `create_profile_data_italy!` when `mc=false`
)
scenario_metadata = Dict{String,Any}("mc"=>false) # Needed by `create_profile_data_italy!`
out_dir = mkpath("output")


## Load test case
Expand All @@ -57,7 +46,7 @@ mn_data = _FP.make_multinetwork(data, time_series) # Create the multinetwork dat
## Plot all candidates pre-optimization

plot_settings = Dict("add_nodes" => true, "plot_result_only" => false)
plot_filename = "./test/data/output_files/candidates_italy.kml"
plot_filename = joinpath(out_dir,"candidates_italy.kml")
_FP.plot_geo_data(mn_data, plot_filename, plot_settings)


Expand All @@ -76,7 +65,7 @@ result = _FP.stoch_flex_tnep(mn_data, _PM.DCPPowerModel, optimizer; setting = s)
## Plot final topology

plot_settings = Dict("add_nodes" => true, "plot_solution_only" => true)
plot_filename = "./test/data/output_files/stoch.kml"
plot_filename = joinpath(out_dir,"stoch.kml")
_FP.plot_geo_data(mn_data, plot_filename, plot_settings; solution = result)


Expand Down
Loading

2 comments on commit 2e37be4

@hakanergun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74340

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" 2e37be46aa9590a39c4284b921bc5c854089471f
git push origin v0.3.0

Please sign in to comment.