|
|
@ -5,8 +5,9 @@ using RELOG, JuMP, Printf, JSON, MathOptInterface.FileFormats
|
|
|
|
|
|
|
|
|
|
|
|
basedir = dirname(@__FILE__)
|
|
|
|
basedir = dirname(@__FILE__)
|
|
|
|
|
|
|
|
|
|
|
|
@testset "solve (exact)" begin
|
|
|
|
function model_solve_test()
|
|
|
|
solution = RELOG.solve("$basedir/../../instances/s1.json")
|
|
|
|
@testset "solve (exact)" begin
|
|
|
|
|
|
|
|
solution = RELOG.solve(fixture("instances/s1.json"))
|
|
|
|
|
|
|
|
|
|
|
|
solution_filename = tempname()
|
|
|
|
solution_filename = tempname()
|
|
|
|
RELOG.write(solution, solution_filename)
|
|
|
|
RELOG.write(solution, solution_filename)
|
|
|
@ -32,22 +33,22 @@ basedir = dirname(@__FILE__)
|
|
|
|
total_disposal =
|
|
|
|
total_disposal =
|
|
|
|
sum([loc["Dispose (tonne)"] for loc in values(solution["Products"]["P1"])])
|
|
|
|
sum([loc["Dispose (tonne)"] for loc in values(solution["Products"]["P1"])])
|
|
|
|
@test total_disposal == [1.0, 1.0]
|
|
|
|
@test total_disposal == [1.0, 1.0]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@testset "solve (heuristic)" begin
|
|
|
|
@testset "solve (heuristic)" begin
|
|
|
|
# Should not crash
|
|
|
|
# Should not crash
|
|
|
|
solution = RELOG.solve("$basedir/../../instances/s1.json", heuristic = true)
|
|
|
|
solution = RELOG.solve(fixture("instances/s1.json"), heuristic = true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@testset "solve (infeasible)" begin
|
|
|
|
@testset "solve (infeasible)" begin
|
|
|
|
json = JSON.parsefile("$basedir/../../instances/s1.json")
|
|
|
|
json = JSON.parsefile(fixture("instances/s1.json"))
|
|
|
|
for (location_name, location_dict) in json["products"]["P1"]["initial amounts"]
|
|
|
|
for (location_name, location_dict) in json["products"]["P1"]["initial amounts"]
|
|
|
|
location_dict["amount (tonne)"] *= 1000
|
|
|
|
location_dict["amount (tonne)"] *= 1000
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@test_throws ErrorException("No solution available") RELOG.solve(RELOG.parse(json))
|
|
|
|
@test_throws ErrorException("No solution available") RELOG.solve(RELOG.parse(json))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@testset "solve (with storage)" begin
|
|
|
|
@testset "solve (with storage)" begin
|
|
|
|
basedir = dirname(@__FILE__)
|
|
|
|
basedir = dirname(@__FILE__)
|
|
|
|
filename = "$basedir/../fixtures/storage.json"
|
|
|
|
filename = "$basedir/../fixtures/storage.json"
|
|
|
|
instance = RELOG.parsefile(filename)
|
|
|
|
instance = RELOG.parsefile(filename)
|
|
|
@ -64,4 +65,5 @@ end
|
|
|
|
@test solution["Costs"]["Variable operating (\$)"] == [500.0, 0.0, 100.0]
|
|
|
|
@test solution["Costs"]["Variable operating (\$)"] == [500.0, 0.0, 100.0]
|
|
|
|
@test solution["Costs"]["Storage (\$)"] == [100.0, 75.0, 0.0]
|
|
|
|
@test solution["Costs"]["Storage (\$)"] == [100.0, 75.0, 0.0]
|
|
|
|
@test solution["Costs"]["Total (\$)"] == [600.0, 75.0, 100.0]
|
|
|
|
@test solution["Costs"]["Total (\$)"] == [600.0, 75.0, 100.0]
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|