operations_research::MinCostFlow Class Reference

Detailed Description

Default MinCostFlow instance that uses StarGraph.

New clients should use SimpleMinCostFlow if they can.

Definition at line 609 of file min_cost_flow.h.

Public Types

typedef StarGraph ::NodeIndex NodeIndex
 
typedef StarGraph ::ArcIndex ArcIndex
 
typedef StarGraph ::OutgoingArcIterator OutgoingArcIterator
 
typedef StarGraph ::OutgoingOrOppositeIncomingArcIterator OutgoingOrOppositeIncomingArcIterator
 
typedef ZVector< ArcIndexArcIndexArray
 
enum  Status {
  NOT_SOLVED, OPTIMAL, FEASIBLE, INFEASIBLE,
  UNBALANCED, BAD_RESULT, BAD_COST_RANGE
}
 

Public Member Functions

 MinCostFlow (const StarGraph *graph)
 
const StarGraphgraph () const
 Returns the graph associated to the current object. More...
 
Status status () const
 Returns the status of last call to Solve(). More...
 
void SetNodeSupply (NodeIndex node, FlowQuantity supply)
 Sets the supply corresponding to node. More...
 
void SetArcUnitCost (ArcIndex arc, CostValue unit_cost)
 Sets the unit cost for the given arc. More...
 
void SetArcCapacity (ArcIndex arc, FlowQuantity new_capacity)
 Sets the capacity for the given arc. More...
 
void SetArcFlow (ArcIndex arc, FlowQuantity new_flow)
 Sets the flow for the given arc. More...
 
bool Solve ()
 Solves the problem, returning true if a min-cost flow could be found. More...
 
bool CheckFeasibility (std::vector< NodeIndex > *const infeasible_supply_node, std::vector< NodeIndex > *const infeasible_demand_node)
 Checks for feasibility, i.e., that all the supplies and demands can be matched without exceeding bottlenecks in the network. More...
 
bool MakeFeasible ()
 Makes the min-cost flow problem solvable by truncating supplies and demands to a level acceptable by the network. More...
 
CostValue GetOptimalCost () const
 Returns the cost of the minimum-cost flow found by the algorithm. More...
 
FlowQuantity Flow (ArcIndex arc) const
 Returns the flow on the given arc using the equations given in the comment on residual_arc_capacity_. More...
 
FlowQuantity Capacity (ArcIndex arc) const
 Returns the capacity of the given arc. More...
 
CostValue UnitCost (ArcIndex arc) const
 Returns the unscaled cost for the given arc. More...
 
FlowQuantity Supply (NodeIndex node) const
 Returns the supply at a given node. More...
 
FlowQuantity InitialSupply (NodeIndex node) const
 Returns the initial supply at a given node. More...
 
FlowQuantity FeasibleSupply (NodeIndex node) const
 Returns the largest supply (if > 0) or largest demand in absolute value (if < 0) admissible at node. More...
 
void SetUseUpdatePrices (bool value)
 Whether to use the UpdatePrices() heuristic. More...
 
void SetCheckFeasibility (bool value)
 Whether to check the feasibility of the problem with a max-flow, prior to solving it. More...
 

Member Typedef Documentation

◆ ArcIndex

◆ ArcIndexArray

Definition at line 329 of file min_cost_flow.h.

◆ NodeIndex

◆ OutgoingArcIterator

◆ OutgoingOrOppositeIncomingArcIterator

Member Enumeration Documentation

◆ Status

Enumerator
NOT_SOLVED 
OPTIMAL 
FEASIBLE 
INFEASIBLE 
UNBALANCED 
BAD_RESULT 
BAD_COST_RANGE 

Definition at line 194 of file min_cost_flow.h.

Constructor & Destructor Documentation

◆ MinCostFlow()

operations_research::MinCostFlow::MinCostFlow ( const StarGraph graph)
inlineexplicit

