mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Add new structs for instance
This commit is contained in:
@@ -4,15 +4,62 @@
|
||||
using ReverseManufacturing
|
||||
|
||||
@testset "Instance" begin
|
||||
instance = ReverseManufacturing.load("samples/s1")
|
||||
plants, products = instance.plants, instance.products
|
||||
@test length(products) == 4
|
||||
|
||||
@test sort(collect(keys(plants))) == ["F1", "F2", "F3", "F4"]
|
||||
@test plants["F1"]["input product"] == products["P1"]
|
||||
|
||||
@test sort(collect(keys(products))) == ["P1", "P2", "P3", "P4"]
|
||||
@test products["P1"]["input plants"] == [plants["F1"]]
|
||||
@test products["P1"]["transportation cost"] == 0.015
|
||||
@test products["P1"]["initial amounts"]["C1"]["latitude"] == 7.0
|
||||
@testset "load" begin
|
||||
basedir = dirname(@__FILE__)
|
||||
instance = ReverseManufacturing.load("$basedir/../instances/samples/s1.json")
|
||||
|
||||
centers = instance.collection_centers
|
||||
plants = instance.plants
|
||||
products = instance.products
|
||||
|
||||
plant_name_to_plant = Dict(p.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"
|
||||
@test centers[1].latitude == 7
|
||||
@test centers[1].latitude == 7
|
||||
@test centers[1].longitude == 7
|
||||
@test centers[1].amount == 934.56
|
||||
@test centers[1].product.name == "P1"
|
||||
|
||||
@test length(plants) == 6
|
||||
|
||||
plant = plant_name_to_plant["L1"]
|
||||
@test plant.name == "L1"
|
||||
@test plant.input.name == "P1"
|
||||
@test plant.latitude == 0
|
||||
@test plant.longitude == 0
|
||||
@test plant.opening_cost == 500
|
||||
@test plant.fixed_operating_cost == 30
|
||||
@test plant.variable_operating_cost == 30
|
||||
@test plant.base_capacity == 250
|
||||
@test plant.max_capacity == 1000
|
||||
@test plant.expansion_cost == 1
|
||||
|
||||
@test length(plant.output) == 2
|
||||
@test plant.output[p2] == 0.2
|
||||
@test plant.output[p3] == 0.5
|
||||
|
||||
@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"
|
||||
@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.expansion_cost == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ using Test
|
||||
|
||||
@testset "ReverseManufacturing" begin
|
||||
include("instance_test.jl")
|
||||
include("model_test.jl")
|
||||
#include("model_test.jl")
|
||||
end
|
||||
Reference in New Issue
Block a user