mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Replace Cbc/Clp by HiGHS
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
using JuMP, LinearAlgebra, Geodesy, Cbc, Clp, ProgressBars, Printf, DataStructures
|
||||
using JuMP, LinearAlgebra, Geodesy, ProgressBars, Printf, DataStructures
|
||||
|
||||
function build_model(instance::Instance, graph::Graph, optimizer)::JuMP.Model
|
||||
model = Model(optimizer)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
using JuMP, LinearAlgebra, Geodesy, Cbc, Clp, ProgressBars, Printf, DataStructures
|
||||
using JuMP, LinearAlgebra, Geodesy, ProgressBars, Printf, DataStructures
|
||||
|
||||
function get_solution(model::JuMP.Model; marginal_costs = true)
|
||||
graph, instance = model[:graph], model[:instance]
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
using JuMP, LinearAlgebra, Geodesy, Cbc, Clp, ProgressBars, Printf, DataStructures
|
||||
using JuMP, LinearAlgebra, Geodesy, ProgressBars, Printf, DataStructures, HiGHS
|
||||
|
||||
function _get_default_milp_optimizer()
|
||||
return optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
|
||||
return optimizer_with_attributes(HiGHS.Optimizer)
|
||||
end
|
||||
|
||||
function _get_default_lp_optimizer()
|
||||
return optimizer_with_attributes(Clp.Optimizer, "LogLevel" => 0)
|
||||
return optimizer_with_attributes(HiGHS.Optimizer)
|
||||
end
|
||||
|
||||
|
||||
@@ -98,7 +98,13 @@ function solve(filename::AbstractString; heuristic = false, kwargs...)
|
||||
if heuristic && instance.time > 1
|
||||
@info "Solving single-period version..."
|
||||
compressed = _compress(instance)
|
||||
csol = solve(compressed; output = nothing, marginal_costs = false, kwargs...)
|
||||
csol, _ = solve(
|
||||
compressed;
|
||||
return_model = true,
|
||||
output = nothing,
|
||||
marginal_costs = false,
|
||||
kwargs...
|
||||
)
|
||||
@info "Filtering candidate locations..."
|
||||
selected_pairs = []
|
||||
for (plant_name, plant_dict) in csol["Plants"]
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using PackageCompiler
|
||||
|
||||
using Cbc
|
||||
using Clp
|
||||
using Geodesy
|
||||
using JSON
|
||||
using JSONSchema
|
||||
using JuMP
|
||||
using MathOptInterface
|
||||
using ProgressBars
|
||||
|
||||
pkg = [:Cbc, :Clp, :Geodesy, :JSON, :JSONSchema, :JuMP, :MathOptInterface, :ProgressBars]
|
||||
|
||||
@info "Building system image..."
|
||||
create_sysimage(pkg, sysimage_path = "build/sysimage.so")
|
||||
@@ -1,22 +1,22 @@
|
||||
println("Initializing...")
|
||||
|
||||
using Logging
|
||||
using Cbc
|
||||
using Clp
|
||||
using JSON
|
||||
using JuMP
|
||||
using HiGHS
|
||||
using RELOG
|
||||
|
||||
function solve(root, filename)
|
||||
ref_file = "$root/$filename"
|
||||
optimizer = optimizer_with_attributes(
|
||||
Cbc.Optimizer,
|
||||
"seconds" => parse(Int, ENV["RELOG_TIME_LIMIT_SEC"]),
|
||||
HiGHS.Optimizer,
|
||||
"time_limit" => parse(Float64, ENV["RELOG_TIME_LIMIT_SEC"]),
|
||||
)
|
||||
ref_solution, ref_model = RELOG.solve(
|
||||
ref_file,
|
||||
heuristic=true,
|
||||
optimizer=optimizer,
|
||||
lp_optimizer=Clp.Optimizer,
|
||||
lp_optimizer=HiGHS.Optimizer,
|
||||
return_model=true,
|
||||
marginal_costs=true,
|
||||
)
|
||||
@@ -61,7 +61,7 @@ function solve(root, filename)
|
||||
ref_model,
|
||||
scenario,
|
||||
optimizer=optimizer,
|
||||
lp_optimizer=Clp.Optimizer,
|
||||
lp_optimizer=HiGHS.Optimizer,
|
||||
)
|
||||
if length(sc_solution) == 0
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user