Move graph creation to graph.jl; simplify model.jl

This commit is contained in:
2020-05-03 16:04:57 -05:00
parent aa4f6537fe
commit cbd7bc5247
8 changed files with 458 additions and 484 deletions

View File

@@ -12,11 +12,9 @@ using ReverseManufacturing
plants = instance.plants
products = instance.products
plant_name_to_plant = Dict(p.name => p for p in plants)
location_name_to_plant = Dict(p.location_name => p for p in plants)
product_name_to_product = Dict(p.name => p for p in products)
p2 = product_name_to_product["P2"]
p3 = product_name_to_product["P3"]
@test length(centers) == 10
@test centers[1].name == "C1"
@@ -28,8 +26,9 @@ using ReverseManufacturing
@test length(plants) == 6
plant = plant_name_to_plant["L1"]
@test plant.name == "L1"
plant = location_name_to_plant["L1"]
@test plant.plant_name == "F1"
@test plant.location_name == "L1"
@test plant.input.name == "P1"
@test plant.latitude == 0
@test plant.longitude == 0
@@ -40,26 +39,33 @@ using ReverseManufacturing
@test plant.max_capacity == 1000
@test plant.expansion_cost == 1
p2 = product_name_to_product["P2"]
p3 = product_name_to_product["P3"]
@test length(plant.output) == 2
@test plant.output[p2] == 0.2
@test plant.output[p3] == 0.5
@test plant.disposal_limit[p2] == 1
@test plant.disposal_limit[p3] == 1
@test plant.disposal_cost[p2] == -10
@test plant.disposal_cost[p3] == -10
@test length(plant.disposal) == 2
@test plant.disposal[1].product.name == "P2"
@test plant.disposal[1].cost == -10
@test plant.disposal[1].limit == 1
plant = plant_name_to_plant["L3"]
@test plant.name == "L3"
plant = location_name_to_plant["L3"]
@test plant.location_name == "L3"
@test plant.input.name == "P2"
@test plant.latitude == 25
@test plant.longitude == 65
@test plant.opening_cost == 3000
@test plant.fixed_operating_cost == 50
@test plant.variable_operating_cost == 50
@test plant.base_capacity == Inf
@test plant.max_capacity == Inf
@test plant.base_capacity == 1e8
@test plant.max_capacity == 1e8
@test plant.expansion_cost == 0
p4 = product_name_to_product["P4"]
@test plant.output[p3] == 0.05
@test plant.output[p4] == 0.8
@test plant.disposal_limit[p3] == 0.0
@test plant.disposal_limit[p4] == 0.0
end
end