-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aymane Lotfi
committed
Apr 11, 2024
1 parent
514c2c1
commit 4bb9a0b
Showing
4 changed files
with
42 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "../graph_utils/SpaceTimeNetwork.h" | ||
|
||
TEST(SpaceTimeNetworkTest, BuildVertices) { | ||
operations_research::lattle::LogisticsNetwork network; | ||
int time_horizon = 5; | ||
SpaceTimeNetwork stn(network, time_horizon); | ||
// Creating a network of 10 hubs. | ||
for (int i = 0; i < 10; i++) { | ||
operations_research::lattle::Hub h; | ||
h.set_name("node_"+to_string(i)); | ||
network.mutable_hubs()->Add(move(h)); | ||
} | ||
// Check that the correct number of vertices were created. | ||
ASSERT_EQ(stn.get_vertices().size(), stn.get_underlying_graph().get_vertices().size() * time_horizon); | ||
|
||
// Check that the vertices have the correct graph and time values. | ||
for (int i = 0; i < stn.get_underlying_graph().get_vertices().size(); i++) { | ||
for (int t = 0; t < time_horizon; t++) { | ||
const VertexST& vertex = stn.get_vertex(i, t); | ||
ASSERT_EQ(vertex.get_id_in_graph(), i); | ||
ASSERT_EQ(vertex.get_time(), t); | ||
} | ||
} | ||
} | ||
|
||
//TODO(aymanelotfi) : Improve this by supporting get vertexST by id. | ||
TEST(SpaceTimeNetworkTest, BuildArcs) { | ||
operations_research::lattle::LogisticsNetwork network; | ||
int time_horizon = 5; | ||
SpaceTimeNetwork stn(network, time_horizon); | ||
|
||
// Check that the correct number of arcs were created. | ||
int num_travelling_arcs = 0; | ||
int num_waiting_arcs = 0; | ||
for (const auto& line : network.lines()) { | ||
num_travelling_arcs += (line.hub_ids().size() - 1) * line.next_rotations().size(); | ||
} | ||
num_waiting_arcs = stn.get_underlying_graph().get_vertices().size() * (time_horizon - 1); | ||
ASSERT_EQ(stn.get_arcs().size(), num_travelling_arcs + num_waiting_arcs); | ||
} |