mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-07 08:48:51 -06:00
Revise docs and struct name; add basic MPI test
This commit is contained in:
37
test/src/solution/methods/ProgressiveHedging/ph.jl
Normal file
37
test/src/solution/methods/ProgressiveHedging/ph.jl
Normal file
@@ -0,0 +1,37 @@
|
||||
using Cbc
|
||||
using MPI
|
||||
using JuMP
|
||||
using UnitCommitment
|
||||
|
||||
UnitCommitment._setup_logger(level = Base.CoreLogging.Error)
|
||||
function fixture(path::String)::String
|
||||
basedir = dirname(@__FILE__)
|
||||
return "$basedir/../../../../fixtures/$path"
|
||||
end
|
||||
|
||||
# 1. Initialize MPI
|
||||
MPI.Init()
|
||||
|
||||
# 2. Configure progressive hedging method
|
||||
ph = UnitCommitment.ProgressiveHedging()
|
||||
|
||||
# 3. Read problem instance
|
||||
instance = UnitCommitment.read(
|
||||
[fixture("case14.json.gz"), fixture("case14.json.gz")],
|
||||
ph,
|
||||
)
|
||||
|
||||
# 4. Build JuMP model
|
||||
model = UnitCommitment.build_model(
|
||||
instance = instance,
|
||||
optimizer = optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0),
|
||||
)
|
||||
|
||||
# 5. Run the decentralized optimization algorithm
|
||||
UnitCommitment.optimize!(model, ph)
|
||||
|
||||
# 6. Fetch the solution
|
||||
solution = UnitCommitment.solution(model, ph)
|
||||
|
||||
# 7. Close MPI
|
||||
MPI.Finalize()
|
||||
16
test/src/solution/methods/ProgressiveHedging/usage_test.jl
Normal file
16
test/src/solution/methods/ProgressiveHedging/usage_test.jl
Normal file
@@ -0,0 +1,16 @@
|
||||
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
using MPI
|
||||
|
||||
function solution_methods_ProgressiveHedging_usage_test()
|
||||
basedir = dirname(@__FILE__)
|
||||
@testset "ProgressiveHedging" begin
|
||||
mpiexec() do exe
|
||||
return run(
|
||||
`$exe -n 2 $(Base.julia_cmd()) --project=test $basedir/ph.jl`,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user