Update python doc

This commit is contained in:
Mizux Seiha
2021-02-26 14:49:16 +01:00
parent d6f2a39833
commit b459168bc7
2 changed files with 416 additions and 158 deletions

View File

@@ -96,33 +96,6 @@ class _SwigNonDynamicMeta(type):
import weakref
class IntBoolPair(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
_pywrapcp.IntBoolPair_swiginit(self, _pywrapcp.new_IntBoolPair(*args))
first = property(_pywrapcp.IntBoolPair_first_get, _pywrapcp.IntBoolPair_first_set)
second = property(_pywrapcp.IntBoolPair_second_get, _pywrapcp.IntBoolPair_second_set)
def __len__(self):
return 2
def __repr__(self):
return str((self.first, self.second))
def __getitem__(self, index):
if not (index % 2):
return self.first
else:
return self.second
def __setitem__(self, index, val):
if not (index % 2):
self.first = val
else:
self.second = val
__swig_destroy__ = _pywrapcp.delete_IntBoolPair
# Register IntBoolPair in _pywrapcp:
_pywrapcp.IntBoolPair_swigregister(IntBoolPair)
class DefaultPhaseParameters(object):
r"""
This struct holds all parameters for the default search.
@@ -4703,6 +4676,12 @@ class RoutingIndexManager(object):
def GetNumberOfIndices(self) -> "int":
return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
def GetStartIndex(self, vehicle: "int") -> "int64":
return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
def GetEndIndex(self, vehicle: "int") -> "int64":
return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
def NodeToIndex(self, node: "operations_research::RoutingIndexManager::NodeIndex") -> "int64":
return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
@@ -4752,12 +4731,19 @@ class RoutingModel(object):
_pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
__swig_destroy__ = _pywrapcp.delete_RoutingModel
def RegisterUnaryTransitVector(self, values: "std::vector< int64 >") -> "int":
r""" Registers 'callback' and returns its index."""
return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
def RegisterUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int":
return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback)
def RegisterPositiveUnaryTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback1") -> "int":
return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback)
def RegisterTransitMatrix(self, values: "std::vector< std::vector< int64 > >") -> "int":
return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def RegisterTransitCallback(self, callback: "operations_research::RoutingModel::TransitCallback2") -> "int":
return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback)
@@ -4820,6 +4806,34 @@ class RoutingModel(object):
def AddConstantDimension(self, value: "int64", capacity: "int64", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >":
return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
def AddVectorDimension(self, values: "std::vector< int64 >", capacity: "int64", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >":
r"""
Creates a dimension where the transit variable is constrained to be
equal to 'values[i]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).
"""
return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def AddMatrixDimension(self, values: "std::vector< std::vector< int64 > >", capacity: "int64", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >":
r"""
Creates a dimension where the transit variable is constrained to be
equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered transit callback
and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).
"""
return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def MakePathSpansAndTotalSlacks(self, dimension: "RoutingDimension", spans: "std::vector< operations_research::IntVar * >", total_slacks: "std::vector< operations_research::IntVar * >") -> "operations_research::Constraint *":
r"""
For every vehicle of the routing model:
@@ -5839,18 +5853,6 @@ class RoutingModel(object):
"""
return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
def RegisterUnaryTransitVector(self, values: "std::vector< int64 > const &") -> "int":
return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
def AddVectorDimension(self, values: "std::vector< int64 > const &", capacity: "int64", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >":
return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def RegisterTransitMatrix(self, values: "std::vector< std::vector< int64 > > const &") -> "int":
return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def AddMatrixDimension(self, values: "std::vector< std::vector< int64 > > const &", capacity: "int64", fix_start_cumul_to_zero: "bool", name: "std::string const &") -> "std::pair< int,bool >":
return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
# Register RoutingModel in _pywrapcp:
_pywrapcp.RoutingModel_swigregister(RoutingModel)
cvar = _pywrapcp.cvar
@@ -9476,62 +9478,6 @@ then SlackVar(nodeA) &gt;= sum_{breaks [tA, tB)} duration(break).</p></div>
</li>
</ul>
</dd>
<dt id="pywrapcp.IntBoolPair"><code class="flex name class">
<span>class <span class="ident">IntBoolPair</span></span>
<span>(</span><span>*args)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class IntBoolPair(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc=&#34;The membership flag&#34;)
__repr__ = _swig_repr
def __init__(self, *args):
_pywrapcp.IntBoolPair_swiginit(self, _pywrapcp.new_IntBoolPair(*args))
first = property(_pywrapcp.IntBoolPair_first_get, _pywrapcp.IntBoolPair_first_set)
second = property(_pywrapcp.IntBoolPair_second_get, _pywrapcp.IntBoolPair_second_set)
def __len__(self):
return 2
def __repr__(self):
return str((self.first, self.second))
def __getitem__(self, index):
if not (index % 2):
return self.first
else:
return self.second
def __setitem__(self, index, val):
if not (index % 2):
self.first = val
else:
self.second = val
__swig_destroy__ = _pywrapcp.delete_IntBoolPair</code></pre>
</details>
<h3>Instance variables</h3>
<dl>
<dt id="pywrapcp.IntBoolPair.first"><code class="name">var <span class="ident">first</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="pywrapcp.IntBoolPair.second"><code class="name">var <span class="ident">second</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="pywrapcp.IntBoolPair.thisown"><code class="name">var <span class="ident">thisown</span></code></dt>
<dd>
<div class="desc"><p>The membership flag</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc=&#34;The membership flag&#34;)</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="pywrapcp.IntExpr"><code class="flex name class">
<span>class <span class="ident">IntExpr</span></span>
<span>(</span><span>*args, **kwargs)</span>
@@ -15917,6 +15863,12 @@ and end nodes) + number of non-start or end nodes.</p></div>
def GetNumberOfIndices(self) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
def GetStartIndex(self, vehicle: &#34;int&#34;) -&gt; &#34;int64&#34;:
return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
def GetEndIndex(self, vehicle: &#34;int&#34;) -&gt; &#34;int64&#34;:
return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
def NodeToIndex(self, node: &#34;operations_research::RoutingIndexManager::NodeIndex&#34;) -&gt; &#34;int64&#34;:
return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
@@ -15938,6 +15890,19 @@ and end nodes) + number of non-start or end nodes.</p></div>
</dl>
<h3>Methods</h3>
<dl>
<dt id="pywrapcp.RoutingIndexManager.GetEndIndex"><code class="name flex">
<span>def <span class="ident">GetEndIndex</span></span>(<span>self, vehicle: int) > int64</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def GetEndIndex(self, vehicle: &#34;int&#34;) -&gt; &#34;int64&#34;:
return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)</code></pre>
</details>
</dd>
<dt id="pywrapcp.RoutingIndexManager.GetNumberOfIndices"><code class="name flex">
<span>def <span class="ident">GetNumberOfIndices</span></span>(<span>self) > int</span>
</code></dt>
@@ -15977,6 +15942,19 @@ and end nodes) + number of non-start or end nodes.</p></div>
return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)</code></pre>
</details>
</dd>
<dt id="pywrapcp.RoutingIndexManager.GetStartIndex"><code class="name flex">
<span>def <span class="ident">GetStartIndex</span></span>(<span>self, vehicle: int) > int64</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def GetStartIndex(self, vehicle: &#34;int&#34;) -&gt; &#34;int64&#34;:
return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)</code></pre>
</details>
</dd>
<dt id="pywrapcp.RoutingIndexManager.IndexToNode"><code class="name flex">
<span>def <span class="ident">IndexToNode</span></span>(<span>self, index: int64) > operations_research::<a title="pywrapcp.RoutingIndexManager" href="#pywrapcp.RoutingIndexManager">RoutingIndexManager</a>::NodeIndex</span>
</code></dt>
@@ -16039,12 +16017,19 @@ and end nodes) + number of non-start or end nodes.</p></div>
_pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
__swig_destroy__ = _pywrapcp.delete_RoutingModel
def RegisterUnaryTransitVector(self, values: &#34;std::vector&lt; int64 &gt;&#34;) -&gt; &#34;int&#34;:
r&#34;&#34;&#34; Registers &#39;callback&#39; and returns its index.&#34;&#34;&#34;
return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
def RegisterUnaryTransitCallback(self, callback: &#34;operations_research::RoutingModel::TransitCallback1&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback)
def RegisterPositiveUnaryTransitCallback(self, callback: &#34;operations_research::RoutingModel::TransitCallback1&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback)
def RegisterTransitMatrix(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt;&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def RegisterTransitCallback(self, callback: &#34;operations_research::RoutingModel::TransitCallback2&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback)
@@ -16107,6 +16092,34 @@ and end nodes) + number of non-start or end nodes.</p></div>
def AddConstantDimension(self, value: &#34;int64&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
def AddVectorDimension(self, values: &#34;std::vector&lt; int64 &gt;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
r&#34;&#34;&#34;
Creates a dimension where the transit variable is constrained to be
equal to &#39;values[i]&#39; for node i; &#39;capacity&#39; is the upper bound of
the cumul variables. &#39;name&#39; is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn&#39;t create the new dimension but still register a new callback).
&#34;&#34;&#34;
return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def AddMatrixDimension(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
r&#34;&#34;&#34;
Creates a dimension where the transit variable is constrained to be
equal to &#39;values[i][next(i)]&#39; for node i; &#39;capacity&#39; is the upper bound of
the cumul variables. &#39;name&#39; is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered transit callback
and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn&#39;t create the new dimension but still register a new callback).
&#34;&#34;&#34;
return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def MakePathSpansAndTotalSlacks(self, dimension: &#34;RoutingDimension&#34;, spans: &#34;std::vector&lt; operations_research::IntVar * &gt;&#34;, total_slacks: &#34;std::vector&lt; operations_research::IntVar * &gt;&#34;) -&gt; &#34;operations_research::Constraint *&#34;:
r&#34;&#34;&#34;
For every vehicle of the routing model:
@@ -17124,19 +17137,7 @@ and end nodes) + number of non-start or end nodes.</p></div>
departute time, n is the number of nodes in the network and m is the
number of vehicles.
&#34;&#34;&#34;
return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
def RegisterUnaryTransitVector(self, values: &#34;std::vector&lt; int64 &gt; const &amp;&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
def AddVectorDimension(self, values: &#34;std::vector&lt; int64 &gt; const &amp;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
def RegisterTransitMatrix(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt; const &amp;&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def AddMatrixDimension(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt; const &amp;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)</code></pre>
return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)</code></pre>
</details>
<h3>Class variables</h3>
<dl>
@@ -17534,15 +17535,34 @@ vehicle routing problem.</p></div>
</details>
</dd>
<dt id="pywrapcp.RoutingModel.AddMatrixDimension"><code class="name flex">
<span>def <span class="ident">AddMatrixDimension</span></span>(<span>self, values: std::vector< std::vector< int64 > > const &, capacity: int64, fix_start_cumul_to_zero: bool, name: std::string const &) > std::pair< int,bool ></span>
<span>def <span class="ident">AddMatrixDimension</span></span>(<span>self, values: std::vector< std::vector< int64 > >, capacity: int64, fix_start_cumul_to_zero: bool, name: std::string const &) > std::pair< int,bool ></span>
</code></dt>
<dd>
<div class="desc"></div>
<div class="desc"><p>Creates a dimension where the transit variable is constrained to be
equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered transit callback
and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def AddMatrixDimension(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt; const &amp;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
<pre><code class="python">def AddMatrixDimension(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
r&#34;&#34;&#34;
Creates a dimension where the transit variable is constrained to be
equal to &#39;values[i][next(i)]&#39; for node i; &#39;capacity&#39; is the upper bound of
the cumul variables. &#39;name&#39; is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered transit callback
and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn&#39;t create the new dimension but still register a new callback).
&#34;&#34;&#34;
return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)</code></pre>
</details>
</dd>
@@ -17805,15 +17825,34 @@ solution finalizer.</p></div>
</details>
</dd>
<dt id="pywrapcp.RoutingModel.AddVectorDimension"><code class="name flex">
<span>def <span class="ident">AddVectorDimension</span></span>(<span>self, values: std::vector< int64 > const &, capacity: int64, fix_start_cumul_to_zero: bool, name: std::string const &) > std::pair< int,bool ></span>
<span>def <span class="ident">AddVectorDimension</span></span>(<span>self, values: std::vector< int64 >, capacity: int64, fix_start_cumul_to_zero: bool, name: std::string const &) > std::pair< int,bool ></span>
</code></dt>
<dd>
<div class="desc"></div>
<div class="desc"><p>Creates a dimension where the transit variable is constrained to be
equal to 'values[i]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def AddVectorDimension(self, values: &#34;std::vector&lt; int64 &gt; const &amp;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
<pre><code class="python">def AddVectorDimension(self, values: &#34;std::vector&lt; int64 &gt;&#34;, capacity: &#34;int64&#34;, fix_start_cumul_to_zero: &#34;bool&#34;, name: &#34;std::string const &amp;&#34;) -&gt; &#34;std::pair&lt; int,bool &gt;&#34;:
r&#34;&#34;&#34;
Creates a dimension where the transit variable is constrained to be
equal to &#39;values[i]&#39; for node i; &#39;capacity&#39; is the upper bound of
the cumul variables. &#39;name&#39; is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn&#39;t create the new dimension but still register a new callback).
&#34;&#34;&#34;
return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)</code></pre>
</details>
</dd>
@@ -19506,7 +19545,7 @@ when using dimensions with slack.</p></div>
</details>
</dd>
<dt id="pywrapcp.RoutingModel.RegisterTransitMatrix"><code class="name flex">
<span>def <span class="ident">RegisterTransitMatrix</span></span>(<span>self, values: std::vector< std::vector< int64 > > const &) > int</span>
<span>def <span class="ident">RegisterTransitMatrix</span></span>(<span>self, values: std::vector< std::vector< int64 > >) > int</span>
</code></dt>
<dd>
<div class="desc"></div>
@@ -19514,7 +19553,7 @@ when using dimensions with slack.</p></div>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def RegisterTransitMatrix(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt; const &amp;&#34;) -&gt; &#34;int&#34;:
<pre><code class="python">def RegisterTransitMatrix(self, values: &#34;std::vector&lt; std::vector&lt; int64 &gt; &gt;&#34;) -&gt; &#34;int&#34;:
return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)</code></pre>
</details>
</dd>
@@ -19532,15 +19571,16 @@ when using dimensions with slack.</p></div>
</details>
</dd>
<dt id="pywrapcp.RoutingModel.RegisterUnaryTransitVector"><code class="name flex">
<span>def <span class="ident">RegisterUnaryTransitVector</span></span>(<span>self, values: std::vector< int64 > const &) > int</span>
<span>def <span class="ident">RegisterUnaryTransitVector</span></span>(<span>self, values: std::vector< int64 >) > int</span>
</code></dt>
<dd>
<div class="desc"></div>
<div class="desc"><p>Registers 'callback' and returns its index.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def RegisterUnaryTransitVector(self, values: &#34;std::vector&lt; int64 &gt; const &amp;&#34;) -&gt; &#34;int&#34;:
<pre><code class="python">def RegisterUnaryTransitVector(self, values: &#34;std::vector&lt; int64 &gt;&#34;) -&gt; &#34;int&#34;:
r&#34;&#34;&#34; Registers &#39;callback&#39; and returns its index.&#34;&#34;&#34;
return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)</code></pre>
</details>
</dd>
@@ -28561,14 +28601,6 @@ OR
</ul>
</li>
<li>
<h4><code><a title="pywrapcp.IntBoolPair" href="#pywrapcp.IntBoolPair">IntBoolPair</a></code></h4>
<ul class="">
<li><code><a title="pywrapcp.IntBoolPair.first" href="#pywrapcp.IntBoolPair.first">first</a></code></li>
<li><code><a title="pywrapcp.IntBoolPair.second" href="#pywrapcp.IntBoolPair.second">second</a></code></li>
<li><code><a title="pywrapcp.IntBoolPair.thisown" href="#pywrapcp.IntBoolPair.thisown">thisown</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="pywrapcp.IntExpr" href="#pywrapcp.IntExpr">IntExpr</a></code></h4>
<ul class="two-column">
<li><code><a title="pywrapcp.IntExpr.Bound" href="#pywrapcp.IntExpr.Bound">Bound</a></code></li>
@@ -28954,9 +28986,11 @@ OR
<li>
<h4><code><a title="pywrapcp.RoutingIndexManager" href="#pywrapcp.RoutingIndexManager">RoutingIndexManager</a></code></h4>
<ul class="two-column">
<li><code><a title="pywrapcp.RoutingIndexManager.GetEndIndex" href="#pywrapcp.RoutingIndexManager.GetEndIndex">GetEndIndex</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.GetNumberOfIndices" href="#pywrapcp.RoutingIndexManager.GetNumberOfIndices">GetNumberOfIndices</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.GetNumberOfNodes" href="#pywrapcp.RoutingIndexManager.GetNumberOfNodes">GetNumberOfNodes</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.GetNumberOfVehicles" href="#pywrapcp.RoutingIndexManager.GetNumberOfVehicles">GetNumberOfVehicles</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.GetStartIndex" href="#pywrapcp.RoutingIndexManager.GetStartIndex">GetStartIndex</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.IndexToNode" href="#pywrapcp.RoutingIndexManager.IndexToNode">IndexToNode</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.NodeToIndex" href="#pywrapcp.RoutingIndexManager.NodeToIndex">NodeToIndex</a></code></li>
<li><code><a title="pywrapcp.RoutingIndexManager.thisown" href="#pywrapcp.RoutingIndexManager.thisown">thisown</a></code></li>

View File

@@ -518,11 +518,22 @@ class IntVar(LinearExpr):
def __init__(self, model, domain, name):
&#34;&#34;&#34;See CpModel.NewIntVar below.&#34;&#34;&#34;
self.__model = model
self.__index = len(model.variables)
self.__var = model.variables.add()
self.__var.domain.extend(domain.FlattenedIntervals())
self.__var.name = name
self.__negation = None
# Python do not support multiple __init__ methods.
# This method is only called from the CpModel class.
# We hack the parameter to support the two cases:
# case 1:
# model is a CpModelProto, domain is a Domain, and name is a string.
# case 2:
# model is a CpModelProto, domain is an index (int), and name is None.
if isinstance(domain, numbers.Integral) and name is None:
self.__index = domain
self.__var = model.variables[domain]
else:
self.__index = len(model.variables)
self.__var = model.variables.add()
self.__var.domain.extend(domain.FlattenedIntervals())
self.__var.name = name
def Index(self):
&#34;&#34;&#34;Returns the index of the variable in the model.&#34;&#34;&#34;
@@ -702,15 +713,28 @@ class IntervalVar(object):
def __init__(self, model, start_index, size_index, end_index,
is_present_index, name):
self.__model = model
self.__index = len(model.constraints)
self.__ct = self.__model.constraints.add()
self.__ct.interval.start = start_index
self.__ct.interval.size = size_index
self.__ct.interval.end = end_index
if is_present_index is not None:
self.__ct.enforcement_literal.append(is_present_index)
if name:
self.__ct.name = name
# As with the IntVar::__init__ method, we hack the __init__ method to
# support two use cases:
# case 1: called when creating a new interval variable.
# {start|size|end}_index are indices of integer variables
# is_present_index is either None or the index of a Boolean literal.
# name is a string
# case 2: called when querying an existing interval variable.
# start_index is an int, all parameters after are None.
if (size_index is None and end_index is None and
is_present_index is None and name is None):
self.__index = start_index
self.__ct = model.constraints[start_index]
else:
self.__index = len(model.constraints)
self.__ct = self.__model.constraints.add()
self.__ct.interval.start = start_index
self.__ct.interval.size = size_index
self.__ct.interval.end = end_index
if is_present_index is not None:
self.__ct.enforcement_literal.append(is_present_index)
if name:
self.__ct.name = name
def Index(self):
&#34;&#34;&#34;Returns the index of the interval constraint in the model.&#34;&#34;&#34;
@@ -753,7 +777,6 @@ class CpModel(object):
def __init__(self):
self.__model = cp_model_pb2.CpModelProto()
self.__constant_map = {}
self.__optional_constant_map = {}
# Integer variable.
@@ -797,7 +820,8 @@ class CpModel(object):
def NewConstant(self, value):
&#34;&#34;&#34;Declares a constant integer.&#34;&#34;&#34;
return IntVar(self.__model, Domain(value, value), &#39;&#39;)
return IntVar(self.__model, self.GetOrMakeIndexFromConstant(value),
None)
# Linear constraints.
@@ -1456,6 +1480,50 @@ class CpModel(object):
model_ct.cumulative.capacity = self.GetOrMakeIndex(capacity)
return ct
# Support for deep copy.
def CopyFrom(self, other_model):
&#34;&#34;&#34;Reset the model, and creates a new one from a CpModelProto instance.&#34;&#34;&#34;
self.__model.CopyFrom(other_model.Proto())
# Rebuild constant map.
self.__constant_map.clear()
for i, var in enumerate(self.__model.variables):
if len(var.domain) == 2 and var.domain[0] == var.domain[1]:
self.__constant_map[var.domain[0]] = i
def GetBoolVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created Boolean variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: out of bound index {index}&#39;)
var = self.__model.variables[index]
if len(var.domain) != 2 or var.domain[0] &lt; 0 or var.domain[1] &gt; 1:
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: index {index} does not reference&#39; +
&#39; a Boolean variable&#39;)
return IntVar(self.__model, index, None)
def GetIntVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created integer variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetIntVarFromProtoIndex: out of bound index {index}&#39;)
return IntVar(self.__model, index, None)
def GetIntervalVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created interval variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.constraints):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: out of bound index {index}&#39;)
ct = self.__model.constraints[index]
if not ct.HasField(&#39;interval&#39;):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: index {index} does not reference an&#39;
+ &#39; interval variable&#39;)
return IntervalVar(self.__model, index, None, None, None, None)
# Helpers.
def __str__(self):
@@ -2240,7 +2308,6 @@ Returns:
def __init__(self):
self.__model = cp_model_pb2.CpModelProto()
self.__constant_map = {}
self.__optional_constant_map = {}
# Integer variable.
@@ -2284,7 +2351,8 @@ Returns:
def NewConstant(self, value):
&#34;&#34;&#34;Declares a constant integer.&#34;&#34;&#34;
return IntVar(self.__model, Domain(value, value), &#39;&#39;)
return IntVar(self.__model, self.GetOrMakeIndexFromConstant(value),
None)
# Linear constraints.
@@ -2943,6 +3011,50 @@ Returns:
model_ct.cumulative.capacity = self.GetOrMakeIndex(capacity)
return ct
# Support for deep copy.
def CopyFrom(self, other_model):
&#34;&#34;&#34;Reset the model, and creates a new one from a CpModelProto instance.&#34;&#34;&#34;
self.__model.CopyFrom(other_model.Proto())
# Rebuild constant map.
self.__constant_map.clear()
for i, var in enumerate(self.__model.variables):
if len(var.domain) == 2 and var.domain[0] == var.domain[1]:
self.__constant_map[var.domain[0]] = i
def GetBoolVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created Boolean variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: out of bound index {index}&#39;)
var = self.__model.variables[index]
if len(var.domain) != 2 or var.domain[0] &lt; 0 or var.domain[1] &gt; 1:
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: index {index} does not reference&#39; +
&#39; a Boolean variable&#39;)
return IntVar(self.__model, index, None)
def GetIntVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created integer variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetIntVarFromProtoIndex: out of bound index {index}&#39;)
return IntVar(self.__model, index, None)
def GetIntervalVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created interval variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.constraints):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: out of bound index {index}&#39;)
ct = self.__model.constraints[index]
if not ct.HasField(&#39;interval&#39;):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: index {index} does not reference an&#39;
+ &#39; interval variable&#39;)
return IntervalVar(self.__model, index, None, None, None, None)
# Helpers.
def __str__(self):
@@ -4358,6 +4470,26 @@ Raises:
self.__model.ClearField(&#39;solution_hint&#39;)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.CopyFrom"><code class="name flex">
<span>def <span class="ident">CopyFrom</span></span>(<span>self, other_model)</span>
</code></dt>
<dd>
<div class="desc"><p>Reset the model, and creates a new one from a CpModelProto instance.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def CopyFrom(self, other_model):
&#34;&#34;&#34;Reset the model, and creates a new one from a CpModelProto instance.&#34;&#34;&#34;
self.__model.CopyFrom(other_model.Proto())
# Rebuild constant map.
self.__constant_map.clear()
for i, var in enumerate(self.__model.variables):
if len(var.domain) == 2 and var.domain[0] == var.domain[1]:
self.__constant_map[var.domain[0]] = i</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.ExportToFile"><code class="name flex">
<span>def <span class="ident">ExportToFile</span></span>(<span>self, file)</span>
</code></dt>
@@ -4372,6 +4504,46 @@ Raises:
return pywrapsat.SatHelper.WriteModelToFile(self.__model, file)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.GetBoolVarFromProtoIndex"><code class="name flex">
<span>def <span class="ident">GetBoolVarFromProtoIndex</span></span>(<span>self, index)</span>
</code></dt>
<dd>
<div class="desc"><p>Returns an already created Boolean variable from its index.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def GetBoolVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created Boolean variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: out of bound index {index}&#39;)
var = self.__model.variables[index]
if len(var.domain) != 2 or var.domain[0] &lt; 0 or var.domain[1] &gt; 1:
raise ValueError(
f&#39;GetBoolVarFromProtoIndex: index {index} does not reference&#39; +
&#39; a Boolean variable&#39;)
return IntVar(self.__model, index, None)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.GetIntVarFromProtoIndex"><code class="name flex">
<span>def <span class="ident">GetIntVarFromProtoIndex</span></span>(<span>self, index)</span>
</code></dt>
<dd>
<div class="desc"><p>Returns an already created integer variable from its index.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def GetIntVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created integer variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.variables):
raise ValueError(
f&#39;GetIntVarFromProtoIndex: out of bound index {index}&#39;)
return IntVar(self.__model, index, None)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.GetIntervalIndex"><code class="name flex">
<span>def <span class="ident">GetIntervalIndex</span></span>(<span>self, arg)</span>
</code></dt>
@@ -4387,6 +4559,29 @@ Raises:
return arg.Index()</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.GetIntervalVarFromProtoIndex"><code class="name flex">
<span>def <span class="ident">GetIntervalVarFromProtoIndex</span></span>(<span>self, index)</span>
</code></dt>
<dd>
<div class="desc"><p>Returns an already created interval variable from its index.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def GetIntervalVarFromProtoIndex(self, index):
&#34;&#34;&#34;Returns an already created interval variable from its index.&#34;&#34;&#34;
if index &lt; 0 or index &gt;= len(self.__model.constraints):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: out of bound index {index}&#39;)
ct = self.__model.constraints[index]
if not ct.HasField(&#39;interval&#39;):
raise ValueError(
f&#39;GetIntervalVarFromProtoIndex: index {index} does not reference an&#39;
+ &#39; interval variable&#39;)
return IntervalVar(self.__model, index, None, None, None, None)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.GetOrMakeBooleanIndex"><code class="name flex">
<span>def <span class="ident">GetOrMakeBooleanIndex</span></span>(<span>self, arg)</span>
</code></dt>
@@ -4548,7 +4743,8 @@ Raises:
</summary>
<pre><code class="python">def NewConstant(self, value):
&#34;&#34;&#34;Declares a constant integer.&#34;&#34;&#34;
return IntVar(self.__model, Domain(value, value), &#39;&#39;)</code></pre>
return IntVar(self.__model, self.GetOrMakeIndexFromConstant(value),
None)</code></pre>
</details>
</dd>
<dt id="cp_model.CpModel.NewIntVar"><code class="name flex">
@@ -5511,11 +5707,22 @@ model is feasible, or optimal if you provided an objective function.</p>
def __init__(self, model, domain, name):
&#34;&#34;&#34;See CpModel.NewIntVar below.&#34;&#34;&#34;
self.__model = model
self.__index = len(model.variables)
self.__var = model.variables.add()
self.__var.domain.extend(domain.FlattenedIntervals())
self.__var.name = name
self.__negation = None
# Python do not support multiple __init__ methods.
# This method is only called from the CpModel class.
# We hack the parameter to support the two cases:
# case 1:
# model is a CpModelProto, domain is a Domain, and name is a string.
# case 2:
# model is a CpModelProto, domain is an index (int), and name is None.
if isinstance(domain, numbers.Integral) and name is None:
self.__index = domain
self.__var = model.variables[domain]
else:
self.__index = len(model.variables)
self.__var = model.variables.add()
self.__var.domain.extend(domain.FlattenedIntervals())
self.__var.name = name
def Index(self):
&#34;&#34;&#34;Returns the index of the variable in the model.&#34;&#34;&#34;
@@ -5689,15 +5896,28 @@ intervals into the schedule.</p></div>
def __init__(self, model, start_index, size_index, end_index,
is_present_index, name):
self.__model = model
self.__index = len(model.constraints)
self.__ct = self.__model.constraints.add()
self.__ct.interval.start = start_index
self.__ct.interval.size = size_index
self.__ct.interval.end = end_index
if is_present_index is not None:
self.__ct.enforcement_literal.append(is_present_index)
if name:
self.__ct.name = name
# As with the IntVar::__init__ method, we hack the __init__ method to
# support two use cases:
# case 1: called when creating a new interval variable.
# {start|size|end}_index are indices of integer variables
# is_present_index is either None or the index of a Boolean literal.
# name is a string
# case 2: called when querying an existing interval variable.
# start_index is an int, all parameters after are None.
if (size_index is None and end_index is None and
is_present_index is None and name is None):
self.__index = start_index
self.__ct = model.constraints[start_index]
else:
self.__index = len(model.constraints)
self.__ct = self.__model.constraints.add()
self.__ct.interval.start = start_index
self.__ct.interval.size = size_index
self.__ct.interval.end = end_index
if is_present_index is not None:
self.__ct.enforcement_literal.append(is_present_index)
if name:
self.__ct.name = name
def Index(self):
&#34;&#34;&#34;Returns the index of the interval constraint in the model.&#34;&#34;&#34;
@@ -6399,8 +6619,12 @@ def Term(cls, expression, coefficient):
<li><code><a title="cp_model.CpModel.AssertIsBooleanVariable" href="#cp_model.CpModel.AssertIsBooleanVariable">AssertIsBooleanVariable</a></code></li>
<li><code><a title="cp_model.CpModel.ClearAssumptions" href="#cp_model.CpModel.ClearAssumptions">ClearAssumptions</a></code></li>
<li><code><a title="cp_model.CpModel.ClearHints" href="#cp_model.CpModel.ClearHints">ClearHints</a></code></li>
<li><code><a title="cp_model.CpModel.CopyFrom" href="#cp_model.CpModel.CopyFrom">CopyFrom</a></code></li>
<li><code><a title="cp_model.CpModel.ExportToFile" href="#cp_model.CpModel.ExportToFile">ExportToFile</a></code></li>
<li><code><a title="cp_model.CpModel.GetBoolVarFromProtoIndex" href="#cp_model.CpModel.GetBoolVarFromProtoIndex">GetBoolVarFromProtoIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetIntVarFromProtoIndex" href="#cp_model.CpModel.GetIntVarFromProtoIndex">GetIntVarFromProtoIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetIntervalIndex" href="#cp_model.CpModel.GetIntervalIndex">GetIntervalIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetIntervalVarFromProtoIndex" href="#cp_model.CpModel.GetIntervalVarFromProtoIndex">GetIntervalVarFromProtoIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetOrMakeBooleanIndex" href="#cp_model.CpModel.GetOrMakeBooleanIndex">GetOrMakeBooleanIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetOrMakeIndex" href="#cp_model.CpModel.GetOrMakeIndex">GetOrMakeIndex</a></code></li>
<li><code><a title="cp_model.CpModel.GetOrMakeIndexFromConstant" href="#cp_model.CpModel.GetOrMakeIndexFromConstant">GetOrMakeIndexFromConstant</a></code></li>