21 #ifndef OPHIDIAN_SRC_ROUTING_GRID_3D_H
22 #define OPHIDIAN_SRC_ROUTING_GRID_3D_H
24 #include <lemon/grid_graph.h>
41 lemon::GridGraph m_graph;
42 lemon::GridGraph::EdgeMap<unsigned> m_edges_capacities;
43 lemon::GridGraph::EdgeMap<unsigned> m_edges_demands;
67 std::vector<std::unique_ptr<grid_2d> > m_vector_of_grid_2D;
84 inline int width(){
return m_width;}
91 inline int height(){
return m_height;}
98 inline int depth(){
return m_depth;}
116 assert(x < m_width-1);
117 assert(y < m_height);
120 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
122 return grid_2d.m_edges_capacities[arc];
136 assert(y < m_height-1);
139 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
141 return grid_2d.m_edges_capacities[arc];
154 assert(x < m_width-1);
155 assert(y < m_height);
158 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
160 grid_2d.m_edges_capacities[arc] = capacity;
174 assert(y < m_height-1);
177 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
179 grid_2d.m_edges_capacities[arc] = capacity;
192 assert(x < m_width-1);
193 assert(y < m_height);
196 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
198 return grid_2d.m_edges_demands[arc];
212 assert(y < m_height-1);
215 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
217 return grid_2d.m_edges_demands[arc];
230 assert(x < m_width-1);
231 assert(y < m_height);
234 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
236 grid_2d.m_edges_demands[arc] = demand;
250 assert(y < m_height-1);
253 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
255 grid_2d.m_edges_demands[arc] = demand;
267 assert(x < m_width-1);
268 assert(y < m_height);
271 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
273 grid_2d.m_edges_demands[arc] += 1;
286 assert(y < m_height-1);
289 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
291 grid_2d.m_edges_demands[arc] += 1;
304 assert(x < m_width-1);
305 assert(y < m_height);
308 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
310 auto capacity =
grid_2d.m_edges_capacities[arc];
311 auto demand =
grid_2d.m_edges_demands[arc];
312 return capacity - demand;
326 assert(y < m_height-1);
329 auto &
grid_2d = *m_vector_of_grid_2D.at(z);
331 auto capacity =
grid_2d.m_edges_capacities[arc];
332 auto demand =
grid_2d.m_edges_demands[arc];
333 return capacity - demand;
351 void get_max_and_total_edges_overflow(
int & max_overflow,
int & total_overflow);
357 #endif // OPHIDIAN_SRC_ROUTING_GRID_3D_H
int depth()
Get grid depth.
Definition: grid_3d.h:98
Grid_3d class.
Definition: grid_3d.h:62
void set_horizontal_edge_capacity(int x, int y, int z, unsigned capacity)
Set the capacity of a given horizontal edge.
Definition: grid_3d.h:152
unsigned get_horizontal_edge_demand(int x, int y, int z)
Get the demand of a given horizontal edge.
Definition: grid_3d.h:190
void increment_horizontal_edge_demand(int x, int y, int z)
Increment the demand of a given horizontal edge.
Definition: grid_3d.h:265
grid_2d(int width, int height)
Constructor.
Definition: grid_3d.cpp:30
unsigned get_vertical_edge_demand(int x, int y, int z)
Get the demand of a given vertical edge.
Definition: grid_3d.h:209
unsigned get_vertical_edge_capacity(int x, int y, int z)
Get capacity of a given vertical edge.
Definition: grid_3d.h:133
int height()
Get grid height.
Definition: grid_3d.h:91
void set_vertical_edge_demand(int x, int y, int z, unsigned demand)
Set the demand of a given vertical edge.
Definition: grid_3d.h:247
int get_vertical_edge_utilization_gap(int x, int y, int z)
Get the utilization gap of a given vertical edge.
Definition: grid_3d.h:323
void set_vertical_edge_capacity(int x, int y, int z, unsigned capacity)
Set the capacity of a given vertical edge.
Definition: grid_3d.h:171
void set_horizontal_edge_demand(int x, int y, int z, unsigned demand)
Set the demand of a given horizontal edge.
Definition: grid_3d.h:228
unsigned get_horizontal_edge_capacity(int x, int y, int z)
Get capacity of a given horizontal edge.
Definition: grid_3d.h:114
void get_max_and_total_edges_overflow(int &max_overflow, int &total_overflow)
Get the maximum and total edge overflow in the 3d grid.
void increment_vertical_edge_demand(int x, int y, int z)
Increment the demand of a given vertical edge.
Definition: grid_3d.h:283
int get_horizontal_edge_utilization_gap(int x, int y, int z)
Get the utilization gap of a given horizontal edge.
Definition: grid_3d.h:302
Grid_2d class.
Definition: grid_3d.h:37
Definition: grid_3d.h:345
int width()
Get grid width.
Definition: grid_3d.h:84
void reset_edge_demands()
Reset all edge demands to zero.
Definition: grid_3d.cpp:51
grid_3d(int width, int height, int depth)
Constructor.
Definition: grid_3d.cpp:40