update doc

This commit is contained in:
Laurent Perron
2019-08-22 13:38:15 +02:00
parent 49e9410a6b
commit 4b9f11ba2a
302 changed files with 24963 additions and 8881 deletions

View File

@@ -3,13 +3,13 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.6.3" />
<meta name="generator" content="pdoc 0.6.2" />
<title>cp_model API documentation</title>
<meta name="description" content="Methods for building and solving CP-SAT models …" />
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase;cursor:pointer}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase;cursor:pointer}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<style type="text/css">
@@ -220,24 +220,29 @@ class LinearExpr(object):
@classmethod
def Sum(cls, expressions):
&#34;&#34;&#34;Create the expression sum(expressions).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions).&#34;&#34;&#34;
return _SumArray(expressions)
@classmethod
def ScalProd(cls, expressions, coefficients):
&#34;&#34;&#34;Create the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
return _ScalProd(expressions, coefficients)
@classmethod
def Term(cls, expression, coefficient):
&#34;&#34;&#34;Creates `expression * coefficient`.&#34;&#34;&#34;
return expression * coefficient
def GetVarValueMap(self):
&#34;&#34;&#34;Scan the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
&#34;&#34;&#34;Scans the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
coeffs = collections.defaultdict(int)
constant = 0
to_process = [(self, 1)]
while to_process: # Flatten to avoid recursion.
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -483,8 +488,8 @@ class _ScalProd(LinearExpr):
def __repr__(self):
return &#39;ScalProd([{}], [{}], {})&#39;.format(
&#39;, &#39;.join(map(repr, self.__expressions)),
&#39;, &#39;.join(map(repr, self.__coefficients)), self.__constant)
&#39;, &#39;.join(map(repr, self.__expressions)), &#39;, &#39;.join(
map(repr, self.__coefficients)), self.__constant)
def Expressions(self):
return self.__expressions
@@ -723,14 +728,14 @@ class IntervalVar(object):
if self.__ct.enforcement_literal:
return &#39;%s(start = %s, size = %s, end = %s, is_present = %s)&#39; % (
self.__ct.name, ShortName(self.__model, interval.start),
ShortName(self.__model,
interval.size), ShortName(self.__model, interval.end),
ShortName(self.__model, interval.size),
ShortName(self.__model, interval.end),
ShortName(self.__model, self.__ct.enforcement_literal[0]))
else:
return &#39;%s(start = %s, size = %s, end = %s)&#39; % (
self.__ct.name, ShortName(self.__model, interval.start),
ShortName(self.__model,
interval.size), ShortName(self.__model, interval.end))
ShortName(self.__model, interval.size),
ShortName(self.__model, interval.end))
def Name(self):
return self.__ct.name
@@ -1612,8 +1617,8 @@ def EvaluateBooleanExpression(literal, solution):
else:
return not solution.solution[-index - 1]
else:
raise TypeError(&#39;Cannot interpret %s as a boolean expression.&#39; %
literal)
raise TypeError(
&#39;Cannot interpret %s as a boolean expression.&#39; % literal)
class CpSolver(object):
@@ -1781,8 +1786,8 @@ class CpSolverSolutionCallback(pywrapsat.SolutionCallback):
index = lit.Index()
return self.SolutionBooleanValue(index)
else:
raise TypeError(&#39;Cannot interpret %s as a boolean expression.&#39; %
lit)
raise TypeError(
&#39;Cannot interpret %s as a boolean expression.&#39; % lit)
def Value(self, expression):
&#34;&#34;&#34;Evaluates an linear expression in the current solution.
@@ -1806,8 +1811,8 @@ class CpSolverSolutionCallback(pywrapsat.SolutionCallback):
while to_process:
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -1819,8 +1824,8 @@ class CpSolverSolutionCallback(pywrapsat.SolutionCallback):
elif isinstance(expr, IntVar):
value += coef * self.SolutionIntegerValue(expr.Index())
elif isinstance(expr, _NotBooleanVariable):
value += coef * (1 -
self.SolutionIntegerValue(expr.Not().Index()))
value += coef * (
1 - self.SolutionIntegerValue(expr.Not().Index()))
return value
@@ -4918,8 +4923,8 @@ and Value() methods.</p>
index = lit.Index()
return self.SolutionBooleanValue(index)
else:
raise TypeError(&#39;Cannot interpret %s as a boolean expression.&#39; %
lit)
raise TypeError(
&#39;Cannot interpret %s as a boolean expression.&#39; % lit)
def Value(self, expression):
&#34;&#34;&#34;Evaluates an linear expression in the current solution.
@@ -4943,8 +4948,8 @@ and Value() methods.</p>
while to_process:
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -4956,8 +4961,8 @@ and Value() methods.</p>
elif isinstance(expr, IntVar):
value += coef * self.SolutionIntegerValue(expr.Index())
elif isinstance(expr, _NotBooleanVariable):
value += coef * (1 -
self.SolutionIntegerValue(expr.Not().Index()))
value += coef * (
1 - self.SolutionIntegerValue(expr.Not().Index()))
return value</code></pre>
</details>
<h3>Ancestors</h3>
@@ -5011,8 +5016,8 @@ Raises:
index = lit.Index()
return self.SolutionBooleanValue(index)
else:
raise TypeError(&#39;Cannot interpret %s as a boolean expression.&#39; %
lit)</code></pre>
raise TypeError(
&#39;Cannot interpret %s as a boolean expression.&#39; % lit)</code></pre>
</details>
</dd>
<dt id="cp_model.CpSolverSolutionCallback.OnSolutionCallback"><code class="name flex">
@@ -5072,8 +5077,8 @@ Raises:
while to_process:
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -5085,8 +5090,8 @@ Raises:
elif isinstance(expr, IntVar):
value += coef * self.SolutionIntegerValue(expr.Index())
elif isinstance(expr, _NotBooleanVariable):
value += coef * (1 -
self.SolutionIntegerValue(expr.Not().Index()))
value += coef * (
1 - self.SolutionIntegerValue(expr.Not().Index()))
return value</code></pre>
</details>
</dd>
@@ -5250,6 +5255,7 @@ Note that this method is nilpotent: `x.Not().Not() == x`.
<li><code><a title="cp_model.LinearExpr.GetVarValueMap" href="#cp_model.LinearExpr.GetVarValueMap">GetVarValueMap</a></code></li>
<li><code><a title="cp_model.LinearExpr.ScalProd" href="#cp_model.LinearExpr.ScalProd">ScalProd</a></code></li>
<li><code><a title="cp_model.LinearExpr.Sum" href="#cp_model.LinearExpr.Sum">Sum</a></code></li>
<li><code><a title="cp_model.LinearExpr.Term" href="#cp_model.LinearExpr.Term">Term</a></code></li>
</ul>
</li>
</ul>
@@ -5319,14 +5325,14 @@ intervals into the schedule.</p></section>
if self.__ct.enforcement_literal:
return &#39;%s(start = %s, size = %s, end = %s, is_present = %s)&#39; % (
self.__ct.name, ShortName(self.__model, interval.start),
ShortName(self.__model,
interval.size), ShortName(self.__model, interval.end),
ShortName(self.__model, interval.size),
ShortName(self.__model, interval.end),
ShortName(self.__model, self.__ct.enforcement_literal[0]))
else:
return &#39;%s(start = %s, size = %s, end = %s)&#39; % (
self.__ct.name, ShortName(self.__model, interval.start),
ShortName(self.__model,
interval.size), ShortName(self.__model, interval.end))
ShortName(self.__model, interval.size),
ShortName(self.__model, interval.end))
def Name(self):
return self.__ct.name</code></pre>
@@ -5423,24 +5429,29 @@ model.Add(cp_model.LinearExpr.ScalProd(expressions, coefficients) &gt;= 0)
@classmethod
def Sum(cls, expressions):
&#34;&#34;&#34;Create the expression sum(expressions).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions).&#34;&#34;&#34;
return _SumArray(expressions)
@classmethod
def ScalProd(cls, expressions, coefficients):
&#34;&#34;&#34;Create the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
return _ScalProd(expressions, coefficients)
@classmethod
def Term(cls, expression, coefficient):
&#34;&#34;&#34;Creates `expression * coefficient`.&#34;&#34;&#34;
return expression * coefficient
def GetVarValueMap(self):
&#34;&#34;&#34;Scan the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
&#34;&#34;&#34;Scans the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
coeffs = collections.defaultdict(int)
constant = 0
to_process = [(self, 1)]
while to_process: # Flatten to avoid recursion.
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -5588,12 +5599,12 @@ model.Add(cp_model.LinearExpr.ScalProd(expressions, coefficients) &gt;= 0)
<span>def <span class="ident">ScalProd</span></span>(<span>expressions, coefficients)</span>
</code></dt>
<dd>
<section class="desc"><p>Create the expression sum(expressions[i] * coefficients[i]).</p></section>
<section class="desc"><p>Creates the expression sum(expressions[i] * coefficients[i]).</p></section>
<details class="source">
<summary>Source code</summary>
<pre><code class="python">@classmethod
def ScalProd(cls, expressions, coefficients):
&#34;&#34;&#34;Create the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions[i] * coefficients[i]).&#34;&#34;&#34;
return _ScalProd(expressions, coefficients)</code></pre>
</details>
</dd>
@@ -5601,15 +5612,28 @@ def ScalProd(cls, expressions, coefficients):
<span>def <span class="ident">Sum</span></span>(<span>expressions)</span>
</code></dt>
<dd>
<section class="desc"><p>Create the expression sum(expressions).</p></section>
<section class="desc"><p>Creates the expression sum(expressions).</p></section>
<details class="source">
<summary>Source code</summary>
<pre><code class="python">@classmethod
def Sum(cls, expressions):
&#34;&#34;&#34;Create the expression sum(expressions).&#34;&#34;&#34;
&#34;&#34;&#34;Creates the expression sum(expressions).&#34;&#34;&#34;
return _SumArray(expressions)</code></pre>
</details>
</dd>
<dt id="cp_model.LinearExpr.Term"><code class="name flex">
<span>def <span class="ident">Term</span></span>(<span>expression, coefficient)</span>
</code></dt>
<dd>
<section class="desc"><p>Creates <code>expression * coefficient</code>.</p></section>
<details class="source">
<summary>Source code</summary>
<pre><code class="python">@classmethod
def Term(cls, expression, coefficient):
&#34;&#34;&#34;Creates `expression * coefficient`.&#34;&#34;&#34;
return expression * coefficient</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
@@ -5617,19 +5641,19 @@ def Sum(cls, expressions):
<span>def <span class="ident">GetVarValueMap</span></span>(<span>self)</span>
</code></dt>
<dd>
<section class="desc"><p>Scan the expression, and return a list of (var_coef_map, constant).</p></section>
<section class="desc"><p>Scans the expression, and return a list of (var_coef_map, constant).</p></section>
<details class="source">
<summary>Source code</summary>
<pre><code class="python">def GetVarValueMap(self):
&#34;&#34;&#34;Scan the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
&#34;&#34;&#34;Scans the expression, and return a list of (var_coef_map, constant).&#34;&#34;&#34;
coeffs = collections.defaultdict(int)
constant = 0
to_process = [(self, 1)]
while to_process: # Flatten to avoid recursion.
expr, coef = to_process.pop()
if isinstance(expr, _ProductCst):
to_process.append(
(expr.Expression(), coef * expr.Coefficient()))
to_process.append((expr.Expression(),
coef * expr.Coefficient()))
elif isinstance(expr, _SumArray):
for e in expr.Expressions():
to_process.append((e, coef))
@@ -6022,6 +6046,7 @@ def Sum(cls, expressions):
<li><code><a title="cp_model.LinearExpr.GetVarValueMap" href="#cp_model.LinearExpr.GetVarValueMap">GetVarValueMap</a></code></li>
<li><code><a title="cp_model.LinearExpr.ScalProd" href="#cp_model.LinearExpr.ScalProd">ScalProd</a></code></li>
<li><code><a title="cp_model.LinearExpr.Sum" href="#cp_model.LinearExpr.Sum">Sum</a></code></li>
<li><code><a title="cp_model.LinearExpr.Term" href="#cp_model.LinearExpr.Term">Term</a></code></li>
</ul>
</li>
<li>
@@ -6052,7 +6077,7 @@ def Sum(cls, expressions):
</main>
<footer id="footer">
<p><span style="color:#ddd">&#21328;</span></p>
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.6.3</a>.</p>
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.6.2</a>.</p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>