0
2
0
... | ... |
@@ -660,49 +660,49 @@ |
660 | 660 |
return _pi[_node_id[n]]; |
661 | 661 |
} |
662 | 662 |
|
663 | 663 |
/// \brief Return the potential map (the dual solution). |
664 | 664 |
/// |
665 | 665 |
/// This function copies the potential (dual value) of each node |
666 | 666 |
/// into the given map. |
667 | 667 |
/// The \c Cost type of the algorithm must be convertible to the |
668 | 668 |
/// \c Value type of the map. |
669 | 669 |
/// |
670 | 670 |
/// \pre \ref run() must be called before using this function. |
671 | 671 |
template <typename PotentialMap> |
672 | 672 |
void potentialMap(PotentialMap &map) const { |
673 | 673 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
674 | 674 |
map.set(n, _pi[_node_id[n]]); |
675 | 675 |
} |
676 | 676 |
} |
677 | 677 |
|
678 | 678 |
/// @} |
679 | 679 |
|
680 | 680 |
private: |
681 | 681 |
|
682 | 682 |
// Initialize the algorithm |
683 | 683 |
ProblemType init() { |
684 |
if (_node_num |
|
684 |
if (_node_num <= 1) return INFEASIBLE; |
|
685 | 685 |
|
686 | 686 |
// Check the sum of supply values |
687 | 687 |
_sum_supply = 0; |
688 | 688 |
for (int i = 0; i != _root; ++i) { |
689 | 689 |
_sum_supply += _supply[i]; |
690 | 690 |
} |
691 | 691 |
if (_sum_supply > 0) return INFEASIBLE; |
692 | 692 |
|
693 | 693 |
// Initialize vectors |
694 | 694 |
for (int i = 0; i != _root; ++i) { |
695 | 695 |
_pi[i] = 0; |
696 | 696 |
_excess[i] = _supply[i]; |
697 | 697 |
} |
698 | 698 |
|
699 | 699 |
// Remove non-zero lower bounds |
700 | 700 |
const Value MAX = std::numeric_limits<Value>::max(); |
701 | 701 |
int last_out; |
702 | 702 |
if (_have_lower) { |
703 | 703 |
for (int i = 0; i != _root; ++i) { |
704 | 704 |
last_out = _first_out[i+1]; |
705 | 705 |
for (int j = _first_out[i]; j != last_out; ++j) { |
706 | 706 |
if (_forward[j]) { |
707 | 707 |
Value c = _lower[j]; |
708 | 708 |
if (c >= 0) { |
... | ... |
@@ -691,49 +691,49 @@ |
691 | 691 |
return static_cast<Cost>(_pi[_node_id[n]]); |
692 | 692 |
} |
693 | 693 |
|
694 | 694 |
/// \brief Return the potential map (the dual solution). |
695 | 695 |
/// |
696 | 696 |
/// This function copies the potential (dual value) of each node |
697 | 697 |
/// into the given map. |
698 | 698 |
/// The \c Cost type of the algorithm must be convertible to the |
699 | 699 |
/// \c Value type of the map. |
700 | 700 |
/// |
701 | 701 |
/// \pre \ref run() must be called before using this function. |
702 | 702 |
template <typename PotentialMap> |
703 | 703 |
void potentialMap(PotentialMap &map) const { |
704 | 704 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
705 | 705 |
map.set(n, static_cast<Cost>(_pi[_node_id[n]])); |
706 | 706 |
} |
707 | 707 |
} |
708 | 708 |
|
709 | 709 |
/// @} |
710 | 710 |
|
711 | 711 |
private: |
712 | 712 |
|
713 | 713 |
// Initialize the algorithm |
714 | 714 |
ProblemType init() { |
715 |
if (_res_node_num |
|
715 |
if (_res_node_num <= 1) return INFEASIBLE; |
|
716 | 716 |
|
717 | 717 |
// Check the sum of supply values |
718 | 718 |
_sum_supply = 0; |
719 | 719 |
for (int i = 0; i != _root; ++i) { |
720 | 720 |
_sum_supply += _supply[i]; |
721 | 721 |
} |
722 | 722 |
if (_sum_supply > 0) return INFEASIBLE; |
723 | 723 |
|
724 | 724 |
|
725 | 725 |
// Initialize vectors |
726 | 726 |
for (int i = 0; i != _res_node_num; ++i) { |
727 | 727 |
_pi[i] = 0; |
728 | 728 |
_excess[i] = _supply[i]; |
729 | 729 |
} |
730 | 730 |
|
731 | 731 |
// Remove infinite upper bounds and check negative arcs |
732 | 732 |
const Value MAX = std::numeric_limits<Value>::max(); |
733 | 733 |
int last_out; |
734 | 734 |
if (_have_lower) { |
735 | 735 |
for (int i = 0; i != _root; ++i) { |
736 | 736 |
last_out = _first_out[i+1]; |
737 | 737 |
for (int j = _first_out[i]; j != last_out; ++j) { |
738 | 738 |
if (_forward[j]) { |
739 | 739 |
Value c = _scost[j] < 0 ? _upper[j] : _lower[j]; |
0 comments (0 inline)