168#ifndef OR_TOOLS_GRAPH_MIN_COST_FLOW_H_
169#define OR_TOOLS_GRAPH_MIN_COST_FLOW_H_
188template <
typename Graph,
typename ArcFlowType,
typename ArcScaledCostType>
189class 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);
440 bool CheckInputConsistency()
const;
446 bool CheckResult()
const;
450 bool CheckCostRange()
const;
456 bool CheckRelabelPrecondition(
NodeIndex node)
const;
464 void ResetFirstAdmissibleArcs();
476 void SaturateAdmissibleArcs();
486 void InitializeActiveNodeStack();
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_;
Graph::OutgoingArcIterator OutgoingArcIterator
CostValue UnitCost(ArcIndex arc) 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
const Graph * graph() 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
CostValue GetOptimalCost() const
FlowQuantity Supply(NodeIndex node) const
void SetArcUnitCost(ArcIndex arc, ArcScaledCostType unit_cost)
ZVector< ArcIndex > ArcIndexArray
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