Definition at line 611 of file min_cost_flow.h.

Member Function Documentation

◆ Capacity()

Returns the capacity of the given arc.

◆ CheckFeasibility()

bool operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::CheckFeasibility ( std::vector< NodeIndex > *const  infeasible_supply_node,
std::vector< NodeIndex > *const  infeasible_demand_node 
)
inherited

Checks for feasibility, i.e., that all the supplies and demands can be matched without exceeding bottlenecks in the network.

If infeasible_supply_node (resp. infeasible_demand_node) are not NULL, they are populated with the indices of the nodes where the initial supplies (resp. demands) are too large. Feasible values for the supplies and demands are accessible through FeasibleSupply.

Note
CheckFeasibility is called by Solve() when the flag min_cost_flow_check_feasibility is set to true (which is the default.)

◆ FeasibleSupply()

Returns the largest supply (if > 0) or largest demand in absolute value (if < 0) admissible at node.

If the problem is not feasible, some of these values will be smaller (in absolute value) than the initial supplies and demand given as input.

◆ Flow()

Returns the flow on the given arc using the equations given in the comment on residual_arc_capacity_.

◆ GetOptimalCost()

CostValue operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::GetOptimalCost ( ) const
inlineinherited

Returns the cost of the minimum-cost flow found by the algorithm.

Definition at line 380 of file min_cost_flow.h.

◆ graph()

const StarGraph * operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::graph ( ) const
inlineinherited

Returns the graph associated to the current object.

Definition at line 337 of file min_cost_flow.h.

◆ InitialSupply()

Returns the initial supply at a given node.

◆ MakeFeasible()

Makes the min-cost flow problem solvable by truncating supplies and demands to a level acceptable by the network.

There may be several ways to do it. In our case, the levels are computed from the result of the max-flow algorithm run in CheckFeasibility(). MakeFeasible returns false if CheckFeasibility() was not called before.

◆ SetArcCapacity()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetArcCapacity ( ArcIndex  arc,
FlowQuantity  new_capacity 
)
inherited

Sets the capacity for the given arc.

◆ SetArcFlow()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetArcFlow ( ArcIndex  arc,
FlowQuantity  new_flow 
)
inherited

Sets the flow for the given arc.

Note that new_flow must be smaller than the capacity of the arc.

◆ SetArcUnitCost()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetArcUnitCost ( ArcIndex  arc,
CostValue  unit_cost 
)
inherited

Sets the unit cost for the given arc.

◆ SetCheckFeasibility()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetCheckFeasibility ( bool  value)
inlineinherited

Whether to check the feasibility of the problem with a max-flow, prior to solving it.

This uses about twice as much memory, but detects infeasible problems (where the flow can't be satisfied) and makes Solve() return INFEASIBLE. If you disable this check, you will spare memory but you must make sure that your problem is feasible, otherwise the code can loop forever.

Definition at line 414 of file min_cost_flow.h.

◆ SetNodeSupply()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetNodeSupply ( NodeIndex  node,
FlowQuantity  supply 
)
inherited

Sets the supply corresponding to node.

A demand is modeled as a negative supply.

◆ SetUseUpdatePrices()

void operations_research::GenericMinCostFlow< StarGraph , FlowQuantity , CostValue >::SetUseUpdatePrices ( bool  value)
inlineinherited

Whether to use the UpdatePrices() heuristic.

Definition at line 406 of file min_cost_flow.h.

◆ Solve()

Solves the problem, returning true if a min-cost flow could be found.

◆ status()

Returns the status of last call to Solve().

NOT_SOLVED is returned if Solve() has never been called or if the problem has been modified in such a way that the previous solution becomes invalid.

Definition at line 342 of file min_cost_flow.h.

◆ Supply()

Returns the supply at a given node.

Demands are modelled as negative supplies.

◆ UnitCost()

Returns the unscaled cost for the given arc.


The documentation for this class was generated from the following file: