kpeter@648: /* -*- mode: C++; indent-tabs-mode: nil; -*- kpeter@648: * kpeter@648: * This file is a part of LEMON, a generic C++ optimization library. kpeter@648: * alpar@1270: * Copyright (C) 2003-2013 kpeter@648: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport kpeter@648: * (Egervary Research Group on Combinatorial Optimization, EGRES). kpeter@648: * kpeter@648: * Permission to use, modify and distribute this software is granted kpeter@648: * provided that this copyright notice appears in all copies. For kpeter@648: * precise terms see the accompanying LICENSE file. kpeter@648: * kpeter@648: * This software is provided "AS IS" with no warranty of any kind, kpeter@648: * express or implied, and with no claim as to its suitability for any kpeter@648: * purpose. kpeter@648: * kpeter@648: */ kpeter@648: kpeter@648: #include kpeter@648: #include kpeter@687: #include kpeter@648: kpeter@648: #include kpeter@648: #include kpeter@648: kpeter@648: #include kpeter@885: #include kpeter@885: #include kpeter@885: #include kpeter@648: kpeter@648: #include kpeter@885: #include kpeter@648: #include kpeter@648: kpeter@648: #include "test_tools.h" kpeter@648: kpeter@648: using namespace lemon; kpeter@648: kpeter@884: // Test networks kpeter@648: char test_lgf[] = kpeter@648: "@nodes\n" kpeter@687: "label sup1 sup2 sup3 sup4 sup5 sup6\n" kpeter@687: " 1 20 27 0 30 20 30\n" kpeter@687: " 2 -4 0 0 0 -8 -3\n" kpeter@687: " 3 0 0 0 0 0 0\n" kpeter@687: " 4 0 0 0 0 0 0\n" kpeter@687: " 5 9 0 0 0 6 11\n" kpeter@687: " 6 -6 0 0 0 -5 -6\n" kpeter@687: " 7 0 0 0 0 0 0\n" kpeter@687: " 8 0 0 0 0 0 3\n" kpeter@687: " 9 3 0 0 0 0 0\n" kpeter@687: " 10 -2 0 0 0 -7 -2\n" kpeter@687: " 11 0 0 0 0 -10 0\n" kpeter@687: " 12 -20 -27 0 -30 -30 -20\n" alpar@956: "\n" kpeter@648: "@arcs\n" kpeter@687: " cost cap low1 low2 low3\n" kpeter@687: " 1 2 70 11 0 8 8\n" kpeter@687: " 1 3 150 3 0 1 0\n" kpeter@687: " 1 4 80 15 0 2 2\n" kpeter@687: " 2 8 80 12 0 0 0\n" kpeter@687: " 3 5 140 5 0 3 1\n" kpeter@687: " 4 6 60 10 0 1 0\n" kpeter@687: " 4 7 80 2 0 0 0\n" kpeter@687: " 4 8 110 3 0 0 0\n" kpeter@687: " 5 7 60 14 0 0 0\n" kpeter@687: " 5 11 120 12 0 0 0\n" kpeter@687: " 6 3 0 3 0 0 0\n" kpeter@687: " 6 9 140 4 0 0 0\n" kpeter@687: " 6 10 90 8 0 0 0\n" kpeter@687: " 7 1 30 5 0 0 -5\n" kpeter@687: " 8 12 60 16 0 4 3\n" kpeter@687: " 9 12 50 6 0 0 0\n" kpeter@687: "10 12 70 13 0 5 2\n" kpeter@687: "10 2 100 7 0 0 0\n" kpeter@687: "10 7 60 10 0 0 -3\n" kpeter@687: "11 10 20 14 0 6 -20\n" kpeter@687: "12 11 30 10 0 0 -10\n" kpeter@648: "\n" kpeter@648: "@attributes\n" kpeter@648: "source 1\n" kpeter@648: "target 12\n"; kpeter@648: kpeter@884: char test_neg1_lgf[] = kpeter@884: "@nodes\n" kpeter@884: "label sup\n" kpeter@884: " 1 100\n" kpeter@884: " 2 0\n" kpeter@884: " 3 0\n" kpeter@884: " 4 -100\n" kpeter@884: " 5 0\n" kpeter@884: " 6 0\n" kpeter@884: " 7 0\n" kpeter@884: "@arcs\n" kpeter@884: " cost low1 low2\n" kpeter@884: "1 2 100 0 0\n" kpeter@884: "1 3 30 0 0\n" kpeter@884: "2 4 20 0 0\n" kpeter@884: "3 4 80 0 0\n" kpeter@884: "3 2 50 0 0\n" kpeter@884: "5 3 10 0 0\n" kpeter@884: "5 6 80 0 1000\n" kpeter@884: "6 7 30 0 -1000\n" kpeter@884: "7 5 -120 0 0\n"; alpar@956: kpeter@884: char test_neg2_lgf[] = kpeter@884: "@nodes\n" kpeter@884: "label sup\n" kpeter@884: " 1 100\n" kpeter@884: " 2 -300\n" kpeter@884: "@arcs\n" kpeter@884: " cost\n" kpeter@884: "1 2 -1\n"; kpeter@884: kpeter@884: kpeter@884: // Test data kpeter@884: typedef ListDigraph Digraph; kpeter@884: DIGRAPH_TYPEDEFS(ListDigraph); kpeter@884: kpeter@884: Digraph gr; kpeter@884: Digraph::ArcMap c(gr), l1(gr), l2(gr), l3(gr), u(gr); kpeter@884: Digraph::NodeMap s1(gr), s2(gr), s3(gr), s4(gr), s5(gr), s6(gr); kpeter@884: ConstMap cc(1), cu(std::numeric_limits::max()); kpeter@884: Node v, w; kpeter@884: kpeter@884: Digraph neg1_gr; kpeter@884: Digraph::ArcMap neg1_c(neg1_gr), neg1_l1(neg1_gr), neg1_l2(neg1_gr); kpeter@884: ConstMap neg1_u1(std::numeric_limits::max()), neg1_u2(5000); kpeter@884: Digraph::NodeMap neg1_s(neg1_gr); kpeter@884: kpeter@884: Digraph neg2_gr; kpeter@884: Digraph::ArcMap neg2_c(neg2_gr); kpeter@884: ConstMap neg2_l(0), neg2_u(1000); kpeter@884: Digraph::NodeMap neg2_s(neg2_gr); kpeter@884: kpeter@648: kpeter@687: enum SupplyType { kpeter@656: EQ, kpeter@656: GEQ, kpeter@656: LEQ kpeter@656: }; kpeter@656: kpeter@884: kpeter@648: // Check the interface of an MCF algorithm kpeter@689: template kpeter@648: class McfClassConcept kpeter@648: { kpeter@648: public: kpeter@648: kpeter@648: template kpeter@648: struct Constraints { kpeter@648: void constraints() { kpeter@648: checkConcept(); alpar@956: kpeter@716: const Constraints& me = *this; kpeter@648: kpeter@716: MCF mcf(me.g); kpeter@689: const MCF& const_mcf = mcf; kpeter@648: kpeter@898: b = mcf.reset().resetParams() kpeter@716: .lowerMap(me.lower) kpeter@716: .upperMap(me.upper) kpeter@716: .costMap(me.cost) kpeter@716: .supplyMap(me.sup) kpeter@716: .stSupply(me.n, me.n, me.k) kpeter@652: .run(); kpeter@652: kpeter@687: c = const_mcf.totalCost(); kpeter@689: x = const_mcf.template totalCost(); kpeter@716: v = const_mcf.flow(me.a); kpeter@716: c = const_mcf.potential(me.n); kpeter@689: const_mcf.flowMap(fm); kpeter@689: const_mcf.potentialMap(pm); kpeter@648: } kpeter@648: kpeter@648: typedef typename GR::Node Node; kpeter@648: typedef typename GR::Arc Arc; kpeter@689: typedef concepts::ReadMap NM; kpeter@689: typedef concepts::ReadMap VAM; kpeter@654: typedef concepts::ReadMap CAM; kpeter@689: typedef concepts::WriteMap FlowMap; kpeter@689: typedef concepts::WriteMap PotMap; alpar@956: kpeter@716: GR g; kpeter@716: VAM lower; kpeter@716: VAM upper; kpeter@716: CAM cost; kpeter@716: NM sup; kpeter@716: Node n; kpeter@716: Arc a; kpeter@716: Value k; kpeter@648: kpeter@689: FlowMap fm; kpeter@689: PotMap pm; kpeter@652: bool b; kpeter@689: double x; kpeter@689: typename MCF::Value v; kpeter@689: typename MCF::Cost c; kpeter@648: }; kpeter@648: kpeter@648: }; kpeter@648: kpeter@648: kpeter@648: // Check the feasibility of the given flow (primal soluiton) kpeter@648: template < typename GR, typename LM, typename UM, kpeter@648: typename SM, typename FM > kpeter@648: bool checkFlow( const GR& gr, const LM& lower, const UM& upper, kpeter@656: const SM& supply, const FM& flow, kpeter@687: SupplyType type = EQ ) kpeter@648: { kpeter@648: TEMPLATE_DIGRAPH_TYPEDEFS(GR); kpeter@648: kpeter@648: for (ArcIt e(gr); e != INVALID; ++e) { kpeter@648: if (flow[e] < lower[e] || flow[e] > upper[e]) return false; kpeter@648: } kpeter@648: kpeter@648: for (NodeIt n(gr); n != INVALID; ++n) { kpeter@648: typename SM::Value sum = 0; kpeter@648: for (OutArcIt e(gr, n); e != INVALID; ++e) kpeter@648: sum += flow[e]; kpeter@648: for (InArcIt e(gr, n); e != INVALID; ++e) kpeter@648: sum -= flow[e]; kpeter@656: bool b = (type == EQ && sum == supply[n]) || kpeter@656: (type == GEQ && sum >= supply[n]) || kpeter@656: (type == LEQ && sum <= supply[n]); kpeter@656: if (!b) return false; kpeter@648: } kpeter@648: kpeter@648: return true; kpeter@648: } kpeter@648: kpeter@648: // Check the feasibility of the given potentials (dual soluiton) kpeter@652: // using the "Complementary Slackness" optimality condition kpeter@648: template < typename GR, typename LM, typename UM, kpeter@656: typename CM, typename SM, typename FM, typename PM > kpeter@648: bool checkPotential( const GR& gr, const LM& lower, const UM& upper, alpar@956: const CM& cost, const SM& supply, const FM& flow, kpeter@711: const PM& pi, SupplyType type ) kpeter@648: { kpeter@648: TEMPLATE_DIGRAPH_TYPEDEFS(GR); kpeter@648: kpeter@648: bool opt = true; kpeter@648: for (ArcIt e(gr); opt && e != INVALID; ++e) { kpeter@648: typename CM::Value red_cost = kpeter@648: cost[e] + pi[gr.source(e)] - pi[gr.target(e)]; kpeter@648: opt = red_cost == 0 || kpeter@648: (red_cost > 0 && flow[e] == lower[e]) || kpeter@648: (red_cost < 0 && flow[e] == upper[e]); kpeter@648: } alpar@956: kpeter@656: for (NodeIt n(gr); opt && n != INVALID; ++n) { kpeter@656: typename SM::Value sum = 0; kpeter@656: for (OutArcIt e(gr, n); e != INVALID; ++e) kpeter@656: sum += flow[e]; kpeter@656: for (InArcIt e(gr, n); e != INVALID; ++e) kpeter@656: sum -= flow[e]; kpeter@711: if (type != LEQ) { kpeter@711: opt = (pi[n] <= 0) && (sum == supply[n] || pi[n] == 0); kpeter@711: } else { kpeter@711: opt = (pi[n] >= 0) && (sum == supply[n] || pi[n] == 0); kpeter@711: } kpeter@656: } alpar@956: kpeter@648: return opt; kpeter@648: } kpeter@648: kpeter@711: // Check whether the dual cost is equal to the primal cost kpeter@711: template < typename GR, typename LM, typename UM, kpeter@711: typename CM, typename SM, typename PM > kpeter@711: bool checkDualCost( const GR& gr, const LM& lower, const UM& upper, kpeter@711: const CM& cost, const SM& supply, const PM& pi, kpeter@711: typename CM::Value total ) kpeter@711: { kpeter@711: TEMPLATE_DIGRAPH_TYPEDEFS(GR); kpeter@711: kpeter@711: typename CM::Value dual_cost = 0; kpeter@711: SM red_supply(gr); kpeter@711: for (NodeIt n(gr); n != INVALID; ++n) { kpeter@711: red_supply[n] = supply[n]; kpeter@711: } kpeter@711: for (ArcIt a(gr); a != INVALID; ++a) { kpeter@711: if (lower[a] != 0) { kpeter@711: dual_cost += lower[a] * cost[a]; kpeter@711: red_supply[gr.source(a)] -= lower[a]; kpeter@711: red_supply[gr.target(a)] += lower[a]; kpeter@711: } kpeter@711: } alpar@956: kpeter@711: for (NodeIt n(gr); n != INVALID; ++n) { kpeter@711: dual_cost -= red_supply[n] * pi[n]; kpeter@711: } kpeter@711: for (ArcIt a(gr); a != INVALID; ++a) { kpeter@711: typename CM::Value red_cost = kpeter@711: cost[a] + pi[gr.source(a)] - pi[gr.target(a)]; kpeter@711: dual_cost -= (upper[a] - lower[a]) * std::max(-red_cost, 0); kpeter@711: } alpar@956: kpeter@711: return dual_cost == total; kpeter@711: } kpeter@711: kpeter@648: // Run a minimum cost flow algorithm and check the results kpeter@648: template < typename MCF, typename GR, kpeter@648: typename LM, typename UM, kpeter@687: typename CM, typename SM, kpeter@687: typename PT > kpeter@687: void checkMcf( const MCF& mcf, PT mcf_result, kpeter@648: const GR& gr, const LM& lower, const UM& upper, kpeter@648: const CM& cost, const SM& supply, kpeter@687: PT result, bool optimal, typename CM::Value total, kpeter@656: const std::string &test_id = "", kpeter@687: SupplyType type = EQ ) kpeter@648: { kpeter@648: check(mcf_result == result, "Wrong result " + test_id); kpeter@687: if (optimal) { kpeter@689: typename GR::template ArcMap flow(gr); kpeter@689: typename GR::template NodeMap pi(gr); kpeter@689: mcf.flowMap(flow); kpeter@689: mcf.potentialMap(pi); kpeter@689: check(checkFlow(gr, lower, upper, supply, flow, type), kpeter@648: "The flow is not feasible " + test_id); kpeter@648: check(mcf.totalCost() == total, "The flow is not optimal " + test_id); kpeter@711: check(checkPotential(gr, lower, upper, cost, supply, flow, pi, type), kpeter@648: "Wrong potentials " + test_id); kpeter@711: check(checkDualCost(gr, lower, upper, cost, supply, pi, total), kpeter@711: "Wrong dual cost " + test_id); kpeter@648: } kpeter@648: } kpeter@648: kpeter@884: template < typename MCF, typename Param > kpeter@884: void runMcfGeqTests( Param param, kpeter@884: const std::string &test_str = "", kpeter@884: bool full_neg_cost_support = false ) kpeter@884: { kpeter@884: MCF mcf1(gr), mcf2(neg1_gr), mcf3(neg2_gr); alpar@956: kpeter@884: // Basic tests kpeter@884: mcf1.upperMap(u).costMap(c).supplyMap(s1); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s1, kpeter@884: mcf1.OPTIMAL, true, 5240, test_str + "-1"); kpeter@884: mcf1.stSupply(v, w, 27); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s2, kpeter@884: mcf1.OPTIMAL, true, 7620, test_str + "-2"); kpeter@884: mcf1.lowerMap(l2).supplyMap(s1); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s1, kpeter@884: mcf1.OPTIMAL, true, 5970, test_str + "-3"); kpeter@884: mcf1.stSupply(v, w, 27); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s2, kpeter@884: mcf1.OPTIMAL, true, 8010, test_str + "-4"); kpeter@898: mcf1.resetParams().supplyMap(s1); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, cu, cc, s1, kpeter@884: mcf1.OPTIMAL, true, 74, test_str + "-5"); kpeter@884: mcf1.lowerMap(l2).stSupply(v, w, 27); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, cu, cc, s2, kpeter@884: mcf1.OPTIMAL, true, 94, test_str + "-6"); kpeter@884: mcf1.reset(); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, cu, cc, s3, kpeter@884: mcf1.OPTIMAL, true, 0, test_str + "-7"); kpeter@884: mcf1.lowerMap(l2).upperMap(u); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, cc, s3, kpeter@884: mcf1.INFEASIBLE, false, 0, test_str + "-8"); kpeter@884: mcf1.lowerMap(l3).upperMap(u).costMap(c).supplyMap(s4); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l3, u, c, s4, kpeter@884: mcf1.OPTIMAL, true, 6360, test_str + "-9"); kpeter@884: kpeter@884: // Tests for the GEQ form kpeter@898: mcf1.resetParams().upperMap(u).costMap(c).supplyMap(s5); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s5, kpeter@884: mcf1.OPTIMAL, true, 3530, test_str + "-10", GEQ); kpeter@884: mcf1.lowerMap(l2); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s5, kpeter@884: mcf1.OPTIMAL, true, 4540, test_str + "-11", GEQ); kpeter@884: mcf1.supplyMap(s6); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s6, kpeter@884: mcf1.INFEASIBLE, false, 0, test_str + "-12", GEQ); kpeter@884: kpeter@884: // Tests with negative costs kpeter@884: mcf2.lowerMap(neg1_l1).costMap(neg1_c).supplyMap(neg1_s); kpeter@884: checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l1, neg1_u1, neg1_c, neg1_s, kpeter@884: mcf2.UNBOUNDED, false, 0, test_str + "-13"); kpeter@884: mcf2.upperMap(neg1_u2); kpeter@884: checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l1, neg1_u2, neg1_c, neg1_s, kpeter@884: mcf2.OPTIMAL, true, -40000, test_str + "-14"); kpeter@898: mcf2.resetParams().lowerMap(neg1_l2).costMap(neg1_c).supplyMap(neg1_s); kpeter@884: checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l2, neg1_u1, neg1_c, neg1_s, kpeter@884: mcf2.UNBOUNDED, false, 0, test_str + "-15"); kpeter@884: kpeter@884: mcf3.costMap(neg2_c).supplyMap(neg2_s); kpeter@884: if (full_neg_cost_support) { kpeter@884: checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, kpeter@884: mcf3.OPTIMAL, true, -300, test_str + "-16", GEQ); kpeter@884: } else { kpeter@884: checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, kpeter@884: mcf3.UNBOUNDED, false, 0, test_str + "-17", GEQ); kpeter@884: } kpeter@884: mcf3.upperMap(neg2_u); kpeter@884: checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, kpeter@884: mcf3.OPTIMAL, true, -300, test_str + "-18", GEQ); kpeter@884: } kpeter@884: kpeter@884: template < typename MCF, typename Param > kpeter@884: void runMcfLeqTests( Param param, kpeter@884: const std::string &test_str = "" ) kpeter@884: { kpeter@884: // Tests for the LEQ form kpeter@884: MCF mcf1(gr); kpeter@884: mcf1.supplyType(mcf1.LEQ); kpeter@884: mcf1.upperMap(u).costMap(c).supplyMap(s6); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s6, kpeter@884: mcf1.OPTIMAL, true, 5080, test_str + "-19", LEQ); kpeter@884: mcf1.lowerMap(l2); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s6, kpeter@884: mcf1.OPTIMAL, true, 5930, test_str + "-20", LEQ); kpeter@884: mcf1.supplyMap(s5); kpeter@884: checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s5, kpeter@884: mcf1.INFEASIBLE, false, 0, test_str + "-21", LEQ); kpeter@884: } kpeter@884: kpeter@884: kpeter@648: int main() kpeter@648: { kpeter@884: // Read the test networks kpeter@648: std::istringstream input(test_lgf); kpeter@648: DigraphReader(gr, input) kpeter@648: .arcMap("cost", c) kpeter@648: .arcMap("cap", u) kpeter@648: .arcMap("low1", l1) kpeter@648: .arcMap("low2", l2) kpeter@687: .arcMap("low3", l3) kpeter@648: .nodeMap("sup1", s1) kpeter@648: .nodeMap("sup2", s2) kpeter@648: .nodeMap("sup3", s3) kpeter@656: .nodeMap("sup4", s4) kpeter@656: .nodeMap("sup5", s5) kpeter@687: .nodeMap("sup6", s6) kpeter@648: .node("source", v) kpeter@648: .node("target", w) kpeter@648: .run(); alpar@956: kpeter@884: std::istringstream neg_inp1(test_neg1_lgf); kpeter@884: DigraphReader(neg1_gr, neg_inp1) kpeter@884: .arcMap("cost", neg1_c) kpeter@884: .arcMap("low1", neg1_l1) kpeter@884: .arcMap("low2", neg1_l2) kpeter@884: .nodeMap("sup", neg1_s) kpeter@884: .run(); alpar@956: kpeter@884: std::istringstream neg_inp2(test_neg2_lgf); kpeter@884: DigraphReader(neg2_gr, neg_inp2) kpeter@884: .arcMap("cost", neg2_c) kpeter@884: .nodeMap("sup", neg2_s) kpeter@884: .run(); alpar@956: kpeter@884: // Check the interface of NetworkSimplex kpeter@648: { kpeter@884: typedef concepts::Digraph GR; kpeter@884: checkConcept< McfClassConcept, kpeter@884: NetworkSimplex >(); kpeter@884: checkConcept< McfClassConcept, kpeter@884: NetworkSimplex >(); kpeter@884: checkConcept< McfClassConcept, kpeter@884: NetworkSimplex >(); kpeter@648: } kpeter@648: kpeter@885: // Check the interface of CapacityScaling kpeter@885: { kpeter@885: typedef concepts::Digraph GR; kpeter@885: checkConcept< McfClassConcept, kpeter@885: CapacityScaling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CapacityScaling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CapacityScaling >(); kpeter@885: typedef CapacityScaling:: kpeter@885: SetHeap > >::Create CAS; kpeter@885: checkConcept< McfClassConcept, CAS >(); kpeter@885: } kpeter@885: kpeter@885: // Check the interface of CostScaling kpeter@885: { kpeter@885: typedef concepts::Digraph GR; kpeter@885: checkConcept< McfClassConcept, kpeter@885: CostScaling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CostScaling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CostScaling >(); kpeter@885: typedef CostScaling:: kpeter@885: SetLargeCost::Create COS; kpeter@885: checkConcept< McfClassConcept, COS >(); kpeter@885: } kpeter@885: kpeter@885: // Check the interface of CycleCanceling kpeter@885: { kpeter@885: typedef concepts::Digraph GR; kpeter@885: checkConcept< McfClassConcept, kpeter@885: CycleCanceling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CycleCanceling >(); kpeter@885: checkConcept< McfClassConcept, kpeter@885: CycleCanceling >(); kpeter@885: } kpeter@885: kpeter@884: // Test NetworkSimplex alpar@956: { kpeter@884: typedef NetworkSimplex MCF; kpeter@884: runMcfGeqTests(MCF::FIRST_ELIGIBLE, "NS-FE", true); kpeter@884: runMcfLeqTests(MCF::FIRST_ELIGIBLE, "NS-FE"); kpeter@884: runMcfGeqTests(MCF::BEST_ELIGIBLE, "NS-BE", true); kpeter@884: runMcfLeqTests(MCF::BEST_ELIGIBLE, "NS-BE"); kpeter@884: runMcfGeqTests(MCF::BLOCK_SEARCH, "NS-BS", true); kpeter@884: runMcfLeqTests(MCF::BLOCK_SEARCH, "NS-BS"); kpeter@884: runMcfGeqTests(MCF::CANDIDATE_LIST, "NS-CL", true); kpeter@884: runMcfLeqTests(MCF::CANDIDATE_LIST, "NS-CL"); kpeter@884: runMcfGeqTests(MCF::ALTERING_LIST, "NS-AL", true); kpeter@884: runMcfLeqTests(MCF::ALTERING_LIST, "NS-AL"); kpeter@648: } alpar@956: kpeter@885: // Test CapacityScaling kpeter@885: { kpeter@885: typedef CapacityScaling MCF; kpeter@885: runMcfGeqTests(0, "SSP"); kpeter@885: runMcfGeqTests(2, "CAS"); kpeter@885: } kpeter@885: kpeter@885: // Test CostScaling kpeter@885: { kpeter@885: typedef CostScaling MCF; kpeter@885: runMcfGeqTests(MCF::PUSH, "COS-PR"); kpeter@885: runMcfGeqTests(MCF::AUGMENT, "COS-AR"); kpeter@885: runMcfGeqTests(MCF::PARTIAL_AUGMENT, "COS-PAR"); kpeter@885: } kpeter@885: kpeter@885: // Test CycleCanceling kpeter@885: { kpeter@885: typedef CycleCanceling MCF; kpeter@885: runMcfGeqTests(MCF::SIMPLE_CYCLE_CANCELING, "SCC"); kpeter@885: runMcfGeqTests(MCF::MINIMUM_MEAN_CYCLE_CANCELING, "MMCC"); kpeter@885: runMcfGeqTests(MCF::CANCEL_AND_TIGHTEN, "CAT"); kpeter@885: } kpeter@648: kpeter@648: return 0; kpeter@648: }