<ahref="arc__flow__builder_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="comment">// Copyright 2010-2021 Google LLC</span></div>
<divclass="line"><aid="l00002"name="l00002"></a><spanclass="lineno"> 2</span><spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div>
<divclass="line"><aid="l00003"name="l00003"></a><spanclass="lineno"> 3</span><spanclass="comment">// you may not use this file except in compliance with the License.</span></div>
<divclass="line"><aid="l00004"name="l00004"></a><spanclass="lineno"> 4</span><spanclass="comment">// You may obtain a copy of the License at</span></div>
<divclass="line"><aid="l00008"name="l00008"></a><spanclass="lineno"> 8</span><spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<divclass="line"><aid="l00009"name="l00009"></a><spanclass="lineno"> 9</span><spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div>
<divclass="line"><aid="l00010"name="l00010"></a><spanclass="lineno"> 10</span><spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment">// See the License for the specific language governing permissions and</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment">// limitations under the License.</span></div>
<divclass="line"><aid="l00014"name="l00014"></a><spanclass="lineno"> 14</span><spanclass="comment">// This code builds an arc-flow generator for vector-bin-packing problems.</span></div>
<divclass="line"><aid="l00015"name="l00015"></a><spanclass="lineno"> 15</span><spanclass="comment">// see https://people.math.gatech.edu/~tetali/PUBLIS/CKPT.pdf</span></div>
<divclass="line"><aid="l00016"name="l00016"></a><spanclass="lineno"> 16</span><spanclass="comment">// It implements a non-recursive version of algorithm 1 described in:</span></div>
<divclass="line"><aid="l00023"name="l00023"></a><spanclass="lineno"> 23</span><spanclass="comment">// Some improvements are not yet implemented:</span></div>
<divclass="line"><aid="l00024"name="l00024"></a><spanclass="lineno"> 24</span><spanclass="comment">// - Lifted stated: when storing a state of the dynamic programming forward</span></div>
<divclass="line"><aid="l00025"name="l00025"></a><spanclass="lineno"> 25</span><spanclass="comment">// pass, one can lift a state. A lifted state of a state S is a maximal</span></div>
<divclass="line"><aid="l00026"name="l00026"></a><spanclass="lineno"> 26</span><spanclass="comment">// increase of S that does not lose any state in the forward pass.</span></div>
<divclass="line"><aid="l00027"name="l00027"></a><spanclass="lineno"> 27</span><spanclass="comment">// A simple example is the following:</span></div>
<divclass="line"><aid="l00029"name="l00029"></a><spanclass="lineno"> 29</span><spanclass="comment">// 2 item of size 2.</span></div>
<divclass="line"><aid="l00030"name="l00030"></a><spanclass="lineno"> 30</span><spanclass="comment">// After adding item 1 in the DP pass, the state is (2).</span></div>
<divclass="line"><aid="l00031"name="l00031"></a><spanclass="lineno"> 31</span><spanclass="comment">// The lifted state is (3) that is (5) - (2) which is the maximal increase</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span><spanclass="comment">// of (2) that does not loose any state.</span></div>
<divclass="line"><aid="l00033"name="l00033"></a><spanclass="lineno"> 33</span><spanclass="comment">// To limit time spent computing this, one can lift a state only if the</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="comment">// remaining number of item is below a threshold.</span></div>
<divclass="line"><aid="l00035"name="l00035"></a><spanclass="lineno"> 35</span><spanclass="comment">// - Disable the backward pass (compress state towards the bin capacity).</span></div>
<divclass="line"><aid="l00036"name="l00036"></a><spanclass="lineno"> 36</span><spanclass="comment">// Although this reduces the graph a lot, this simplication is not valid</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="comment">// when the cost is not the number of bins, but a function of the capacity</span></div>
<divclass="line"><aid="l00038"name="l00038"></a><spanclass="lineno"> 38</span><spanclass="comment">// used (useful for fair allocation).</span></div>
<divclass="line"><aid="l00053"name="l00053"></a><spanclass="lineno"> 53</span><spanclass="comment">// Arc flow gragh built from a vector bin packing problem.</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment">// The first node will always be the source. The last will always be the sink</span></div>
<divclass="line"><aid="l00055"name="l00055"></a><spanclass="lineno"> 55</span><spanclass="comment">// of the arc-flow graph.</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span><spanclass="comment">// All the nodes explored during the DP phase.</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment">// In the forward pass, these are the consumed capacity of the bin at this</span></div>
<divclass="line"><aid="l00069"name="l00069"></a><spanclass="lineno"> 69</span><spanclass="comment">// state. In the backward pass, this is pushed up towards the max capacity</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// of the bin. In the final compression phase, this is pushed down towards</span></div>
<divclass="line"><aid="l00071"name="l00071"></a><spanclass="lineno"> 71</span><spanclass="comment">// the initial zero state.</span></div>
<divclass="line"><aid="l00079"name="l00079"></a><spanclass="lineno"> 79</span><spanclass="comment">// Arc flow builder. The input must enforce the following constraints:</span></div>
<divclass="line"><aid="l00080"name="l00080"></a><spanclass="lineno"> 80</span><spanclass="comment">// - item_dimensions_by_type.size() == demand_by_type.size() == num types</span></div>
<divclass="line"><aid="l00081"name="l00081"></a><spanclass="lineno"> 81</span><spanclass="comment">// - for each type t:</span></div>
<divclass="ttc"id="anamespaceoperations__research_1_1packing_html_a43c15c357e1f59a9ff10700a5ac7b63e"><divclass="ttname"><ahref="namespaceoperations__research_1_1packing.html#a43c15c357e1f59a9ff10700a5ac7b63e">operations_research::packing::BuildArcFlowGraph</a></div><divclass="ttdeci">ArcFlowGraph BuildArcFlowGraph(const std::vector< int >&bin_dimensions, const std::vector< std::vector< int >>&item_dimensions_by_type, const std::vector< int >&demand_by_type)</div><divclass="ttdef"><b>Definition:</b><ahref="arc__flow__builder_8cc_source.html#l00399">arc_flow_builder.cc:399</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">Collection of objects used to extend the Constraint Solver library.</div><divclass="ttdef"><b>Definition:</b><ahref="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
<divclass="ttc"id="astructoperations__research_1_1packing_1_1_arc_flow_graph_html_a405100e4926c5c9e6f758d909ce466d6"><divclass="ttname"><ahref="structoperations__research_1_1packing_1_1_arc_flow_graph.html#a405100e4926c5c9e6f758d909ce466d6">operations_research::packing::ArcFlowGraph::nodes</a></div><divclass="ttdeci">std::vector< std::vector< int >> nodes</div><divclass="ttdef"><b>Definition:</b><ahref="arc__flow__builder_8h_source.html#l00072">arc_flow_builder.h:72</a></div></div>