<ahref="min__cost__flow_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div><divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> </div><divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment">// An implementation of a cost-scaling push-relabel algorithm for</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment">// the min-cost flow problem.</span></div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="comment">// In the following, we consider a graph G = (V,E) where V denotes the set</span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="comment">// of nodes (vertices) in the graph, E denotes the set of arcs (edges).</span></div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="comment">// n = |V| denotes the number of nodes in the graph, and m = |E| denotes the</span></div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment">// number of arcs in the graph.</span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="comment">// With each arc (v,w) is associated a nonnegative capacity u(v,w)</span></div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="comment">// (where 'u' stands for "upper bound") and a unit cost c(v,w). With</span></div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="comment">// each node v is associated a quantity named supply(v), which</span></div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="comment">// represents a supply of fluid (if >0) or a demand
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html">operations_research::SimpleMinCostFlow</a></div><divclass="ttdoc">A simple and efficient min-cost flow interface.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00213">min_cost_flow.h:213</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a60da0a24c813a9ee39f96cc36f8dd9ad"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a60da0a24c813a9ee39f96cc36f8dd9ad">operations_research::GenericMinCostFlow::MakeFeasible</a></div><divclass="ttdeci">bool MakeFeasible()</div><divclass="ttdoc">Makes the min-cost flow problem solvable by truncating supplies and demands to a level acceptable by ...</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a7e4301ebf8c5f86143e390494a0a6f4f"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a7e4301ebf8c5f86143e390494a0a6f4f">operations_research::GenericMinCostFlow::SetNodeSupply</a></div><divclass="ttdeci">void SetNodeSupply(NodeIndex node, FlowQuantity supply)</div><divclass="ttdoc">Sets the supply corresponding to node.</div></div>
<divclass="ttc"id="namespaceutil_html_ae76339cb2dcd3bc05ad762146f91fdda"><divclass="ttname"><ahref="namespaceutil.html#ae76339cb2dcd3bc05ad762146f91fdda">util::Graph</a></div><divclass="ttdeci">ListGraph Graph</div><divclass="ttdoc">Defining the simplest Graph interface as Graph for convenience.</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l02358">graph.h:2358</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_a49270938ce4794ae76f8a25c23ddef65"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#a49270938ce4794ae76f8a25c23ddef65">operations_research::SimpleMinCostFlow::MaximumFlow</a></div><divclass="ttdeci">FlowQuantity MaximumFlow() const</div><divclass="ttdoc">Returns the total flow of the minimum-cost flow found by the algorithm when the returned Status is OP...</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a8ea0e6e91a6965d8de090ef797bb4185"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a8ea0e6e91a6965d8de090ef797bb4185">operations_research::GenericMinCostFlow::graph</a></div><divclass="ttdeci">const Graph * graph() const</div><divclass="ttdoc">Returns the graph associated to the current object.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00337">min_cost_flow.h:337</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_ace5a6df9ac9993c42cd091f6e9ebbd54"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#ace5a6df9ac9993c42cd091f6e9ebbd54">operations_research::GenericMinCostFlow::status</a></div><divclass="ttdeci">Status status() const</div><divclass="ttdoc">Returns the status of last call to Solve().</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00342">min_cost_flow.h:342</a></div></div>
<divclass="ttc"id="classoperations__research_1_1MinCostFlowBase_html"><divclass="ttname"><ahref="classoperations__research_1_1MinCostFlowBase.html">operations_research::MinCostFlowBase</a></div><divclass="ttdoc">Different statuses for a solved problem.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00192">min_cost_flow.h:192</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_ac2a7f803ea909ac1f3225f2607f1f33b"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#ac2a7f803ea909ac1f3225f2607f1f33b">operations_research::SimpleMinCostFlow::Flow</a></div><divclass="ttdeci">FlowQuantity Flow(ArcIndex arc) const</div><divclass="ttdoc">Returns the flow on arc, this only make sense for a successful Solve().</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_ac5a5362a674cfb2a7589bcd77c484c17"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#ac5a5362a674cfb2a7589bcd77c484c17">operations_research::GenericMinCostFlow::Flow</a></div><divclass="ttdeci">FlowQuantity Flow(ArcIndex arc) const</div><divclass="ttdoc">Returns the flow on the given arc using the equations given in the comment on residual_arc_capacity_.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a35f31d23e3f300f2e36aa46b2e854c00"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a35f31d23e3f300f2e36aa46b2e854c00">operations_research::GenericMinCostFlow::SetArcCapacity</a></div><divclass="ttdeci">void SetArcCapacity(ArcIndex arc, ArcFlowType new_capacity)</div><divclass="ttdoc">Sets the capacity for the given arc.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a0969b64c9993394fb1cc97a2404e12a4"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a0969b64c9993394fb1cc97a2404e12a4">operations_research::GenericMinCostFlow::SetArcUnitCost</a></div><divclass="ttdeci">void SetArcUnitCost(ArcIndex arc, ArcScaledCostType unit_cost)</div><divclass="ttdoc">Sets the unit cost for the given arc.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a44c22a9d4609a54cfc7034de3e541ce7"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a44c22a9d4609a54cfc7034de3e541ce7">operations_research::GenericMinCostFlow::Capacity</a></div><divclass="ttdeci">FlowQuantity Capacity(ArcIndex arc) const</div><divclass="ttdoc">Returns the capacity of the given arc.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_ae70575b0b8bbc06301778b172752958b"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#ae70575b0b8bbc06301778b172752958b">operations_research::GenericMinCostFlow::UnitCost</a></div><divclass="ttdeci">CostValue UnitCost(ArcIndex arc) const</div><divclass="ttdoc">Returns the unscaled cost for the given arc.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a37cb4245bf39c34116d5466d7922f565"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a37cb4245bf39c34116d5466d7922f565">operations_research::GenericMinCostFlow::GetOptimalCost</a></div><divclass="ttdeci">CostValue GetOptimalCost() const</div><divclass="ttdoc">Returns the cost of the minimum-cost flow found by the algorithm.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00380">min_cost_flow.h:380</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_af4eeb2bca251bf02604bcbea5c304421"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#af4eeb2bca251bf02604bcbea5c304421">operations_research::SimpleMinCostFlow::Solve</a></div><divclass="ttdeci">Status Solve()</div><divclass="ttdoc">Solves the problem, and returns the problem status.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00239">min_cost_flow.h:239</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_aaec6a152673412884a7c0d1b59991a70"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#aaec6a152673412884a7c0d1b59991a70">operations_research::SimpleMinCostFlow::OptimalCost</a></div><divclass="ttdeci">CostValue OptimalCost() const</div><divclass="ttdoc">Returns the cost of the minimum-cost flow found by the algorithm when the returned Status is OPTIMAL.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a15963b8d1126b858e249c58658934305"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a15963b8d1126b858e249c58658934305">operations_research::GenericMinCostFlow::InitialSupply</a></div><divclass="ttdeci">FlowQuantity InitialSupply(NodeIndex node) const</div><divclass="ttdoc">Returns the initial supply at a given node.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a17aff4acf62f808db05d5c43f37efda2"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a17aff4acf62f808db05d5c43f37efda2">operations_research::GenericMinCostFlow::GenericMinCostFlow</a></div><divclass="ttdeci">GenericMinCostFlow(const Graph *graph)</div><divclass="ttdoc">Initialize a MinCostFlow instance on the given graph.</div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_a4f442c73b242e40a793d529df4e44d07"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#a4f442c73b242e40a793d529df4e44d07">operations_research::SimpleMinCostFlow::SimpleMinCostFlow</a></div><divclass="ttdeci">SimpleMinCostFlow()</div><divclass="ttdoc">The constructor takes no size.</div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_a7410b695f7e06dd3de7e6920bc28a3ac"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#a7410b695f7e06dd3de7e6920bc28a3ac">operations_research::SimpleMinCostFlow::SetNodeSupply</a></div><divclass="ttdeci">void SetNodeSupply(NodeIndex node, FlowQuantity supply)</div><divclass="ttdoc">Sets the supply of the given node.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a816e24f3a6af98c2b3ae1854f6fc0781"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a816e24f3a6af98c2b3ae1854f6fc0781">operations_research::GenericMinCostFlow::SetUseUpdatePrices</a></div><divclass="ttdeci">void SetUseUpdatePrices(bool value)</div><divclass="ttdoc">Whether to use the UpdatePrices() heuristic.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00406">min_cost_flow.h:406</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a60875aa935bd9594db707bfd97eab98c"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a60875aa935bd9594db707bfd97eab98c">operations_research::GenericMinCostFlow::SetArcFlow</a></div><divclass="ttdeci">void SetArcFlow(ArcIndex arc, ArcFlowType new_flow)</div><divclass="ttdoc">Sets the flow for the given arc.</div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a01f13e85a3d12e356f26d80210a6755f"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a01f13e85a3d12e356f26d80210a6755f">operations_research::GenericMinCostFlow::CheckFeasibility</a></div><divclass="ttdeci">bool CheckFeasibility(std::vector< NodeIndex > *const infeasible_supply_node, std::vector< NodeIndex > *const infeasible_demand_node)</div><divclass="ttdoc">Checks for feasibility, i.e., that all the supplies and demands can be matched without exceeding bott...</div></div>
<divclass="ttc"id="namespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...</div><divclass="ttdef"><b>Definition:</b><ahref="christofides_8h_source.html#l00033">christofides.h:33</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_afa58296d5399afd27f8bed235e18309d"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#afa58296d5399afd27f8bed235e18309d">operations_research::GenericMinCostFlow::FeasibleSupply</a></div><divclass="ttdeci">FlowQuantity FeasibleSupply(NodeIndex node) const</div><divclass="ttdoc">Returns the largest supply (if > 0) or largest demand in absolute value (if < 0) admissible at node.</div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_a632cc069a03f2d9873715467c09a3810"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#a632cc069a03f2d9873715467c09a3810">operations_research::SimpleMinCostFlow::AddArcWithCapacityAndUnitCost</a></div><divclass="ttdeci">ArcIndex AddArcWithCapacityAndUnitCost(NodeIndex tail, NodeIndex head, FlowQuantity capacity, CostValue unit_cost)</div><divclass="ttdoc">Adds a directed arc from tail to head to the underlying graph with a given capacity and cost per unit...</div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_a443e6d29a83127237379abb898a26195"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#a443e6d29a83127237379abb898a26195">operations_research::SimpleMinCostFlow::SolveMaxFlowWithMinCost</a></div><divclass="ttdeci">Status SolveMaxFlowWithMinCost()</div><divclass="ttdoc">Same as Solve(), but does not have the restriction that the supply must match the demand or that the ...</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00248">min_cost_flow.h:248</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a67cea170737362bd37bc8c8f8f024555"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a67cea170737362bd37bc8c8f8f024555">operations_research::GenericMinCostFlow::Supply</a></div><divclass="ttdeci">FlowQuantity Supply(NodeIndex node) const</div><divclass="ttdoc">Returns the supply at a given node.</div></div>
<divclass="ttc"id="namespaceoperations__research_html_a0e629e35bfa311b31dd7f5065eb834bb"><divclass="ttname"><ahref="namespaceoperations__research.html#a0e629e35bfa311b31dd7f5065eb834bb">operations_research::NodeIndex</a></div><divclass="ttdeci">int32 NodeIndex</div><divclass="ttdoc">Standard instantiation of ForwardEbertGraph (named 'ForwardStarGraph') of EbertGraph (named 'StarGrap...</div><divclass="ttdef"><b>Definition:</b><ahref="ebert__graph_8h_source.html#l00192">ebert_graph.h:192</a></div></div>
<divclass="ttc"id="classoperations__research_1_1GenericMinCostFlow_html_a9fffb489dce981de3233b1702b801eb6"><divclass="ttname"><ahref="classoperations__research_1_1GenericMinCostFlow.html#a9fffb489dce981de3233b1702b801eb6">operations_research::GenericMinCostFlow::SetCheckFeasibility</a></div><divclass="ttdeci">void SetCheckFeasibility(bool value)</div><divclass="ttdoc">Whether to check the feasibility of the problem with a max-flow, prior to solving it.</div><divclass="ttdef"><b>Definition:</b><ahref="min__cost__flow_8h_source.html#l00414">min_cost_flow.h:414</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SimpleMinCostFlow_html_ac80325e043df267da7b4f9e0799bba54"><divclass="ttname"><ahref="classoperations__research_1_1SimpleMinCostFlow.html#ac80325e043df267da7b4f9e0799bba54">operations_research::SimpleMinCostFlow::NumNodes</a></div><divclass="ttdeci">NodeIndex NumNodes() const</div><divclass="ttdoc">Accessors for the user given data.</div></div>