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