diff --git a/examples/exatron.jl b/examples/exatron.jl index 17f0c47..5900236 100644 --- a/examples/exatron.jl +++ b/examples/exatron.jl @@ -86,10 +86,6 @@ ranks = MPI.Comm_size(MPI.COMM_WORLD) if MPI.Comm_rank(MPI.COMM_WORLD) == 0 println("ProxAL/ExaTron $ranks ranks, $T periods, $K contingencies") end -# Tuple(genid, Pmin, Pmax) -genOff = Dict{Int,Vector{Tuple{Int,Float64,Float64}}}() -# At time period 2 switch generator 3 off by setting Pmin = Pmax = 0.0 -genOff[2] = [(3, 0.0, 0.0)] cur_logger = global_logger(NullLogger()) elapsed_t = @elapsed begin # redirect_stdout(devnull) do @@ -98,8 +94,7 @@ elapsed_t = @elapsed begin load_file, modelinfo, algparams, - backend; - genOff=genOff + backend ) # end end diff --git a/src/Evaluators/ProxALEvalutor.jl b/src/Evaluators/ProxALEvalutor.jl index bf5b2a2..141c980 100644 --- a/src/Evaluators/ProxALEvalutor.jl +++ b/src/Evaluators/ProxALEvalutor.jl @@ -30,8 +30,7 @@ function ProxALEvaluator( modelinfo::ModelInfo, algparams::AlgParams, space::AbstractBackend=JuMPBackend(), - comm::Union{MPI.Comm,Nothing} = MPI.COMM_WORLD; - genOff::Union{Dict{Int,Vector{Tuple{Int,Float64,Float64}}},Nothing} = nothing, + comm::Union{MPI.Comm,Nothing} = MPI.COMM_WORLD ) rawdata = RawData(case_file, load_file) opfdata = opf_loaddata( @@ -65,7 +64,7 @@ function ProxALEvaluator( end # ctgs_arr = deepcopy(rawdata.ctgs_arr) - problem = ProxALProblem(opfdata, rawdata, modelinfo, algparams, space, comm; genOff=genOff) + problem = ProxALProblem(opfdata, rawdata, modelinfo, algparams, space, comm) return ProxALEvaluator(problem, modelinfo, algparams, opfdata, rawdata, space, comm) end diff --git a/src/OPF/opfdata.jl b/src/OPF/opfdata.jl index d2e8251..6602500 100644 --- a/src/OPF/opfdata.jl +++ b/src/OPF/opfdata.jl @@ -197,7 +197,8 @@ end load_scale::Float64=1.0, ramp_scale::Float64=0.0, corr_scale::Float64=0.1, - lineOff=Line() + lineOff=Line(), + genOff::Vector{Int}=Int[], ) Loads the multi-period ACOPF instance data from `raw` @@ -216,6 +217,9 @@ These are set in `ModelInfo`. See [Model parameters](@ref). `lineOff` is a transmission line that can be deleted to represent a contingency. +`genOff` is a vector of generator indices that can be turned off +to represent a contingency. + NOTE: If `raw.genfuel_arr` is undefined for generator ``g``, then the ramp rate is set equal to ``p_{g}^{max}``. Otherwise, the ramp rate is set based on the genfuel type as follows. @@ -237,7 +241,7 @@ function opf_loaddata(raw::RawData; ramp_scale::Float64=0.0, corr_scale::Float64=0.1, lineOff=Line(), - genOff::Union{Vector{Tuple{Int,Float64,Float64}},Nothing} = nothing) + genOff::Vector{Int}=Int[]) # # load buses # @@ -311,7 +315,8 @@ function opf_loaddata(raw::RawData; ncols_gens = size(gen_arr, 2) - gens_on = findall(gen_arr[:, 8].!=0); num_on = length(gens_on) + gens_on = findall(gen_arr[:, 8].!=0); setdiff!(gens_on, genOff) + num_on = length(gens_on) num_off = num_gens-num_on if num_off > 0 @warn("loaddata: $(num_off) generators are off and will be discarded (out of $(num_gens))", maxlog=1) @@ -341,26 +346,8 @@ function opf_loaddata(raw::RawData; generators[i].mBase = gen_arr[git,7] generators[i].status = gen_arr[git,8] @assert generators[i].status==1 - if !isa(genOff, Nothing) && i ∈ getindex.(genOff,1) - # Pmax is stored at 3rd entry of Tuple - Pmax = genOff[findfirst(x -> x[1] == i, genOff)][3] - # Pmin is stored at 2nd entry of Tuple - Pmin = genOff[findfirst(x -> x[1] == i, genOff)][2] - if Pmax == 0.0 && Pmin == 0.0 - generators[i].Pmax = 0.0 - generators[i].Pmin = 0.0 - generators[i].Qmax = 0.0 - generators[i].Qmin = 0.0 - println("Switched generator $i off Pmax = Pmin = Qmax = Qmin = 0.0") - else - generators[i].Pmax = Pmax - generators[i].Pmin = Pmin - println("Changed generator $i to Pmin = $Pmin and Pmax = $Pmax") - end - else - generators[i].Pmax = gen_arr[git,9] / baseMVA - generators[i].Pmin = gen_arr[git,10] / baseMVA - end + generators[i].Pmax = gen_arr[git,9] / baseMVA + generators[i].Pmin = gen_arr[git,10] / baseMVA generators[i].Pc1 = gen_arr[git,11] generators[i].Pc2 = gen_arr[git,12] generators[i].Qc1min = gen_arr[git,13] diff --git a/src/ProxAL.jl b/src/ProxAL.jl index 333acb2..9702d03 100644 --- a/src/ProxAL.jl +++ b/src/ProxAL.jl @@ -202,8 +202,7 @@ function ProxALProblem( modelinfo::ModelInfo, algparams::AlgParams, backend::AbstractBackend, - comm::Union{MPI.Comm,Nothing}; - genOff::Union{Dict{Int,Vector{Tuple{Int,Float64,Float64}}},Nothing} = nothing, + comm::Union{MPI.Comm,Nothing} ) # initial values x = OPFPrimalSolution(opfdata, modelinfo) @@ -219,7 +218,7 @@ function ProxALProblem( blocks = OPFBlocks( opfdata, rawdata; modelinfo=modelinfo, algparams=algparams, - backend=backend, comm, genOff=genOff, + backend=backend, comm=comm ) blkLinIndex = LinearIndices(blocks.blkIndex) for blk in blkLinIndex diff --git a/src/blocks.jl b/src/blocks.jl index 6cb3fde..a72e973 100644 --- a/src/blocks.jl +++ b/src/blocks.jl @@ -53,7 +53,6 @@ function OPFBlocks( backend=JuMPBlockBackend, algparams::AlgParams = AlgParams(), comm::Union{MPI.Comm,Nothing}, - genOff::Union{Dict{Int,Vector{Tuple{Int,Float64,Float64}}},Nothing} = nothing, ) ngen = length(opfdata.generators) nbus = length(opfdata.buses) @@ -80,7 +79,6 @@ function OPFBlocks( modelinfo, t, k; decompCtgs=false, - genOff::Union{Nothing,Vector{Tuple{Int,Float64,Float64}}}=nothing, ) lineOff = Line() if length(rawdata.ctgs_arr) < k - 1 @@ -99,7 +97,6 @@ function OPFBlocks( ramp_scale=modelinfo.ramp_scale, corr_scale=modelinfo.corr_scale, lineOff=lineOff, - genOff=genOff, ) return data end @@ -115,14 +112,8 @@ function OPFBlocks( @assert k > 0 localinfo.num_ctgs = 0 end - _genOff = nothing - if genOff != nothing - _genOff = haskey(genOff,t) ? genOff[t] : nothing - end localdata = load_local_data(rawdata, opfdata, localinfo, t, k; - decompCtgs=algparams.decompCtgs, - genOff=_genOff, - ) + decompCtgs=algparams.decompCtgs) # Create block model localmodel = backend(blk, localdata, rawdata, algparams, localinfo, t, k, T) else