11#include <gtest/gtest.h>
29 std::vector<Project<double>>
projects = {
30 {0, 100, {},
"Profitable A"},
31 {1, 50, {},
"Profitable B"},
42 std::vector<Project<double>>
projects = {
43 {0, 100, {},
"Project A"},
44 {1, -30, {},
"Infra"},
45 {2, 50, {1},
"Project B"},
59 std::vector<Project<double>>
projects = {
60 {0, -50, {},
"Cost A"},
61 {1, -30, {},
"Cost B"},
72 std::vector<Project<double>>
projects;
82 std::vector<Project<double>>
projects = {
83 {0, 100, {1},
"A needs B"},
84 {1, 50, {0},
"B needs A"},
95 std::vector<Project<double>>
projects = {
96 {0, -10, {},
"Foundation"},
97 {1, -10, {0},
"Level 1"},
98 {2, -10, {1},
"Level 2"},
99 {3, 100, {2},
"Payoff"},
119 std::vector<Team>
teams(4);
121 teams[0].name =
"Atlanta";
123 teams[0].losses = 71;
124 teams[0].remaining = 8;
125 teams[0].against = {0, 1, 6, 1};
127 teams[1].name =
"Philly";
129 teams[1].losses = 79;
130 teams[1].remaining = 3;
131 teams[1].against = {1, 0, 0, 2};
133 teams[2].name =
"New York";
135 teams[2].losses = 78;
136 teams[2].remaining = 6;
137 teams[2].against = {6, 0, 0, 0};
139 teams[3].name =
"Montreal";
141 teams[3].losses = 82;
142 teams[3].remaining = 3;
143 teams[3].against = {1, 2, 0, 0};
151 auto teams = create_simple_division();
162 std::vector<Team>
teams(3);
164 teams[0].name =
"Leader";
166 teams[0].remaining = 0;
167 teams[0].against = {0, 0, 0};
169 teams[1].name =
"Middle";
171 teams[1].remaining = 40;
172 teams[1].against = {0, 0, 40};
174 teams[2].name =
"Loser";
176 teams[2].remaining = 50;
177 teams[2].against = {0, 40, 0};
187 auto teams = create_simple_division();
199 auto teams = create_simple_division();
220 std::vector<std::vector<std::array<double, 2>>> data(2,
221 std::vector<std::array<double, 2>>(2));
224 data[0][0] = {100, 10};
227 data[0][1] = {10, 100};
228 data[1][0] = {10, 100};
229 data[1][1] = {10, 100};
243 std::vector<std::vector<std::array<double, 2>>> data(3,
244 std::vector<std::array<double, 2>>(3));
246 for (
int i = 0; i < 3; ++i)
247 for (
int j = 0; j < 3; ++j)
248 data[i][j] = {100, 10};
253 for (
int i = 0; i < 3; ++i)
254 for (
int j = 0; j < 3; ++j)
260 std::vector<std::vector<std::array<double, 2>>> data;
269 std::vector<std::vector<std::array<double, 2>>> data(1,
270 std::vector<std::array<double, 2>>(1));
272 data[0][0] = {5, 10};
291 std::vector<SurveyQuestion>
questions = {
309 std::vector<SurveyQuestion>
questions = {
324 std::vector<SurveyQuestion>
questions = {
340 for (
const auto& [r, q] : result.assignments)
381 [](
auto*) {
return 0.0; },
382 [](
auto*) {
return 0.0; });
397 std::map<TestNet::Node*, double>
demands;
403 [](
auto*) {
return 0.0; });
423 std::map<TestNet::Node*, double>
demands;
429 [](
auto*) {
return 0.0; });
444 std::map<TestNet::Node*, double>
demands;
474 std::map<TestNet::Node*, double>
demands;
505 [](
auto*) {
return 0.0; },
506 [](
auto*) {
return 0.0; });
528 std::map<TestNet::Node*, double>
demands;
534 [](
auto*) {
return 0.0; });
562 std::map<TestNet::Node*, double>
demands;
568 [](
auto*) {
return 0.0; });
587 [](
auto*) {
return 0.0; },
588 [](
auto*) {
return 0.0; });
596 ::testing::InitGoogleTest(&
argc,
argv);
std::vector< Team > create_simple_division()
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
BaseballEliminationResult check_baseball_elimination(const std::vector< Team > &teams, size_t team_idx)
Check if a team is mathematically eliminated from winning.
ProjectSelectionResult< Value_Type > solve_project_selection(const std::vector< Project< Value_Type > > &projects)
Solve project selection problem using max-flow.
SegmentationResult segment_image(size_t rows, size_t cols, const std::vector< std::vector< std::array< Value_Type, 2 > > > &data_cost, Value_Type smoothness)
Segment image using graph cuts.
SurveyDesignResult design_survey(const std::vector< SurveyQuestion > &questions, const std::vector< SurveyRespondent > &respondents)
Design survey assignment using network flow.
CirculationResult< typename Net::Flow_Type > solve_circulation(Net &net, GetDemand get_demand, GetLower get_lower)
Solve a circulation problem with demands.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Network flow applications.
TEST_F(ProjectSelectionTest, SimpleProjects)
Arc of a flow network implemented with adjacency lists.
Flow network implemented with adjacency lists.
Node * insert_node(const Node_Type &node_info)
Insert a new node by copying node_info.
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.