Changeset 1081:f1398882a928 in lemon for test/min_cost_flow_test.cc
 Timestamp:
 08/08/11 12:36:16 (8 years ago)
 Branch:
 1.1
 Phase:
 public
 Tags:
 r1.1.4
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/min_cost_flow_test.cc
r716 r1081 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 200320 095 * Copyright (C) 20032011 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 48 48 " 11 0 0 0 0 10 0\n" 49 49 " 12 20 27 0 30 30 20\n" 50 "\n" 50 "\n" 51 51 "@arcs\n" 52 52 " cost cap low1 low2 low3\n" … … 94 94 void constraints() { 95 95 checkConcept<concepts::Digraph, GR>(); 96 96 97 97 const Constraints& me = *this; 98 98 … … 123 123 typedef concepts::WriteMap<Arc, Value> FlowMap; 124 124 typedef concepts::WriteMap<Node, Cost> PotMap; 125 125 126 126 GR g; 127 127 VAM lower; … … 177 177 typename CM, typename SM, typename FM, typename PM > 178 178 bool 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, 180 180 const PM& pi, SupplyType type ) 181 181 { … … 190 190 (red_cost < 0 && flow[e] == upper[e]); 191 191 } 192 192 193 193 for (NodeIt n(gr); opt && n != INVALID; ++n) { 194 194 typename SM::Value sum = 0; … … 203 203 } 204 204 } 205 205 206 206 return opt; 207 207 } … … 228 228 } 229 229 } 230 230 231 231 for (NodeIt n(gr); n != INVALID; ++n) { 232 232 dual_cost = red_supply[n] * pi[n]; … … 237 237 dual_cost = (upper[a]  lower[a]) * std::max(red_cost, 0); 238 238 } 239 239 240 240 return dual_cost == total; 241 241 } … … 309 309 .node("target", w) 310 310 .run(); 311 311 312 312 // Build test digraphs with negative costs 313 313 Digraph neg_gr; … … 319 319 Node n6 = neg_gr.addNode(); 320 320 Node n7 = neg_gr.addNode(); 321 321 322 322 Arc a1 = neg_gr.addArc(n1, n2); 323 323 Arc a2 = neg_gr.addArc(n1, n3); … … 329 329 Arc a8 = neg_gr.addArc(n6, n7); 330 330 Arc a9 = neg_gr.addArc(n7, n5); 331 331 332 332 Digraph::ArcMap<int> neg_c(neg_gr), neg_l1(neg_gr, 0), neg_l2(neg_gr, 0); 333 333 ConstMap<Arc, int> neg_u1(std::numeric_limits<int>::max()), neg_u2(5000); 334 334 Digraph::NodeMap<int> neg_s(neg_gr, 0); 335 335 336 336 neg_l2[a7] = 1000; 337 337 neg_l2[a8] = 1000; 338 338 339 339 neg_s[n1] = 100; 340 340 neg_s[n4] = 100; 341 341 342 342 neg_c[a1] = 100; 343 343 neg_c[a2] = 30; … … 423 423 checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l2, neg_u1, 424 424 neg_c, neg_s, neg_mcf.UNBOUNDED, false, 0, "#A18"); 425 425 426 426 NetworkSimplex<Digraph> negs_mcf(negs_gr); 427 427 negs_mcf.costMap(negs_c).supplyMap(negs_s);
Note: See TracChangeset
for help on using the changeset viewer.