Replace Cbc/Clp by HiGHS

relog-web
Alinson S. Xavier 3 years ago
parent d84b74a8a7
commit 86dee7558b
Signed by: isoron
GPG Key ID: 0DA8E4B9E1109DCA

@ -6,8 +6,6 @@ version = "0.5.2"
[deps]
CRC = "44b605c4-b955-5f2b-9b6d-d2bd01d3d205"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
@ -15,6 +13,7 @@ Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
@ -30,14 +29,12 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"
[compat]
Cbc = "1"
Clp = "1"
CRC = "4"
CSV = "0.10"
DataFrames = "1"
DataStructures = "0.18"
Geodesy = "1"
GZip = "0.5"
Geodesy = "1"
HTTP = "0.9"
JSON = "0.21"
JSONSchema = "1"

@ -101,7 +101,7 @@ To use the `resolve` method, the new input file should be very similar to the or
### 5.1 Changing the solver
By default, RELOG internally uses [Cbc](https://github.com/coin-or/Cbc), an open-source and freely-available Mixed-Integer Linear Programming solver developed by the [COIN-OR Project](https://www.coin-or.org/). For larger-scale test cases, a commercial solver such as Gurobi, CPLEX or XPRESS is recommended. The following snippet shows how to switch from Cbc to Gurobi, for example:
By default, RELOG internally uses [HiGHS](https://github.com/ERGO-Code/HiGHS), an open-source and freely-available Mixed-Integer Linear Programming solver. For larger-scale test cases, a commercial solver such as Gurobi, CPLEX or XPRESS is recommended. The following snippet shows how to switch to Gurobi, for example:
```julia
using RELOG, Gurobi, JuMP

@ -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

@ -1,14 +1,13 @@
# Copyright (C) 2020 Argonne National Laboratory
# Written by Alinson Santos Xavier <axavier@anl.gov>
using RELOG, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormats
using RELOG, HiGHS, JuMP, Printf, JSON, MathOptInterface.FileFormats
@testset "build" begin
basedir = dirname(@__FILE__)
instance = RELOG.parsefile("$basedir/../../instances/s1.json")
graph = RELOG.build_graph(instance)
model = RELOG.build_model(instance, graph, Cbc.Optimizer)
set_optimizer_attribute(model, "logLevel", 0)
model = RELOG.build_model(instance, graph, HiGHS.Optimizer)
process_node_by_location_name =
Dict(n.location.location_name => n for n in graph.process_nodes)

@ -1,7 +1,7 @@
# Copyright (C) 2020 Argonne National Laboratory
# Written by Alinson Santos Xavier <axavier@anl.gov>
using RELOG, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormats
using RELOG, JuMP, Printf, JSON, MathOptInterface.FileFormats
basedir = dirname(@__FILE__)

Loading…
Cancel
Save