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>
189 class GenericMinCostFlow;
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_;
332 typedef typename Graph::OutgoingOrOppositeIncomingArcIterator
375 std::vector<NodeIndex>*
const infeasible_demand_node);
444 bool CheckInputConsistency()
const;
450 bool CheckResult()
const;
454 bool CheckCostRange()
const;
460 bool CheckRelabelPrecondition(
NodeIndex node)
const;
468 void ResetFirstAdmissibleArcs();
480 void SaturateAdmissibleArcs();
490 void InitializeActiveNodeStack();
557 ZVector<ArcFlowType> residual_arc_capacity_;
565 std::stack<NodeIndex> active_nodes_;
572 const int64_t alpha_;
578 ZVector<ArcScaledCostType> scaled_arc_unit_cost_;
597 int num_relabels_since_last_price_update_;
600 bool feasibility_checked_;
603 bool use_price_update_;
606 bool check_feasibility_;
Graph::OutgoingArcIterator OutgoingArcIterator
CostValue UnitCost(ArcIndex arc) const
const Graph * graph() const
Graph::OutgoingOrOppositeIncomingArcIterator OutgoingOrOppositeIncomingArcIterator
FlowQuantity FeasibleSupply(NodeIndex node) const
FlowQuantity Flow(ArcIndex arc) const
GenericMinCostFlow(const Graph *graph)
Graph::NodeIndex NodeIndex
void SetCheckFeasibility(bool value)
void SetNodeSupply(NodeIndex node, FlowQuantity supply)
FlowQuantity InitialSupply(NodeIndex node) const
void SetArcFlow(ArcIndex arc, ArcFlowType new_flow)
bool CheckFeasibility(std::vector< NodeIndex > *const infeasible_supply_node, std::vector< NodeIndex > *const infeasible_demand_node)
FlowQuantity Capacity(ArcIndex arc) const
FlowQuantity Supply(NodeIndex node) const
void SetArcUnitCost(ArcIndex arc, ArcScaledCostType unit_cost)
ZVector< ArcIndex > ArcIndexArray
CostValue GetOptimalCost()
void SetUseUpdatePrices(bool value)
void SetArcCapacity(ArcIndex arc, ArcFlowType new_capacity)
MinCostFlow(const StarGraph *graph)
CostValue UnitCost(ArcIndex arc) const
ArcIndex AddArcWithCapacityAndUnitCost(NodeIndex tail, NodeIndex head, FlowQuantity capacity, CostValue unit_cost)
Status SolveMaxFlowWithMinCost()
FlowQuantity Flow(ArcIndex arc) const
FlowQuantity MaximumFlow() const
NodeIndex NumNodes() const
SimpleMinCostFlow(NodeIndex reserve_num_nodes=0, ArcIndex reserve_num_arcs=0)
void SetNodeSupply(NodeIndex node, FlowQuantity supply)
NodeIndex Tail(ArcIndex arc) const
FlowQuantity Capacity(ArcIndex arc) const
FlowQuantity Supply(NodeIndex node) const
NodeIndex Head(ArcIndex arc) const
CostValue OptimalCost() const
GurobiMPCallbackContext * context
Collection of objects used to extend the Constraint Solver library.
ZVector< FlowQuantity > QuantityArray
ZVector< CostValue > CostArray