168 #ifndef OR_TOOLS_GRAPH_MIN_COST_FLOW_H_ 169 #define OR_TOOLS_GRAPH_MIN_COST_FLOW_H_ 188 template <
typename Graph,
typename ArcFlowType,
typename ArcScaledCostType>
245 return SolveWithPossibleAdjustment(SupplyAdjustment::DONT_ADJUST);
254 return SolveWithPossibleAdjustment(SupplyAdjustment::ADJUST);
284 typedef ::util::ReverseArcStaticGraph<NodeIndex, ArcIndex> Graph;
285 enum SupplyAdjustment { ADJUST, DONT_ADJUST };
291 Status SolveWithPossibleAdjustment(SupplyAdjustment adjustment);
294 std::vector<NodeIndex> arc_tail_;
295 std::vector<NodeIndex> arc_head_;
296 std::vector<FlowQuantity> arc_capacity_;
297 std::vector<FlowQuantity> node_supply_;
298 std::vector<CostValue> arc_cost_;
299 std::vector<ArcIndex> arc_permutation_;
300 std::vector<FlowQuantity> arc_flow_;
327 class GenericMinCostFlow :
public MinCostFlowBase {
332 typedef typename Graph::OutgoingOrOppositeIncomingArcIterator
375 std::vector<NodeIndex>*
const infeasible_demand_node);
425 bool IsAdmissible(
ArcIndex arc)
const;
440 bool CheckInputConsistency()
const;
446 bool CheckResult()
const;
450 bool CheckCostRange()
const;
456 bool CheckRelabelPrecondition(
NodeIndex node)
const;
460 std::string DebugString(
const std::string&
context,
ArcIndex arc)
const;
464 void ResetFirstAdmissibleArcs();
476 void SaturateAdmissibleArcs();
486 void InitializeActiveNodeStack();
520 bool IsArcDirect(
ArcIndex arc)
const;
521 bool IsArcValid(
ArcIndex arc)
const;
553 ZVector<ArcFlowType> residual_arc_capacity_;
561 std::stack<NodeIndex> active_nodes_;
568 const int64_t alpha_;
574 ZVector<ArcScaledCostType> scaled_arc_unit_cost_;
596 int num_relabels_since_last_price_update_;
599 bool feasibility_checked_;
602 bool use_price_update_;
605 bool check_feasibility_;
622 #endif // OR_TOOLS_GRAPH_MIN_COST_FLOW_H_
Graph::OutgoingArcIterator OutgoingArcIterator
void SetUseUpdatePrices(bool value)
FlowQuantity FeasibleSupply(NodeIndex node) const
void SetNodeSupply(NodeIndex node, FlowQuantity supply)
FlowQuantity Capacity(ArcIndex arc) const
NodeIndex NumNodes() const
FlowQuantity Capacity(ArcIndex arc) const
const Graph * graph() const
FlowQuantity Flow(ArcIndex arc) const
CostValue UnitCost(ArcIndex arc) const
Status SolveMaxFlowWithMinCost()
void SetArcCapacity(ArcIndex arc, ArcFlowType new_capacity)
CostValue OptimalCost() const
NodeIndex Tail(ArcIndex arc) const
ZVector< FlowQuantity > QuantityArray
void SetCheckFeasibility(bool value)
FlowQuantity Supply(NodeIndex node) const
GenericMinCostFlow(const Graph *graph)
SimpleMinCostFlow(NodeIndex reserve_num_nodes=0, ArcIndex reserve_num_arcs=0)
ZVector< CostValue > CostArray
MinCostFlow(const StarGraph *graph)
void SetArcFlow(ArcIndex arc, ArcFlowType new_flow)
ZVector< ArcIndex > ArcIndexArray
Graph::NodeIndex NodeIndex
FlowQuantity Flow(ArcIndex arc) const
FlowQuantity InitialSupply(NodeIndex node) const
CostValue GetOptimalCost() const
FlowQuantity Supply(NodeIndex node) const
void SetArcUnitCost(ArcIndex arc, ArcScaledCostType unit_cost)
NodeIndex Head(ArcIndex arc) const
Collection of objects used to extend the Constraint Solver library.
GurobiMPCallbackContext * context
FlowQuantity MaximumFlow() const
Graph::OutgoingOrOppositeIncomingArcIterator OutgoingOrOppositeIncomingArcIterator
CostValue UnitCost(ArcIndex arc) const
ArcIndex AddArcWithCapacityAndUnitCost(NodeIndex tail, NodeIndex head, FlowQuantity capacity, CostValue unit_cost)
void SetNodeSupply(NodeIndex node, FlowQuantity supply)
bool CheckFeasibility(std::vector< NodeIndex > *const infeasible_supply_node, std::vector< NodeIndex > *const infeasible_demand_node)