0
6
0
34
21
15
9
31
60
... | ... |
@@ -271,185 +271,195 @@ |
271 | 271 |
*/ |
272 | 272 |
|
273 | 273 |
/** |
274 | 274 |
@defgroup auxdat Auxiliary Data Structures |
275 | 275 |
@ingroup datas |
276 | 276 |
\brief Auxiliary data structures implemented in LEMON. |
277 | 277 |
|
278 | 278 |
This group contains some data structures implemented in LEMON in |
279 | 279 |
order to make it easier to implement combinatorial algorithms. |
280 | 280 |
*/ |
281 | 281 |
|
282 | 282 |
/** |
283 | 283 |
@defgroup geomdat Geometric Data Structures |
284 | 284 |
@ingroup auxdat |
285 | 285 |
\brief Geometric data structures implemented in LEMON. |
286 | 286 |
|
287 | 287 |
This group contains geometric data structures implemented in LEMON. |
288 | 288 |
|
289 | 289 |
- \ref lemon::dim2::Point "dim2::Point" implements a two dimensional |
290 | 290 |
vector with the usual operations. |
291 | 291 |
- \ref lemon::dim2::Box "dim2::Box" can be used to determine the |
292 | 292 |
rectangular bounding box of a set of \ref lemon::dim2::Point |
293 | 293 |
"dim2::Point"'s. |
294 | 294 |
*/ |
295 | 295 |
|
296 | 296 |
/** |
297 | 297 |
@defgroup matrices Matrices |
298 | 298 |
@ingroup auxdat |
299 | 299 |
\brief Two dimensional data storages implemented in LEMON. |
300 | 300 |
|
301 | 301 |
This group contains two dimensional data storages implemented in LEMON. |
302 | 302 |
*/ |
303 | 303 |
|
304 | 304 |
/** |
305 | 305 |
@defgroup algs Algorithms |
306 | 306 |
\brief This group contains the several algorithms |
307 | 307 |
implemented in LEMON. |
308 | 308 |
|
309 | 309 |
This group contains the several algorithms |
310 | 310 |
implemented in LEMON. |
311 | 311 |
*/ |
312 | 312 |
|
313 | 313 |
/** |
314 | 314 |
@defgroup search Graph Search |
315 | 315 |
@ingroup algs |
316 | 316 |
\brief Common graph search algorithms. |
317 | 317 |
|
318 | 318 |
This group contains the common graph search algorithms, namely |
319 |
\e breadth-first \e search (BFS) and \e depth-first \e search (DFS) |
|
319 |
\e breadth-first \e search (BFS) and \e depth-first \e search (DFS) |
|
320 |
\ref clrs01algorithms. |
|
320 | 321 |
*/ |
321 | 322 |
|
322 | 323 |
/** |
323 | 324 |
@defgroup shortest_path Shortest Path Algorithms |
324 | 325 |
@ingroup algs |
325 | 326 |
\brief Algorithms for finding shortest paths. |
326 | 327 |
|
327 |
This group contains the algorithms for finding shortest paths in digraphs |
|
328 |
This group contains the algorithms for finding shortest paths in digraphs |
|
329 |
\ref clrs01algorithms. |
|
328 | 330 |
|
329 | 331 |
- \ref Dijkstra algorithm for finding shortest paths from a source node |
330 | 332 |
when all arc lengths are non-negative. |
331 | 333 |
- \ref BellmanFord "Bellman-Ford" algorithm for finding shortest paths |
332 | 334 |
from a source node when arc lenghts can be either positive or negative, |
333 | 335 |
but the digraph should not contain directed cycles with negative total |
334 | 336 |
length. |
335 | 337 |
- \ref FloydWarshall "Floyd-Warshall" and \ref Johnson "Johnson" algorithms |
336 | 338 |
for solving the \e all-pairs \e shortest \e paths \e problem when arc |
337 | 339 |
lenghts can be either positive or negative, but the digraph should |
338 | 340 |
not contain directed cycles with negative total length. |
339 | 341 |
- \ref Suurballe A successive shortest path algorithm for finding |
340 | 342 |
arc-disjoint paths between two nodes having minimum total length. |
341 | 343 |
*/ |
342 | 344 |
|
343 | 345 |
/** |
344 | 346 |
@defgroup spantree Minimum Spanning Tree Algorithms |
345 | 347 |
@ingroup algs |
346 | 348 |
\brief Algorithms for finding minimum cost spanning trees and arborescences. |
347 | 349 |
|
348 | 350 |
This group contains the algorithms for finding minimum cost spanning |
349 |
trees and arborescences. |
|
351 |
trees and arborescences \ref clrs01algorithms. |
|
350 | 352 |
*/ |
351 | 353 |
|
352 | 354 |
/** |
353 | 355 |
@defgroup max_flow Maximum Flow Algorithms |
354 | 356 |
@ingroup algs |
355 | 357 |
\brief Algorithms for finding maximum flows. |
356 | 358 |
|
357 | 359 |
This group contains the algorithms for finding maximum flows and |
358 |
feasible circulations. |
|
360 |
feasible circulations \ref clrs01algorithms, \ref amo93networkflows. |
|
359 | 361 |
|
360 | 362 |
The \e maximum \e flow \e problem is to find a flow of maximum value between |
361 | 363 |
a single source and a single target. Formally, there is a \f$G=(V,A)\f$ |
362 | 364 |
digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and |
363 | 365 |
\f$s, t \in V\f$ source and target nodes. |
364 | 366 |
A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the |
365 | 367 |
following optimization problem. |
366 | 368 |
|
367 | 369 |
\f[ \max\sum_{sv\in A} f(sv) - \sum_{vs\in A} f(vs) \f] |
368 | 370 |
\f[ \sum_{uv\in A} f(uv) = \sum_{vu\in A} f(vu) |
369 | 371 |
\quad \forall u\in V\setminus\{s,t\} \f] |
370 | 372 |
\f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f] |
371 | 373 |
|
372 | 374 |
LEMON contains several algorithms for solving maximum flow problems: |
373 |
- \ref EdmondsKarp Edmonds-Karp algorithm. |
|
374 |
- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm. |
|
375 |
- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees. |
|
376 |
- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees. |
|
375 |
- \ref EdmondsKarp Edmonds-Karp algorithm |
|
376 |
\ref edmondskarp72theoretical. |
|
377 |
- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm |
|
378 |
\ref goldberg88newapproach. |
|
379 |
- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees |
|
380 |
\ref dinic70algorithm, \ref sleator83dynamic. |
|
381 |
- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees |
|
382 |
\ref goldberg88newapproach, \ref sleator83dynamic. |
|
377 | 383 |
|
378 |
In most cases the \ref Preflow |
|
384 |
In most cases the \ref Preflow algorithm provides the |
|
379 | 385 |
fastest method for computing a maximum flow. All implementations |
380 | 386 |
also provide functions to query the minimum cut, which is the dual |
381 | 387 |
problem of maximum flow. |
382 | 388 |
|
383 | 389 |
\ref Circulation is a preflow push-relabel algorithm implemented directly |
384 | 390 |
for finding feasible circulations, which is a somewhat different problem, |
385 | 391 |
but it is strongly related to maximum flow. |
386 | 392 |
For more information, see \ref Circulation. |
387 | 393 |
*/ |
388 | 394 |
|
389 | 395 |
/** |
390 | 396 |
@defgroup min_cost_flow_algs Minimum Cost Flow Algorithms |
391 | 397 |
@ingroup algs |
392 | 398 |
|
393 | 399 |
\brief Algorithms for finding minimum cost flows and circulations. |
394 | 400 |
|
395 | 401 |
This group contains the algorithms for finding minimum cost flows and |
396 |
circulations. For more information about this problem and its dual |
|
397 |
solution see \ref min_cost_flow "Minimum Cost Flow Problem". |
|
402 |
circulations \ref amo93networkflows. For more information about this |
|
403 |
problem and its dual solution, see \ref min_cost_flow |
|
404 |
"Minimum Cost Flow Problem". |
|
398 | 405 |
|
399 | 406 |
LEMON contains several algorithms for this problem. |
400 | 407 |
- \ref NetworkSimplex Primal Network Simplex algorithm with various |
401 |
pivot strategies. |
|
408 |
pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex. |
|
402 | 409 |
- \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on |
403 |
cost scaling |
|
410 |
cost scaling \ref goldberg90approximation, \ref goldberg97efficient, |
|
411 |
\ref bunnagel98efficient. |
|
404 | 412 |
- \ref CapacityScaling Successive Shortest %Path algorithm with optional |
405 |
capacity scaling. |
|
406 |
- \ref CancelAndTighten The Cancel and Tighten algorithm. |
|
407 |
|
|
413 |
capacity scaling \ref edmondskarp72theoretical. |
|
414 |
- \ref CancelAndTighten The Cancel and Tighten algorithm |
|
415 |
\ref goldberg89cyclecanceling. |
|
416 |
- \ref CycleCanceling Cycle-Canceling algorithms |
|
417 |
\ref klein67primal, \ref goldberg89cyclecanceling. |
|
408 | 418 |
|
409 | 419 |
In general NetworkSimplex is the most efficient implementation, |
410 | 420 |
but in special cases other algorithms could be faster. |
411 | 421 |
For example, if the total supply and/or capacities are rather small, |
412 | 422 |
CapacityScaling is usually the fastest algorithm (without effective scaling). |
413 | 423 |
*/ |
414 | 424 |
|
415 | 425 |
/** |
416 | 426 |
@defgroup min_cut Minimum Cut Algorithms |
417 | 427 |
@ingroup algs |
418 | 428 |
|
419 | 429 |
\brief Algorithms for finding minimum cut in graphs. |
420 | 430 |
|
421 | 431 |
This group contains the algorithms for finding minimum cut in graphs. |
422 | 432 |
|
423 | 433 |
The \e minimum \e cut \e problem is to find a non-empty and non-complete |
424 | 434 |
\f$X\f$ subset of the nodes with minimum overall capacity on |
425 | 435 |
outgoing arcs. Formally, there is a \f$G=(V,A)\f$ digraph, a |
426 | 436 |
\f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum |
427 | 437 |
cut is the \f$X\f$ solution of the next optimization problem: |
428 | 438 |
|
429 | 439 |
\f[ \min_{X \subset V, X\not\in \{\emptyset, V\}} |
430 | 440 |
\sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f] |
431 | 441 |
|
432 | 442 |
LEMON contains several algorithms related to minimum cut problems: |
433 | 443 |
|
434 | 444 |
- \ref HaoOrlin "Hao-Orlin algorithm" for calculating minimum cut |
435 | 445 |
in directed graphs. |
436 | 446 |
- \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for |
437 | 447 |
calculating minimum cut in undirected graphs. |
438 | 448 |
- \ref GomoryHu "Gomory-Hu tree computation" for calculating |
439 | 449 |
all-pairs minimum cut in undirected graphs. |
440 | 450 |
|
441 | 451 |
If you want to find minimum cut just between two distinict nodes, |
442 | 452 |
see the \ref max_flow "maximum flow problem". |
443 | 453 |
*/ |
444 | 454 |
|
445 | 455 |
/** |
446 | 456 |
@defgroup matching Matching Algorithms |
447 | 457 |
@ingroup algs |
448 | 458 |
\brief Algorithms for finding matchings in graphs and bipartite graphs. |
449 | 459 |
|
450 | 460 |
This group contains the algorithms for calculating |
451 | 461 |
matchings in graphs and bipartite graphs. The general matching problem is |
452 | 462 |
finding a subset of the edges for which each node has at most one incident |
453 | 463 |
edge. |
454 | 464 |
|
455 | 465 |
There are several different algorithms for calculate matchings in |
... | ... |
@@ -489,103 +499,106 @@ |
489 | 499 |
|
490 | 500 |
This group contains the algorithms for discovering the graph properties |
491 | 501 |
like connectivity, bipartiteness, euler property, simplicity etc. |
492 | 502 |
|
493 | 503 |
\image html connected_components.png |
494 | 504 |
\image latex connected_components.eps "Connected components" width=\textwidth |
495 | 505 |
*/ |
496 | 506 |
|
497 | 507 |
/** |
498 | 508 |
@defgroup planar Planarity Embedding and Drawing |
499 | 509 |
@ingroup algs |
500 | 510 |
\brief Algorithms for planarity checking, embedding and drawing |
501 | 511 |
|
502 | 512 |
This group contains the algorithms for planarity checking, |
503 | 513 |
embedding and drawing. |
504 | 514 |
|
505 | 515 |
\image html planar.png |
506 | 516 |
\image latex planar.eps "Plane graph" width=\textwidth |
507 | 517 |
*/ |
508 | 518 |
|
509 | 519 |
/** |
510 | 520 |
@defgroup approx Approximation Algorithms |
511 | 521 |
@ingroup algs |
512 | 522 |
\brief Approximation algorithms. |
513 | 523 |
|
514 | 524 |
This group contains the approximation and heuristic algorithms |
515 | 525 |
implemented in LEMON. |
516 | 526 |
*/ |
517 | 527 |
|
518 | 528 |
/** |
519 | 529 |
@defgroup auxalg Auxiliary Algorithms |
520 | 530 |
@ingroup algs |
521 | 531 |
\brief Auxiliary algorithms implemented in LEMON. |
522 | 532 |
|
523 | 533 |
This group contains some algorithms implemented in LEMON |
524 | 534 |
in order to make it easier to implement complex algorithms. |
525 | 535 |
*/ |
526 | 536 |
|
527 | 537 |
/** |
528 | 538 |
@defgroup gen_opt_group General Optimization Tools |
529 | 539 |
\brief This group contains some general optimization frameworks |
530 | 540 |
implemented in LEMON. |
531 | 541 |
|
532 | 542 |
This group contains some general optimization frameworks |
533 | 543 |
implemented in LEMON. |
534 | 544 |
*/ |
535 | 545 |
|
536 | 546 |
/** |
537 |
@defgroup lp_group |
|
547 |
@defgroup lp_group LP and MIP Solvers |
|
538 | 548 |
@ingroup gen_opt_group |
539 |
\brief |
|
549 |
\brief LP and MIP solver interfaces for LEMON. |
|
540 | 550 |
|
541 |
This group contains Lp and Mip solver interfaces for LEMON. The |
|
542 |
various LP solvers could be used in the same manner with this |
|
543 |
|
|
551 |
This group contains LP and MIP solver interfaces for LEMON. |
|
552 |
Various LP solvers could be used in the same manner with this |
|
553 |
high-level interface. |
|
554 |
|
|
555 |
The currently supported solvers are \ref glpk, \ref clp, \ref cbc, |
|
556 |
\ref cplex, \ref soplex. |
|
544 | 557 |
*/ |
545 | 558 |
|
546 | 559 |
/** |
547 | 560 |
@defgroup lp_utils Tools for Lp and Mip Solvers |
548 | 561 |
@ingroup lp_group |
549 | 562 |
\brief Helper tools to the Lp and Mip solvers. |
550 | 563 |
|
551 | 564 |
This group adds some helper tools to general optimization framework |
552 | 565 |
implemented in LEMON. |
553 | 566 |
*/ |
554 | 567 |
|
555 | 568 |
/** |
556 | 569 |
@defgroup metah Metaheuristics |
557 | 570 |
@ingroup gen_opt_group |
558 | 571 |
\brief Metaheuristics for LEMON library. |
559 | 572 |
|
560 | 573 |
This group contains some metaheuristic optimization tools. |
561 | 574 |
*/ |
562 | 575 |
|
563 | 576 |
/** |
564 | 577 |
@defgroup utils Tools and Utilities |
565 | 578 |
\brief Tools and utilities for programming in LEMON |
566 | 579 |
|
567 | 580 |
Tools and utilities for programming in LEMON. |
568 | 581 |
*/ |
569 | 582 |
|
570 | 583 |
/** |
571 | 584 |
@defgroup gutils Basic Graph Utilities |
572 | 585 |
@ingroup utils |
573 | 586 |
\brief Simple basic graph utilities. |
574 | 587 |
|
575 | 588 |
This group contains some simple basic graph utilities. |
576 | 589 |
*/ |
577 | 590 |
|
578 | 591 |
/** |
579 | 592 |
@defgroup misc Miscellaneous Tools |
580 | 593 |
@ingroup utils |
581 | 594 |
\brief Tools for development, debugging and testing. |
582 | 595 |
|
583 | 596 |
This group contains several useful tools for development, |
584 | 597 |
debugging and testing. |
585 | 598 |
*/ |
586 | 599 |
|
587 | 600 |
/** |
588 | 601 |
@defgroup timecount Time Measuring and Counting |
589 | 602 |
@ingroup misc |
590 | 603 |
\brief Simple tools for measuring the performance of algorithms. |
591 | 604 |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
/** |
20 | 20 |
\mainpage LEMON Documentation |
21 | 21 |
|
22 | 22 |
\section intro Introduction |
23 | 23 |
|
24 |
\subsection whatis What is LEMON |
|
25 |
|
|
26 |
LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling |
|
27 |
and <b>O</b>ptimization in <b>N</b>etworks. |
|
28 |
It is a C++ template |
|
29 |
library aimed at combinatorial optimization tasks which |
|
30 |
often involve in working |
|
31 |
with graphs. |
|
24 |
<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling |
|
25 |
and <b>O</b>ptimization in <b>N</b>etworks</i>. |
|
26 |
It is a C++ template library providing efficient implementation of common |
|
27 |
data structures and algorithms with focus on combinatorial optimization |
|
28 |
problems in graphs and networks. |
|
32 | 29 |
|
33 | 30 |
<b> |
34 | 31 |
LEMON is an <a class="el" href="http://opensource.org/">open source</a> |
35 | 32 |
project. |
36 | 33 |
You are free to use it in your commercial or |
37 | 34 |
non-commercial applications under very permissive |
38 | 35 |
\ref license "license terms". |
39 | 36 |
</b> |
40 | 37 |
|
41 |
|
|
38 |
The project is maintained by the |
|
39 |
<a href="http://www.cs.elte.hu/egres/">Egerváry Research Group on |
|
40 |
Combinatorial Optimization</a> \ref egres |
|
41 |
at the Operations Research Department of the |
|
42 |
<a href="http://www.elte.hu/">Eötvös Loránd University, |
|
43 |
Budapest</a>, Hungary. |
|
44 |
LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a> |
|
45 |
initiative \ref coinor. |
|
46 |
|
|
47 |
\section howtoread How to Read the Documentation |
|
42 | 48 |
|
43 | 49 |
If you would like to get to know the library, see |
44 | 50 |
<a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>. |
45 | 51 |
|
46 | 52 |
If you know what you are looking for, then try to find it under the |
47 | 53 |
<a class="el" href="modules.html">Modules</a> section. |
48 | 54 |
|
49 | 55 |
If you are a user of the old (0.x) series of LEMON, please check out the |
50 | 56 |
\ref migration "Migration Guide" for the backward incompatibilities. |
51 | 57 |
*/ |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
namespace lemon { |
20 | 20 |
|
21 | 21 |
/** |
22 | 22 |
\page min_cost_flow Minimum Cost Flow Problem |
23 | 23 |
|
24 | 24 |
\section mcf_def Definition (GEQ form) |
25 | 25 |
|
26 | 26 |
The \e minimum \e cost \e flow \e problem is to find a feasible flow of |
27 | 27 |
minimum total cost from a set of supply nodes to a set of demand nodes |
28 | 28 |
in a network with capacity constraints (lower and upper bounds) |
29 |
and arc costs. |
|
29 |
and arc costs \ref amo93networkflows. |
|
30 | 30 |
|
31 | 31 |
Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$, |
32 | 32 |
\f$upper: A\rightarrow\mathbf{R}\cup\{+\infty\}\f$ denote the lower and |
33 | 33 |
upper bounds for the flow values on the arcs, for which |
34 | 34 |
\f$lower(uv) \leq upper(uv)\f$ must hold for all \f$uv\in A\f$, |
35 | 35 |
\f$cost: A\rightarrow\mathbf{R}\f$ denotes the cost per unit flow |
36 | 36 |
on the arcs and \f$sup: V\rightarrow\mathbf{R}\f$ denotes the |
37 | 37 |
signed supply values of the nodes. |
38 | 38 |
If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$ |
39 | 39 |
supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with |
40 | 40 |
\f$-sup(u)\f$ demand. |
41 | 41 |
A minimum cost flow is an \f$f: A\rightarrow\mathbf{R}\f$ solution |
42 | 42 |
of the following optimization problem. |
43 | 43 |
|
44 | 44 |
\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f] |
45 | 45 |
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \geq |
46 | 46 |
sup(u) \quad \forall u\in V \f] |
47 | 47 |
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f] |
48 | 48 |
|
49 | 49 |
The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be |
50 | 50 |
zero or negative in order to have a feasible solution (since the sum |
51 | 51 |
of the expressions on the left-hand side of the inequalities is zero). |
52 | 52 |
It means that the total demand must be greater or equal to the total |
53 | 53 |
supply and all the supplies have to be carried out from the supply nodes, |
54 | 54 |
but there could be demands that are not satisfied. |
55 | 55 |
If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand |
56 | 56 |
constraints have to be satisfied with equality, i.e. all demands |
57 | 57 |
have to be satisfied and all supplies have to be used. |
58 | 58 |
|
59 | 59 |
|
60 | 60 |
\section mcf_algs Algorithms |
61 | 61 |
|
62 | 62 |
LEMON contains several algorithms for solving this problem, for more |
63 | 63 |
information see \ref min_cost_flow_algs "Minimum Cost Flow Algorithms". |
64 | 64 |
|
65 | 65 |
A feasible solution for this problem can be found using \ref Circulation. |
66 | 66 |
|
67 | 67 |
|
68 | 68 |
\section mcf_dual Dual Solution |
69 | 69 |
|
70 | 70 |
The dual solution of the minimum cost flow problem is represented by |
71 | 71 |
node potentials \f$\pi: V\rightarrow\mathbf{R}\f$. |
72 | 72 |
An \f$f: A\rightarrow\mathbf{R}\f$ primal feasible solution is optimal |
73 | 73 |
if and only if for some \f$\pi: V\rightarrow\mathbf{R}\f$ node potentials |
74 | 74 |
the following \e complementary \e slackness optimality conditions hold. |
75 | 75 |
|
76 | 76 |
- For all \f$uv\in A\f$ arcs: |
77 | 77 |
- if \f$cost^\pi(uv)>0\f$, then \f$f(uv)=lower(uv)\f$; |
... | ... |
@@ -105,226 +105,197 @@ |
105 | 105 |
title = {{SoPlex} -- {T}he {S}equential {O}bject-{O}riented |
106 | 106 |
{S}implex}, |
107 | 107 |
url = {http://soplex.zib.de/} |
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
|
111 | 111 |
%%%%% General books %%%%% |
112 | 112 |
|
113 | 113 |
@book{amo93networkflows, |
114 | 114 |
author = {Ravindra K. Ahuja and Thomas L. Magnanti and James |
115 | 115 |
B. Orlin}, |
116 | 116 |
title = {Network Flows: Theory, Algorithms, and Applications}, |
117 | 117 |
publisher = {Prentice-Hall, Inc.}, |
118 | 118 |
year = 1993, |
119 | 119 |
month = feb, |
120 | 120 |
isbn = {978-0136175490} |
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
@book{schrijver03combinatorial, |
124 | 124 |
author = {Alexander Schrijver}, |
125 | 125 |
title = {Combinatorial Optimization: Polyhedra and Efficiency}, |
126 | 126 |
publisher = {Springer-Verlag}, |
127 | 127 |
year = 2003, |
128 | 128 |
isbn = {978-3540443896} |
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
@book{clrs01algorithms, |
132 | 132 |
author = {Thomas H. Cormen and Charles E. Leiserson and Ronald |
133 | 133 |
L. Rivest and Clifford Stein}, |
134 | 134 |
title = {Introduction to Algorithms}, |
135 | 135 |
publisher = {The MIT Press}, |
136 | 136 |
year = 2001, |
137 | 137 |
edition = {2nd} |
138 | 138 |
} |
139 | 139 |
|
140 | 140 |
@book{stroustrup00cpp, |
141 | 141 |
author = {Bjarne Stroustrup}, |
142 | 142 |
title = {The C++ Programming Language}, |
143 | 143 |
edition = {3rd}, |
144 | 144 |
publisher = {Addison-Wesley Professional}, |
145 | 145 |
isbn = 0201700735, |
146 | 146 |
month = {February}, |
147 | 147 |
year = 2000 |
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
|
151 | 151 |
%%%%% Maximum flow algorithms %%%%% |
152 | 152 |
|
153 |
@ |
|
153 |
@article{edmondskarp72theoretical, |
|
154 |
author = {Jack Edmonds and Richard M. Karp}, |
|
155 |
title = {Theoretical improvements in algorithmic efficiency |
|
156 |
for network flow problems}, |
|
157 |
journal = {Journal of the ACM}, |
|
158 |
year = 1972, |
|
159 |
volume = 19, |
|
160 |
number = 2, |
|
161 |
pages = {248-264} |
|
162 |
} |
|
163 |
|
|
164 |
@article{goldberg88newapproach, |
|
154 | 165 |
author = {Andrew V. Goldberg and Robert E. Tarjan}, |
155 | 166 |
title = {A new approach to the maximum flow problem}, |
156 |
booktitle = {STOC '86: Proceedings of the Eighteenth Annual ACM |
|
157 |
Symposium on Theory of Computing}, |
|
158 |
year = 1986, |
|
159 |
publisher = {ACM Press}, |
|
160 |
address = {New York, NY}, |
|
161 |
pages = {136-146} |
|
167 |
journal = {Journal of the ACM}, |
|
168 |
year = 1988, |
|
169 |
volume = 35, |
|
170 |
number = 4, |
|
171 |
pages = {921-940} |
|
162 | 172 |
} |
163 | 173 |
|
164 | 174 |
@article{dinic70algorithm, |
165 | 175 |
author = {E. A. Dinic}, |
166 | 176 |
title = {Algorithm for solution of a problem of maximum flow |
167 | 177 |
in a network with power estimation}, |
168 | 178 |
journal = {Soviet Math. Doklady}, |
169 | 179 |
year = 1970, |
170 | 180 |
volume = 11, |
171 | 181 |
pages = {1277-1280} |
172 | 182 |
} |
173 | 183 |
|
174 | 184 |
@article{goldberg08partial, |
175 | 185 |
author = {Andrew V. Goldberg}, |
176 | 186 |
title = {The Partial Augment-Relabel Algorithm for the |
177 | 187 |
Maximum Flow Problem}, |
178 | 188 |
journal = {16th Annual European Symposium on Algorithms}, |
179 | 189 |
year = 2008, |
180 | 190 |
pages = {466-477} |
181 | 191 |
} |
182 | 192 |
|
183 | 193 |
@article{sleator83dynamic, |
184 | 194 |
author = {Daniel D. Sleator and Robert E. Tarjan}, |
185 | 195 |
title = {A data structure for dynamic trees}, |
186 | 196 |
journal = {Journal of Computer and System Sciences}, |
187 | 197 |
year = 1983, |
188 | 198 |
volume = 26, |
189 | 199 |
number = 3, |
190 | 200 |
pages = {362-391} |
191 | 201 |
} |
192 | 202 |
|
193 | 203 |
|
194 | 204 |
%%%%% Minimum mean cycle algorithms %%%%% |
195 | 205 |
|
196 | 206 |
@article{karp78characterization, |
197 | 207 |
author = {Richard M. Karp}, |
198 | 208 |
title = {A characterization of the minimum cycle mean in a |
199 | 209 |
digraph}, |
200 | 210 |
journal = {Discrete Math.}, |
201 | 211 |
year = 1978, |
202 | 212 |
volume = 23, |
203 | 213 |
pages = {309-311} |
204 | 214 |
} |
205 | 215 |
|
206 | 216 |
@article{dasdan98minmeancycle, |
207 | 217 |
author = {Ali Dasdan and Rajesh K. Gupta}, |
208 | 218 |
title = {Faster Maximum and Minimum Mean Cycle Alogrithms for |
209 | 219 |
System Performance Analysis}, |
210 | 220 |
journal = {IEEE Transactions on Computer-Aided Design of |
211 | 221 |
Integrated Circuits and Systems}, |
212 | 222 |
year = 1998, |
213 | 223 |
volume = 17, |
214 | 224 |
number = 10, |
215 | 225 |
pages = {889-899} |
216 | 226 |
} |
217 | 227 |
|
218 | 228 |
|
219 | 229 |
%%%%% Minimum cost flow algorithms %%%%% |
220 | 230 |
|
221 | 231 |
@article{klein67primal, |
222 | 232 |
author = {Morton Klein}, |
223 | 233 |
title = {A primal method for minimal cost flows with |
224 | 234 |
applications to the assignment and transportation |
225 | 235 |
problems}, |
226 | 236 |
journal = {Management Science}, |
227 | 237 |
year = 1967, |
228 | 238 |
volume = 14, |
229 | 239 |
pages = {205-220} |
230 | 240 |
} |
231 | 241 |
|
232 |
@ |
|
242 |
@article{goldberg89cyclecanceling, |
|
233 | 243 |
author = {Andrew V. Goldberg and Robert E. Tarjan}, |
234 | 244 |
title = {Finding minimum-cost circulations by canceling |
235 | 245 |
negative cycles}, |
236 |
booktitle = {STOC '88: Proceedings of the Twentieth Annual ACM |
|
237 |
Symposium on Theory of Computing}, |
|
238 |
year = 1988, |
|
239 |
publisher = {ACM Press}, |
|
240 |
address = {New York, NY}, |
|
241 |
pages = {388-397} |
|
246 |
journal = {Journal of the ACM}, |
|
247 |
year = 1989, |
|
248 |
volume = 36, |
|
249 |
number = 4, |
|
250 |
pages = {873-886} |
|
242 | 251 |
} |
243 | 252 |
|
244 |
@article{edmondskarp72theoretical, |
|
245 |
author = {Jack Edmonds and Richard M. Karp}, |
|
246 |
title = {Theoretical improvements in algorithmic efficiency |
|
247 |
for network flow problems}, |
|
248 |
journal = {Journal of the ACM}, |
|
249 |
year = 1972, |
|
250 |
volume = 19, |
|
251 |
number = 2, |
|
252 |
pages = {248-264} |
|
253 |
} |
|
254 |
|
|
255 |
@inproceedings{goldberg87approximation, |
|
256 |
author = {Andrew V. Goldberg and Robert E. Tarjan}, |
|
257 |
title = {Solving minimum-cost flow problems by successive |
|
258 |
approximation}, |
|
259 |
booktitle = {STOC '87: Proceedings of the Nineteenth Annual ACM |
|
260 |
Symposium on Theory of Computing}, |
|
261 |
year = 1987, |
|
262 |
publisher = {ACM Press}, |
|
263 |
address = {New York, NY}, |
|
264 |
pages = {7-18} |
|
265 |
} |
|
266 |
|
|
267 |
@article{goldberg90finding, |
|
253 |
@article{goldberg90approximation, |
|
268 | 254 |
author = {Andrew V. Goldberg and Robert E. Tarjan}, |
269 | 255 |
title = {Finding Minimum-Cost Circulations by Successive |
270 | 256 |
Approximation}, |
271 | 257 |
journal = {Mathematics of Operations Research}, |
272 | 258 |
year = 1990, |
273 | 259 |
volume = 15, |
274 | 260 |
number = 3, |
275 | 261 |
pages = {430-466} |
276 | 262 |
} |
277 | 263 |
|
278 | 264 |
@article{goldberg97efficient, |
279 | 265 |
author = {Andrew V. Goldberg}, |
280 | 266 |
title = {An Efficient Implementation of a Scaling |
281 | 267 |
Minimum-Cost Flow Algorithm}, |
282 | 268 |
journal = {Journal of Algorithms}, |
283 | 269 |
year = 1997, |
284 | 270 |
volume = 22, |
285 | 271 |
number = 1, |
286 | 272 |
pages = {1-29} |
287 | 273 |
} |
288 | 274 |
|
289 | 275 |
@article{bunnagel98efficient, |
290 | 276 |
author = {Ursula B{\"u}nnagel and Bernhard Korte and Jens |
291 | 277 |
Vygen}, |
292 | 278 |
title = {Efficient implementation of the {G}oldberg-{T}arjan |
293 | 279 |
minimum-cost flow algorithm}, |
294 | 280 |
journal = {Optimization Methods and Software}, |
295 | 281 |
year = 1998, |
296 | 282 |
volume = 10, |
297 | 283 |
pages = {157-174} |
298 | 284 |
} |
299 | 285 |
|
286 |
@book{dantzig63linearprog, |
|
287 |
author = {George B. Dantzig}, |
|
288 |
title = {Linear Programming and Extensions}, |
|
289 |
publisher = {Princeton University Press}, |
|
290 |
year = 1963 |
|
291 |
} |
|
292 |
|
|
300 | 293 |
@mastersthesis{kellyoneill91netsimplex, |
301 | 294 |
author = {Damian J. Kelly and Garrett M. O'Neill}, |
302 | 295 |
title = {The Minimum Cost Flow Problem and The Network |
303 | 296 |
Simplex Method}, |
304 | 297 |
school = {University College}, |
305 | 298 |
address = {Dublin, Ireland}, |
306 | 299 |
year = 1991, |
307 | 300 |
month = sep, |
308 | 301 |
} |
309 |
|
|
310 |
@techreport{lobel96networksimplex, |
|
311 |
author = {Andreas L{\"o}bel}, |
|
312 |
title = {Solving large-scale real-world minimum-cost flow |
|
313 |
problems by a network simplex method}, |
|
314 |
institution = {Konrad-Zuse-Zentrum fur Informationstechnik Berlin |
|
315 |
({ZIB})}, |
|
316 |
address = {Berlin, Germany}, |
|
317 |
year = 1996, |
|
318 |
number = {SC 96-7} |
|
319 |
} |
|
320 |
|
|
321 |
@article{frangioni06computational, |
|
322 |
author = {Antonio Frangioni and Antonio Manca}, |
|
323 |
title = {A Computational Study of Cost Reoptimization for |
|
324 |
Min-Cost Flow Problems}, |
|
325 |
journal = {INFORMS Journal On Computing}, |
|
326 |
year = 2006, |
|
327 |
volume = 18, |
|
328 |
number = 1, |
|
329 |
pages = {61-70} |
|
330 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_NETWORK_SIMPLEX_H |
20 | 20 |
#define LEMON_NETWORK_SIMPLEX_H |
21 | 21 |
|
22 | 22 |
/// \ingroup min_cost_flow_algs |
23 | 23 |
/// |
24 | 24 |
/// \file |
25 | 25 |
/// \brief Network Simplex algorithm for finding a minimum cost flow. |
26 | 26 |
|
27 | 27 |
#include <vector> |
28 | 28 |
#include <limits> |
29 | 29 |
#include <algorithm> |
30 | 30 |
|
31 | 31 |
#include <lemon/core.h> |
32 | 32 |
#include <lemon/math.h> |
33 | 33 |
|
34 | 34 |
namespace lemon { |
35 | 35 |
|
36 | 36 |
/// \addtogroup min_cost_flow_algs |
37 | 37 |
/// @{ |
38 | 38 |
|
39 | 39 |
/// \brief Implementation of the primal Network Simplex algorithm |
40 | 40 |
/// for finding a \ref min_cost_flow "minimum cost flow". |
41 | 41 |
/// |
42 | 42 |
/// \ref NetworkSimplex implements the primal Network Simplex algorithm |
43 |
/// for finding a \ref min_cost_flow "minimum cost flow" |
|
43 |
/// for finding a \ref min_cost_flow "minimum cost flow" |
|
44 |
/// \ref amo93networkflows, \ref dantzig63linearprog, |
|
45 |
/// \ref kellyoneill91netsimplex. |
|
44 | 46 |
/// This algorithm is a specialized version of the linear programming |
45 | 47 |
/// simplex method directly for the minimum cost flow problem. |
46 | 48 |
/// It is one of the most efficient solution methods. |
47 | 49 |
/// |
48 | 50 |
/// In general this class is the fastest implementation available |
49 | 51 |
/// in LEMON for the minimum cost flow problem. |
50 | 52 |
/// Moreover it supports both directions of the supply/demand inequality |
51 | 53 |
/// constraints. For more information see \ref SupplyType. |
52 | 54 |
/// |
53 | 55 |
/// Most of the parameters of the problem (except for the digraph) |
54 | 56 |
/// can be given using separate functions, and the algorithm can be |
55 | 57 |
/// executed using the \ref run() function. If some parameters are not |
56 | 58 |
/// specified, then default values will be used. |
57 | 59 |
/// |
58 | 60 |
/// \tparam GR The digraph type the algorithm runs on. |
59 | 61 |
/// \tparam V The value type used for flow amounts, capacity bounds |
60 | 62 |
/// and supply values in the algorithm. By default it is \c int. |
61 | 63 |
/// \tparam C The value type used for costs and potentials in the |
62 | 64 |
/// algorithm. By default it is the same as \c V. |
63 | 65 |
/// |
64 | 66 |
/// \warning Both value types must be signed and all input data must |
65 | 67 |
/// be integer. |
66 | 68 |
/// |
67 | 69 |
/// \note %NetworkSimplex provides five different pivot rule |
68 | 70 |
/// implementations, from which the most efficient one is used |
69 | 71 |
/// by default. For more information see \ref PivotRule. |
70 | 72 |
template <typename GR, typename V = int, typename C = V> |
71 | 73 |
class NetworkSimplex |
72 | 74 |
{ |
73 | 75 |
public: |
74 | 76 |
|
75 | 77 |
/// The type of the flow amounts, capacity bounds and supply values |
76 | 78 |
typedef V Value; |
77 | 79 |
/// The type of the arc costs |
78 | 80 |
typedef C Cost; |
79 | 81 |
|
80 | 82 |
public: |
81 | 83 |
|
82 | 84 |
/// \brief Problem type constants for the \c run() function. |
83 | 85 |
/// |
84 | 86 |
/// Enum type containing the problem type constants that can be |
85 | 87 |
/// returned by the \ref run() function of the algorithm. |
86 | 88 |
enum ProblemType { |
87 | 89 |
/// The problem has no feasible solution (flow). |
88 | 90 |
INFEASIBLE, |
89 | 91 |
/// The problem has optimal solution (i.e. it is feasible and |
90 | 92 |
/// bounded), and the algorithm has found optimal flow and node |
91 | 93 |
/// potentials (primal and dual solutions). |
... | ... |
@@ -57,97 +57,98 @@ |
57 | 57 |
#else |
58 | 58 |
typedef typename Digraph::template ArcMap<Value> FlowMap; |
59 | 59 |
#endif |
60 | 60 |
|
61 | 61 |
/// \brief Instantiates a FlowMap. |
62 | 62 |
/// |
63 | 63 |
/// This function instantiates a \ref FlowMap. |
64 | 64 |
/// \param digraph The digraph for which we would like to define |
65 | 65 |
/// the flow map. |
66 | 66 |
static FlowMap* createFlowMap(const Digraph& digraph) { |
67 | 67 |
return new FlowMap(digraph); |
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
/// \brief The elevator type used by Preflow algorithm. |
71 | 71 |
/// |
72 | 72 |
/// The elevator type used by Preflow algorithm. |
73 | 73 |
/// |
74 | 74 |
/// \sa Elevator, LinkedElevator |
75 | 75 |
#ifdef DOXYGEN |
76 | 76 |
typedef lemon::Elevator<GR, GR::Node> Elevator; |
77 | 77 |
#else |
78 | 78 |
typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator; |
79 | 79 |
#endif |
80 | 80 |
|
81 | 81 |
/// \brief Instantiates an Elevator. |
82 | 82 |
/// |
83 | 83 |
/// This function instantiates an \ref Elevator. |
84 | 84 |
/// \param digraph The digraph for which we would like to define |
85 | 85 |
/// the elevator. |
86 | 86 |
/// \param max_level The maximum level of the elevator. |
87 | 87 |
static Elevator* createElevator(const Digraph& digraph, int max_level) { |
88 | 88 |
return new Elevator(digraph, max_level); |
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
/// \brief The tolerance used by the algorithm |
92 | 92 |
/// |
93 | 93 |
/// The tolerance used by the algorithm to handle inexact computation. |
94 | 94 |
typedef lemon::Tolerance<Value> Tolerance; |
95 | 95 |
|
96 | 96 |
}; |
97 | 97 |
|
98 | 98 |
|
99 | 99 |
/// \ingroup max_flow |
100 | 100 |
/// |
101 | 101 |
/// \brief %Preflow algorithm class. |
102 | 102 |
/// |
103 | 103 |
/// This class provides an implementation of Goldberg-Tarjan's \e preflow |
104 | 104 |
/// \e push-relabel algorithm producing a \ref max_flow |
105 |
/// "flow of maximum value" in a digraph |
|
105 |
/// "flow of maximum value" in a digraph \ref clrs01algorithms, |
|
106 |
/// \ref amo93networkflows, \ref goldberg88newapproach. |
|
106 | 107 |
/// The preflow algorithms are the fastest known maximum |
107 | 108 |
/// flow algorithms. The current implementation uses a mixture of the |
108 | 109 |
/// \e "highest label" and the \e "bound decrease" heuristics. |
109 | 110 |
/// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$. |
110 | 111 |
/// |
111 | 112 |
/// The algorithm consists of two phases. After the first phase |
112 | 113 |
/// the maximum flow value and the minimum cut is obtained. The |
113 | 114 |
/// second phase constructs a feasible maximum flow on each arc. |
114 | 115 |
/// |
115 | 116 |
/// \tparam GR The type of the digraph the algorithm runs on. |
116 | 117 |
/// \tparam CAP The type of the capacity map. The default map |
117 | 118 |
/// type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
118 | 119 |
#ifdef DOXYGEN |
119 | 120 |
template <typename GR, typename CAP, typename TR> |
120 | 121 |
#else |
121 | 122 |
template <typename GR, |
122 | 123 |
typename CAP = typename GR::template ArcMap<int>, |
123 | 124 |
typename TR = PreflowDefaultTraits<GR, CAP> > |
124 | 125 |
#endif |
125 | 126 |
class Preflow { |
126 | 127 |
public: |
127 | 128 |
|
128 | 129 |
///The \ref PreflowDefaultTraits "traits class" of the algorithm. |
129 | 130 |
typedef TR Traits; |
130 | 131 |
///The type of the digraph the algorithm runs on. |
131 | 132 |
typedef typename Traits::Digraph Digraph; |
132 | 133 |
///The type of the capacity map. |
133 | 134 |
typedef typename Traits::CapacityMap CapacityMap; |
134 | 135 |
///The type of the flow values. |
135 | 136 |
typedef typename Traits::Value Value; |
136 | 137 |
|
137 | 138 |
///The type of the flow map. |
138 | 139 |
typedef typename Traits::FlowMap FlowMap; |
139 | 140 |
///The type of the elevator. |
140 | 141 |
typedef typename Traits::Elevator Elevator; |
141 | 142 |
///The type of the tolerance. |
142 | 143 |
typedef typename Traits::Tolerance Tolerance; |
143 | 144 |
|
144 | 145 |
private: |
145 | 146 |
|
146 | 147 |
TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); |
147 | 148 |
|
148 | 149 |
const Digraph& _graph; |
149 | 150 |
const CapacityMap* _capacity; |
150 | 151 |
|
151 | 152 |
int _node_num; |
152 | 153 |
|
153 | 154 |
Node _source, _target; |
0 comments (0 inline)