Finish multi-period output; update paths

v0.1
Alinson S. Xavier 5 years ago
parent e37d411bf4
commit 8f59322e3f

1
.gitignore vendored

@ -4,3 +4,4 @@ instances/Makefile
instances/run.jl instances/run.jl
notebooks notebooks
.idea .idea
*.lp

@ -54,15 +54,72 @@
}, },
"F1": { "F1": {
"L1": { "L1": {
"total output": {}, "total output": {
"P2": [
200.0,
200.0
],
"P3": [
500.0,
500.0
]
},
"latitude": 0.0, "latitude": 0.0,
"expansion cost": [ "expansion cost": [
750.0, 750.0,
0.0 0.0
], ],
"output": { "output": {
"dispose": {}, "dispose": {
"send": {} "P2": {
"amount": [
1.0,
1.0
],
"cost": [
-10.0,
-10.0
]
},
"P3": {
"amount": [
1.0,
1.0
],
"cost": [
-10.0,
-10.0
]
}
},
"send": {
"P2": {
"F2": {
"L4": {
"amount": [
199.0,
199.0
],
"latitude": 0.75,
"distance": 85.87,
"longitude": 0.2
}
}
},
"P3": {
"F4": {
"L6": {
"amount": [
499.0,
499.0
],
"latitude": 50.0,
"distance": 6893.41,
"longitude": 50.0
}
}
}
}
}, },
"longitude": 0.0, "longitude": 0.0,
"total input": [ "total input": [
@ -155,7 +212,16 @@
] ]
}, },
"L2": { "L2": {
"total output": {}, "total output": {
"P2": [
747.728,
747.728
],
"P3": [
1869.3199999999997,
1869.3199999999997
]
},
"latitude": 0.5, "latitude": 0.5,
"expansion cost": [ "expansion cost": [
3738.6399999999967, 3738.6399999999967,
@ -163,7 +229,34 @@
], ],
"output": { "output": {
"dispose": {}, "dispose": {},
"send": {} "send": {
"P2": {
"F2": {
"L4": {
"amount": [
747.728,
747.728
],
"latitude": 0.75,
"distance": 43.35,
"longitude": 0.2
}
}
},
"P3": {
"F4": {
"L6": {
"amount": [
1869.3199999999997,
1869.3199999999997
],
"latitude": 50.0,
"distance": 6828.89,
"longitude": 50.0
}
}
}
}
}, },
"longitude": 0.5, "longitude": 0.5,
"total input": [ "total input": [
@ -308,38 +401,17 @@
} }
}, },
"F2": { "F2": {
"L3": {
"total output": {},
"latitude": 25.0,
"expansion cost": [
0.0,
0.0
],
"output": {
"dispose": {},
"send": {}
},
"longitude": 65.0,
"total input": [
0.0,
0.0
],
"fixed operating cost": [
-0.0,
-0.0
],
"input": {},
"opening cost": [
-0.0,
0.0
],
"capacity": [
0.0,
0.0
]
},
"L4": { "L4": {
"total output": {}, "total output": {
"P4": [
757.3824000000001,
757.3824000000001
],
"P3": [
47.336400000000005,
47.336400000000005
]
},
"latitude": 0.75, "latitude": 0.75,
"expansion cost": [ "expansion cost": [
0.0, 0.0,
@ -347,7 +419,34 @@
], ],
"output": { "output": {
"dispose": {}, "dispose": {},
"send": {} "send": {
"P4": {
"F3": {
"L5": {
"amount": [
757.3824000000001,
757.3824000000001
],
"latitude": 100.0,
"distance": 8811.73,
"longitude": 100.0
}
}
},
"P3": {
"F4": {
"L6": {
"amount": [
47.336400000000005,
47.336400000000005
],
"latitude": 50.0,
"distance": 6824.63,
"longitude": 50.0
}
}
}
}
}, },
"longitude": 0.2, "longitude": 0.2,
"total input": [ "total input": [
@ -513,16 +612,16 @@
130.0 130.0
], ],
"total": [ "total": [
225924.922057, 225904.922057,
216936.282057 216916.282057
], ],
"transportation": [ "transportation": [
133.464057, 133.464057,
133.464057 133.464057
], ],
"disposal": [ "disposal": [
0.0, -20.0,
0.0 -20.0
] ]
} }
} }

@ -197,7 +197,7 @@ function get_solution(model::ManufacturingModel)
end end
for plant in instance.plants for plant in instance.plants
skip_plant = false skip_plant = true
process_node = plant_to_process_node[plant] process_node = plant_to_process_node[plant]
plant_dict = Dict{Any, Any}( plant_dict = Dict{Any, Any}(
"input" => Dict(), "input" => Dict(),
@ -261,40 +261,42 @@ function get_solution(model::ManufacturingModel)
output["costs"]["variable operating"] += dict["variable operating cost"] output["costs"]["variable operating"] += dict["variable operating cost"]
end end
# # Outputs # Outputs
# for shipping_node in plant_to_shipping_nodes[plant] for shipping_node in plant_to_shipping_nodes[plant]
# product_name = shipping_node.product.name product_name = shipping_node.product.name
# plant_dict["total output"][product_name] = 0.0 plant_dict["total output"][product_name] = zeros(T)
# plant_dict["output"]["send"][product_name] = product_dict = Dict() plant_dict["output"]["send"][product_name] = product_dict = Dict()
# disposal_amount = JuMP.value(vars.dispose[shipping_node]) disposal_amount = [JuMP.value(vars.dispose[shipping_node, t]) for t in 1:T]
# if disposal_amount > 1e-5 if sum(disposal_amount) > 1e-5
# plant_dict["output"]["dispose"][product_name] = disposal_dict = Dict() skip_plant = false
# disposal_dict["amount"] = JuMP.value(model.vars.dispose[shipping_node]) plant_dict["output"]["dispose"][product_name] = disposal_dict = Dict()
# disposal_dict["cost"] = disposal_dict["amount"] * plant.disposal_cost[shipping_node.product] disposal_dict["amount"] = [JuMP.value(model.vars.dispose[shipping_node, t]) for t in 1:T]
# plant_dict["total output"][product_name] += disposal_amount disposal_dict["cost"] = [disposal_dict["amount"][t] * plant.disposal_cost[shipping_node.product][t]
# output["costs"]["disposal"] += disposal_dict["cost"] for t in 1:T]
# end plant_dict["total output"][product_name] += disposal_amount
output["costs"]["disposal"] += disposal_dict["cost"]
# for a in shipping_node.outgoing_arcs end
# val = JuMP.value(vars.flow[a])
# if val <= 1e-3 for a in shipping_node.outgoing_arcs
# continue vals = [JuMP.value(vars.flow[a, t]) for t in 1:T]
# end if sum(vals) <= 1e-3
# skip_plant = false continue
# dict = Dict( end
# "amount" => val, skip_plant = false
# "distance" => a.values["distance"], dict = Dict(
# "latitude" => a.dest.location.latitude, "amount" => vals,
# "longitude" => a.dest.location.longitude, "distance" => a.values["distance"],
# ) "latitude" => a.dest.location.latitude,
# if a.dest.location.plant_name ∉ keys(product_dict) "longitude" => a.dest.location.longitude,
# product_dict[a.dest.location.plant_name] = Dict() )
# end if a.dest.location.plant_name keys(product_dict)
# product_dict[a.dest.location.plant_name][a.dest.location.location_name] = dict product_dict[a.dest.location.plant_name] = Dict()
# plant_dict["total output"][product_name] += val end
# end product_dict[a.dest.location.plant_name][a.dest.location.location_name] = dict
# end plant_dict["total output"][product_name] += vals
end
end
if !skip_plant if !skip_plant
if plant.plant_name keys(output["plants"]) if plant.plant_name keys(output["plants"])

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

@ -6,7 +6,7 @@ using ReverseManufacturing
@testset "Instance" begin @testset "Instance" begin
@testset "load" begin @testset "load" begin
basedir = dirname(@__FILE__) basedir = dirname(@__FILE__)
instance = ReverseManufacturing.load("$basedir/../instances/samples/s1.json") instance = ReverseManufacturing.load("$basedir/../instances/s1.json")
centers = instance.collection_centers centers = instance.collection_centers
plants = instance.plants plants = instance.plants

@ -6,7 +6,7 @@ using ReverseManufacturing, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormat
@testset "Model" begin @testset "Model" begin
@testset "build" begin @testset "build" begin
basedir = dirname(@__FILE__) basedir = dirname(@__FILE__)
instance = ReverseManufacturing.load("$basedir/../instances/samples/s1.json") instance = ReverseManufacturing.load("$basedir/../instances/s1.json")
graph = ReverseManufacturing.build_graph(instance) graph = ReverseManufacturing.build_graph(instance)
model = ReverseManufacturing.build_model(instance, graph, Cbc.Optimizer) model = ReverseManufacturing.build_model(instance, graph, Cbc.Optimizer)
@ -43,8 +43,8 @@ using ReverseManufacturing, Cbc, JuMP, Printf, JSON, MathOptInterface.FileFormat
end end
@testset "solve" begin @testset "solve" begin
solution = ReverseManufacturing.solve("$(pwd())/../instances/samples/s1.json") solution = ReverseManufacturing.solve("$(pwd())/../instances/s1.json")
#JSON.print(stdout, solution, 4) JSON.print(stdout, solution, 4)
@test "costs" in keys(solution) @test "costs" in keys(solution)
@test "fixed operating" in keys(solution["costs"]) @test "fixed operating" in keys(solution["costs"])

Loading…
Cancel
Save