mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
Break down model.jl
This commit is contained in:
@@ -8,21 +8,21 @@ TIMESTAMP := $(shell date "+%Y-%m-%d %H:%M")
|
||||
SRC_FILES := $(wildcard ../src/*.jl)
|
||||
|
||||
INSTANCES_PGLIB := \
|
||||
pglib-uc/ca/2014-09-01_reserves_0 \
|
||||
pglib-uc/ca/2014-09-01_reserves_1 \
|
||||
pglib-uc/ca/2015-03-01_reserves_0 \
|
||||
pglib-uc/ca/2015-06-01_reserves_0 \
|
||||
pglib-uc/ca/Scenario400_reserves_1 \
|
||||
pglib-uc/ferc/2015-01-01_lw \
|
||||
pglib-uc/ferc/2015-05-01_lw \
|
||||
pglib-uc/ferc/2015-07-01_hw \
|
||||
pglib-uc/ferc/2015-10-01_lw \
|
||||
pglib-uc/ferc/2015-12-01_lw \
|
||||
pglib-uc/rts_gmlc/2020-04-03 \
|
||||
pglib-uc/rts_gmlc/2020-09-20 \
|
||||
pglib-uc/rts_gmlc/2020-10-27 \
|
||||
pglib-uc/rts_gmlc/2020-11-25 \
|
||||
pglib-uc/rts_gmlc/2020-12-23
|
||||
pglib-uc/ca/2014-09-01_reserves_0 \
|
||||
pglib-uc/ca/2014-09-01_reserves_1 \
|
||||
pglib-uc/ca/2015-03-01_reserves_0 \
|
||||
pglib-uc/ca/2015-06-01_reserves_0 \
|
||||
pglib-uc/ca/Scenario400_reserves_1 \
|
||||
pglib-uc/ferc/2015-01-01_lw \
|
||||
pglib-uc/ferc/2015-05-01_lw \
|
||||
pglib-uc/ferc/2015-07-01_hw \
|
||||
pglib-uc/ferc/2015-10-01_lw \
|
||||
pglib-uc/ferc/2015-12-01_lw \
|
||||
pglib-uc/rts_gmlc/2020-04-03 \
|
||||
pglib-uc/rts_gmlc/2020-09-20 \
|
||||
pglib-uc/rts_gmlc/2020-10-27 \
|
||||
pglib-uc/rts_gmlc/2020-11-25 \
|
||||
pglib-uc/rts_gmlc/2020-12-23
|
||||
|
||||
INSTANCES_MATPOWER := \
|
||||
matpower/case118/2017-02-01 \
|
||||
@@ -68,7 +68,7 @@ SOLUTIONS_PGLIB := $(foreach s,$(SAMPLES),$(addprefix results/,$(addsuffix .$(s)
|
||||
SOLUTIONS_ORLIB := $(foreach s,$(SAMPLES),$(addprefix results/,$(addsuffix .$(s).sol.json,$(INSTANCES_ORLIB))))
|
||||
SOLUTIONS_TEJADA19 := $(foreach s,$(SAMPLES),$(addprefix results/,$(addsuffix .$(s).sol.json,$(INSTANCES_TEJADA19))))
|
||||
|
||||
.PHONY: tables save small large clean-mps matpower pglib orlib
|
||||
.PHONY: matpower pglib orlib tejada19 clean clean-mps clean-sol save tables
|
||||
|
||||
all: matpower pglib orlib tejada19
|
||||
|
||||
|
||||
@@ -16,49 +16,37 @@ function main()
|
||||
basename, suffix = split(ARGS[1], ".")
|
||||
solution_filename = "results/$basename.$suffix.sol.json"
|
||||
model_filename = "results/$basename.$suffix.mps.gz"
|
||||
|
||||
time_limit = 60 * 20
|
||||
|
||||
BLAS.set_num_threads(4)
|
||||
|
||||
total_time = @elapsed begin
|
||||
@info "Reading: $basename"
|
||||
time_read = @elapsed begin
|
||||
instance = UnitCommitment.read_benchmark(basename)
|
||||
end
|
||||
@info @sprintf("Read problem in %.2f seconds", time_read)
|
||||
|
||||
time_model = @elapsed begin
|
||||
model = build_model(
|
||||
instance = instance,
|
||||
optimizer = optimizer_with_attributes(
|
||||
Gurobi.Optimizer,
|
||||
"Threads" => 4,
|
||||
"Seed" => rand(1:1000),
|
||||
),
|
||||
variable_names = true,
|
||||
)
|
||||
end
|
||||
|
||||
model = UnitCommitment.build_model(
|
||||
instance = instance,
|
||||
optimizer = optimizer_with_attributes(
|
||||
Gurobi.Optimizer,
|
||||
"Threads" => 4,
|
||||
"Seed" => rand(1:1000),
|
||||
),
|
||||
variable_names = true,
|
||||
)
|
||||
@info "Optimizing..."
|
||||
BLAS.set_num_threads(1)
|
||||
UnitCommitment.optimize!(
|
||||
model,
|
||||
time_limit = time_limit,
|
||||
gap_limit = 1e-3,
|
||||
UnitCommitment._XaQiWaTh19(time_limit = 3600.0),
|
||||
)
|
||||
end
|
||||
@info @sprintf("Total time was %.2f seconds", total_time)
|
||||
|
||||
@info "Writing: $solution_filename"
|
||||
solution = UnitCommitment.solution(model)
|
||||
open(solution_filename, "w") do file
|
||||
return JSON.print(file, solution, 2)
|
||||
end
|
||||
|
||||
@info "Verifying solution..."
|
||||
UnitCommitment.validate(instance, solution)
|
||||
|
||||
@info "Exporting model..."
|
||||
return JuMP.write_to_file(model, model_filename)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user