Skip to content

Commit

Permalink
Merge pull request #12 from YoungFaithful/master
Browse files Browse the repository at this point in the history
Merge changes in master into dev
  • Loading branch information
holgerteichgraeber authored May 3, 2019
2 parents 0a1a35a + 253c31d commit 27a8dae
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ after_success:

jobs:
include:
- stage: "Documentation"
- stage: "Testing"
julia: 1.0
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
- julia --project=test/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- julia --project=test/ test/cep.jl
after_success:
- stage: "Testing"
- stage: "Documentation"
julia: 1.0
os: linux
script:
- julia --project=test/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- julia --project=test/ test/cep.jl
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
after_success:
services: docker
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ keywords = ["energy", "capacity", "JuMP", "optimization"]
license = "MIT"
desc = "Capacity Expansion Problem Formulation for Julia"
author = ["Elias Kuepper <elias.kuepper@rwth-aachen.de>"]
version = "0.1.1"
version = "0.1.3"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
2 changes: 1 addition & 1 deletion src/CapacityExpansion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module CapacityExpansion
@reexport using FileIO
using JuMP

export OptDataCEP,
export OptDataCEP,
OptDataCEPTech,
OptDataCEPNode,
OptDataCEPLine,
Expand Down
4 changes: 2 additions & 2 deletions src/optim_problems/run_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function run_opt(ts_data::ClustData,
end

"""
run_opt(ts_data::ClustData,opt_data::OptDataCEP,optimizer::DataTyple;co2_limit::Number=Inf,lost_el_load_cost::Number=Inf,lost_CO2_emission_cost::Number=Inf,existing_infrastructure::Bool=false,limit_infrastructure::Bool=false,storage::String="none",transmission::Bool=false,descriptor::String="",print_flag::Bool=true,optimizer_config::Dict{Symbol,Any}=Dict{Symbol,Any}(),round_sigdigits::Int64=9)
run_opt(ts_data::ClustData,opt_data::OptDataCEP,optimizer::DataTyple;co2_limit::Number=Inf,lost_el_load_cost::Number=Inf,lost_CO2_emission_cost::Number=Inf,existing_infrastructure::Bool=false,limit_infrastructure::Bool=false,storage::String="none",transmission::Bool=false,descriptor::String="",print_flag::Bool=true,optimizer_config::Dict{Symbol,Any}=Dict{Symbol,Any}(),round_sigdigits::Int=9)
Wrapper function for type of optimization problem for the CEP-Problem (NOTE: identifier is the type of `opt_data` - in this case OptDataCEP - so identification as CEP problem).
Required elements are:
- `ts_data`: The time-series data, which could either be the original input data or some aggregated time-series data. The `keys(ts_data.data)` need to match the `[time_series_name]-[node]`
Expand Down Expand Up @@ -128,7 +128,7 @@ function run_opt(ts_data::ClustData,
descriptor::String="",
print_flag::Bool=true,
optimizer_config::Dict{Symbol,Any}=Dict{Symbol,Any}(),
round_sigdigits::Int64=9)
round_sigdigits::Int=9)
# Activated seasonal or simple storage corresponds with storage
if storage=="seasonal"
storage=true
Expand Down
6 changes: 3 additions & 3 deletions src/utils/datastructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
- `variables`: Dictionary with each OptVariable as an entry
- `sets`: Dictionary with each set as an entry
- `opt_config`: The configuration of the model setup - for more detail see tye `run_opt` documentation that sets the `opt_config` up
- `opt_info`: Holds information about the model. E.g. `opt_info["model"]` contains the exact equations used in the model.
- `opt_info`: Holds information about the model. E.g. `opt_info["model"]` contains the exact equations used in the model.
"""
struct OptResult
status::Symbol
Expand Down Expand Up @@ -99,7 +99,7 @@ struct OptDataCEPNode <: OptData
end

"""
OptDataCEPLine{name::String,node_start::String,node_end::String,reactance::Number,resistance::Number,power::Number,circuits::Int64,voltage::Number,length::Number} <: OptData
OptDataCEPLine{name::String,node_start::String,node_end::String,reactance::Number,resistance::Number,power::Number,circuits::Int,voltage::Number,length::Number} <: OptData
- `name`
- `node_start` Node where line starts
- `node_end` Node where line ends
Expand All @@ -120,7 +120,7 @@ struct OptDataCEPLine <: OptData
resistance::Number
power_ex::Number
power_lim::Number
circuits::Int64
circuits::Int
voltage::Number
length::Number
eff::Number
Expand Down
6 changes: 3 additions & 3 deletions src/utils/load_data.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
load_timeseries_data_provided(region::String="GER_1"; T::Int64=24, years::Array{Int64,1}=[2016], att::Array{String,1}=Array{String,1}())
load_timeseries_data_provided(region::String="GER_1"; T::Int=24, years::Array{Int,1}=[2016], att::Array{String,1}=Array{String,1}())
- Adding the information in the `*.csv` file at `data_path` to the data dictionary
The `*.csv` files shall have the following structure and must have the same length:
Expand All @@ -17,8 +17,8 @@ for regions:
- `"TX_1"`: Texas 1 node
"""
function load_timeseries_data_provided(region::String="GER_1";
T::Int64=24,
years::Array{Int64,1}=[2016],
T::Int=24,
years::Array{Int,1}=[2016],
att::Array{String,1}=Array{String,1}())
# Check for existance of the region in data
region in readdir(normpath(joinpath(@__DIR__,"..","..","data"))) || throw(@error "The region $region is not found. The provided regions are: GER_1: Germany 1 node, GER_18: Germany 18 nodes, CA_1: California 1 node, CA_14: California 14 nodes, TX_1: Texas 1 node")
Expand Down
8 changes: 4 additions & 4 deletions src/utils/optvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Constructor for OptVariable taking JuMP Array and type (ov-operational variable
function OptVariable(cep::OptModelCEP,
variable::Symbol,
type::String;
round_sigdigits::Int64=9)
round_sigdigits::Int=9)
jumparray=value.(cep.model[variable])
axes_names=Array{String,1}()
for axe in jumparray.axes
Expand All @@ -53,10 +53,10 @@ match `size(data)` in the corresponding dimensions.
# Example
```jldoctest
julia> array = OptVariable([1 2; 3 4], [:a, :b], 2:3)
2-dimensional OptVariable{Int64,2,...} with index sets:
2-dimensional OptVariable{Int,2,...} with index sets:
Dimension 1, Symbol[:a, :b]
Dimension 2, 2:3
And data, a 2×2 Array{Int64,2}:
And data, a 2×2 Array{Int,2}:
1 2
3 4
Expand All @@ -77,7 +77,7 @@ given axes.
# Example
```jldoctest
julia> array = OptVariable{Float64}(undef, [:a, :b], 1:2);
julia> array = OptVariable{Float}(undef, [:a, :b], 1:2);
julia> fill!(array, 1.0)
2-dimensional OptVariable{Float64,2,...} with index sets:
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function get_cep_variable_value(variable::OptVariable,
for i in 1:length(index_set)
if index_set[i]==Colon()
push!(index_num,Colon())
elseif typeof(index_set[i])==Int64 || typeof(index_set[i])==UnitRange{Int64}
elseif typeof(index_set[i])==Int || typeof(index_set[i])==UnitRange{Int}
push!(index_num,index_set[i])
else
new_index_num=findfirst(variable.axes[i].==index_set[i])
Expand Down
17 changes: 9 additions & 8 deletions test/cep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Clp
# run clustering
ts_clust_res = run_clust(ts_input_data;method="kmeans",representation="centroid",n_init=1,n_clust=365) # default k-means
# run optimization
model = run_opt(ts_clust_res.best_results,cep_input_data,Clp.Optimizer)
model = run_opt(ts_clust_res.best_results,cep_input_data,Clp.Optimizer;optimizer_config=Dict{Symbol,Any}(:LogLevel => 0))
# compare to exact result
exact_res=[70540.26439790576;0.0;8498.278397905757;0.0;80132.88454450261]
@test exact_res model.variables["CAP"].data[:,1,1] atol=1
Expand All @@ -26,12 +26,13 @@ using Clp
ts_full_data = run_clust(ts_input_data;method="hierarchical",representation="centroid",n_init=1,n_clust=30)
## OPTIMIZATION ##
optimizer=Clp.Optimizer
scenarios["$state-$years-co2"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="co2",co2_limit=1000)
scenarios["$state-$years-slack"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="slack",lost_el_load_cost=1e6, lost_CO2_emission_cost=700)
scenarios["$state-$years-ex"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="ex",existing_infrastructure=true)
scenarios["$state-$years-simple"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="simple storage",storage="simple")
scenarios["$state-$years-seasonal"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="seasonal storage",storage="seasonal")
design_result=run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="des&op")
optimizer_config=Dict{Symbol,Any}(:LogLevel => 0)
scenarios["$state-$years-co2"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="co2",co2_limit=1000,optimizer_config=optimizer_config)
scenarios["$state-$years-slack"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="slack",lost_el_load_cost=1e6, lost_CO2_emission_cost=700,optimizer_config=optimizer_config)
scenarios["$state-$years-ex"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="ex",existing_infrastructure=true,optimizer_config=optimizer_config)
scenarios["$state-$years-simple"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="simple storage",storage="simple",optimizer_config=optimizer_config)
scenarios["$state-$years-seasonal"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="seasonal storage",storage="seasonal",optimizer_config=optimizer_config)
design_result=run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="des&op",optimizer_config=optimizer_config)
scenarios["$state-$years-des&op"] = run_opt(ts_full_data.best_results,cep_data,design_result.opt_config,get_cep_design_variables(design_result),optimizer;lost_el_load_cost=1e6,lost_CO2_emission_cost=700)
end
end
Expand All @@ -44,7 +45,7 @@ using Clp
ts_clust_data = run_clust(ts_input_data;method="hierarchical",representation="centroid",n_init=1,n_clust=3)
## OPTIMIZATION ##
optimizer=Clp.Optimizer
scenarios["$state-$years-trans"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="trans",transmission=true)
scenarios["$state-$years-trans"] = run_opt(ts_clust_data.best_results,cep_data,optimizer;descriptor="trans",transmission=true,optimizer_config=Dict{Symbol,Any}(:LogLevel => 0))
end
end
#Test exact values for each of the previously calculated scenarios by comparison with exact scenarios
Expand Down

0 comments on commit 27a8dae

Please sign in to comment.