COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
08/08/11 12:36:16 (8 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
1.1
Phase:
public
Tags:
r1.1.4
Message:

Unify sources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/min_cost_flow_test.cc

    r716 r1081  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2011
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4848  "   11     0    0    0    0  -10    0\n"
    4949  "   12   -20  -27    0  -30  -30  -20\n"
    50   "\n"               
     50  "\n"
    5151  "@arcs\n"
    5252  "       cost  cap low1 low2 low3\n"
     
    9494    void constraints() {
    9595      checkConcept<concepts::Digraph, GR>();
    96      
     96
    9797      const Constraints& me = *this;
    9898
     
    123123    typedef concepts::WriteMap<Arc, Value> FlowMap;
    124124    typedef concepts::WriteMap<Node, Cost> PotMap;
    125  
     125
    126126    GR g;
    127127    VAM lower;
     
    177177           typename CM, typename SM, typename FM, typename PM >
    178178bool checkPotential( const GR& gr, const LM& lower, const UM& upper,
    179                      const CM& cost, const SM& supply, const FM& flow, 
     179                     const CM& cost, const SM& supply, const FM& flow,
    180180                     const PM& pi, SupplyType type )
    181181{
     
    190190          (red_cost < 0 && flow[e] == upper[e]);
    191191  }
    192  
     192
    193193  for (NodeIt n(gr); opt && n != INVALID; ++n) {
    194194    typename SM::Value sum = 0;
     
    203203    }
    204204  }
    205  
     205
    206206  return opt;
    207207}
     
    228228    }
    229229  }
    230  
     230
    231231  for (NodeIt n(gr); n != INVALID; ++n) {
    232232    dual_cost -= red_supply[n] * pi[n];
     
    237237    dual_cost -= (upper[a] - lower[a]) * std::max(-red_cost, 0);
    238238  }
    239  
     239
    240240  return dual_cost == total;
    241241}
     
    309309    .node("target", w)
    310310    .run();
    311  
     311
    312312  // Build test digraphs with negative costs
    313313  Digraph neg_gr;
     
    319319  Node n6 = neg_gr.addNode();
    320320  Node n7 = neg_gr.addNode();
    321  
     321
    322322  Arc a1 = neg_gr.addArc(n1, n2);
    323323  Arc a2 = neg_gr.addArc(n1, n3);
     
    329329  Arc a8 = neg_gr.addArc(n6, n7);
    330330  Arc a9 = neg_gr.addArc(n7, n5);
    331  
     331
    332332  Digraph::ArcMap<int> neg_c(neg_gr), neg_l1(neg_gr, 0), neg_l2(neg_gr, 0);
    333333  ConstMap<Arc, int> neg_u1(std::numeric_limits<int>::max()), neg_u2(5000);
    334334  Digraph::NodeMap<int> neg_s(neg_gr, 0);
    335  
     335
    336336  neg_l2[a7] =  1000;
    337337  neg_l2[a8] = -1000;
    338  
     338
    339339  neg_s[n1] =  100;
    340340  neg_s[n4] = -100;
    341  
     341
    342342  neg_c[a1] =  100;
    343343  neg_c[a2] =   30;
     
    423423    checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l2, neg_u1,
    424424      neg_c, neg_s, neg_mcf.UNBOUNDED, false,    0, "#A18");
    425      
     425
    426426    NetworkSimplex<Digraph> negs_mcf(negs_gr);
    427427    negs_mcf.costMap(negs_c).supplyMap(negs_s);
Note: See TracChangeset for help on using the changeset viewer.