mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-08 08:28:52 -06:00
Move graph creation to graph.jl; simplify model.jl
This commit is contained in:
42
test/graph_test.jl
Normal file
42
test/graph_test.jl
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (C) 2020 Argonne National Laboratory
|
||||
# Written by Alinson Santos Xavier <axavier@anl.gov>
|
||||
|
||||
using ReverseManufacturing
|
||||
|
||||
@testset "Graph" begin
|
||||
@testset "build_graph" begin
|
||||
basedir = dirname(@__FILE__)
|
||||
instance = ReverseManufacturing.load("$basedir/../instances/samples/s1.json")
|
||||
graph = ReverseManufacturing.build_graph(instance)
|
||||
process_node_by_location_name = Dict(n.plant.location_name => n
|
||||
for n in graph.process_nodes)
|
||||
|
||||
@test length(graph.plant_shipping_nodes) == 8
|
||||
@test length(graph.collection_shipping_nodes) == 10
|
||||
@test length(graph.process_nodes) == 6
|
||||
|
||||
node = graph.collection_shipping_nodes[1]
|
||||
@test node.location.name == "C1"
|
||||
@test length(node.incoming_arcs) == 0
|
||||
@test length(node.outgoing_arcs) == 2
|
||||
@test node.outgoing_arcs[1].source.location.name == "C1"
|
||||
@test node.outgoing_arcs[1].dest.plant.plant_name == "F1"
|
||||
@test node.outgoing_arcs[1].dest.plant.location_name == "L1"
|
||||
@test node.outgoing_arcs[1].values["distance"] == 1095.62
|
||||
|
||||
node = process_node_by_location_name["L1"]
|
||||
@test node.plant.plant_name == "F1"
|
||||
@test node.plant.location_name == "L1"
|
||||
@test length(node.incoming_arcs) == 10
|
||||
@test length(node.outgoing_arcs) == 2
|
||||
|
||||
node = process_node_by_location_name["L3"]
|
||||
@test node.plant.plant_name == "F2"
|
||||
@test node.plant.location_name == "L3"
|
||||
@test length(node.incoming_arcs) == 2
|
||||
@test length(node.outgoing_arcs) == 2
|
||||
|
||||
@test length(graph.arcs) == 38
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user