Improve error message when instance is infeasible

This commit is contained in:
2020-08-13 10:21:29 -05:00
parent 44df06bbfa
commit d8c9a1b30a
5 changed files with 43 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ using RELOG
@testset "Graph" begin
@testset "build_graph" begin
basedir = dirname(@__FILE__)
instance = RELOG.load("$basedir/../instances/s1.json")
instance = RELOG.parsefile("$basedir/../instances/s1.json")
graph = RELOG.build_graph(instance)
process_node_by_location_name = Dict(n.location.location_name => n
for n in graph.process_nodes)

View File

@@ -6,7 +6,7 @@ using RELOG
@testset "Instance" begin
@testset "load" begin
basedir = dirname(@__FILE__)
instance = RELOG.load("$basedir/../instances/s1.json")
instance = RELOG.parsefile("$basedir/../instances/s1.json")
centers = instance.collection_centers
plants = instance.plants
@@ -73,7 +73,7 @@ using RELOG
end
@testset "validate timeseries" begin
@test_throws String RELOG.load("fixtures/s1-wrong-length.json")
@test_throws String RELOG.parsefile("fixtures/s1-wrong-length.json")
end
end

View File

@@ -6,7 +6,7 @@ using RELOG, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormats
@testset "Model" begin
@testset "build" begin
basedir = dirname(@__FILE__)
instance = RELOG.load("$basedir/../instances/s1.json")
instance = RELOG.parsefile("$basedir/../instances/s1.json")
graph = RELOG.build_graph(instance)
model = RELOG.build_model(instance, graph, Cbc.Optimizer)
set_optimizer_attribute(model.mip, "logLevel", 0)
@@ -43,7 +43,6 @@ using RELOG, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormats
@testset "solve" begin
solution = RELOG.solve("$(pwd())/../instances/s1.json")
#JSON.print(stdout, solution, 4)
@test "Costs" in keys(solution)
@test "Fixed operating (\$)" in keys(solution["Costs"])
@@ -57,6 +56,15 @@ using RELOG, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormats
@test "F3" in keys(solution["Plants"])
@test "F4" in keys(solution["Plants"])
end
@testset "infeasible solve" begin
json = JSON.parsefile("$(pwd())/../instances/s1.json")
for (location_name, location_dict) in json["products"]["P1"]["initial amounts"]
location_dict["amount (tonne)"] *= 1000
end
RELOG.solve(RELOG.parse(json))
end
end