10#include <gtest/gtest.h>
29 flow += it.get_curr()->flow;
118 auto net = build_diamond_network();
206 auto [flow, cost] =
ssp(net);
215 auto net_ssp = build_diamond_network();
216 auto net_cc = build_diamond_network();
274 auto net1 = build_diamond_network();
275 auto net2 = build_diamond_network();
317 std::vector<std::vector<Node*>>
nodes(
SIZE, std::vector<Node*>(
SIZE));
319 for (
int i = 0; i <
SIZE; ++i)
320 for (
int j = 0; j <
SIZE; ++j)
324 for (
int i = 0; i <
SIZE; ++i)
325 for (
int j = 0; j <
SIZE - 1; ++j)
331 for (
int i = 0; i <
SIZE - 1; ++i)
332 for (
int j = 0; j <
SIZE; ++j)
335 1.0 + ((i+1)*j) % 3);
353 std::cout <<
"\nGrid " <<
SIZE <<
"x" <<
SIZE <<
" results:\n";
355 std::cout <<
" CC: Flow=" <<
flow_cc <<
", Cost=" <<
cost_cc <<
"\n";
365 std::vector<std::vector<double>>
costs = {
380 std::vector<std::vector<double>>
costs = {{42}};
391 std::vector<std::vector<double>>
costs;
401 std::vector<std::vector<double>>
costs = {
423 std::vector<double>
supplies = {100, 100};
424 std::vector<double>
demands = {100, 100};
425 std::vector<std::vector<double>>
costs = {
438 std::vector<double>
supplies = {100, 100};
439 std::vector<double>
demands = {50, 50};
441 std::vector<std::vector<double>>
costs = {
454 std::vector<double>
supplies = {50, 60, 40};
455 std::vector<double>
demands = {30, 40, 50, 30};
456 std::vector<std::vector<double>>
costs = {
469 for (
size_t i = 0; i < result.shipments.size(); ++i)
470 for (
size_t j = 0; j < result.shipments[i].size(); ++j)
479 ::testing::InitGoogleTest(&
argc,
argv);
WeightedDigraph::Node Node
bool has_curr() const noexcept
Return true the iterator has an current arc.
Filtered iterator for outcoming arcs of a node.
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
std::tuple< size_t, double > max_flow_min_cost_by_cycle_canceling(Net &net, double it_factor=0.4, size_t step=10)
Compute maximum flow at minimum cost using cycle canceling.
TransportationResult< Cost_Type > solve_transportation(const std::vector< Cost_Type > &supplies, const std::vector< Cost_Type > &demands, const std::vector< std::vector< Cost_Type > > &costs)
Solve the transportation problem using min-cost flow.
std::pair< typename Net::Flow_Type, typename Net::Flow_Type > successive_shortest_paths(Net &net)
Compute minimum cost maximum flow using Successive Shortest Paths.
AssignmentResult< Cost_Type > solve_assignment(const std::vector< std::vector< Cost_Type > > &costs)
Solve the assignment problem using min-cost flow.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Capacitated flow network with costs associated to arcs.
Flow network implemented with adjacency lists.
Node * insert_node(const Node_Type &node_info)
Insert a new node by copying node_info.
bool check_network() const
Validate flow-conservation and capacity constraints.
Node * get_source() const
Return an arbitrary source node.
Arc * insert_arc(Node *src_node, Node *tgt_node, const Flow_Type &cap, const Flow_Type &flow, const typename Arc::Arc_Type &arc_info=Arc_Type())
Insert a capacitated arc with an initial flow.
Functor wrapper for SSP algorithm.
Advanced minimum cost flow algorithms.
Maximum flow minimum cost network algorithms.