<!doctype html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>docplex.mp.kpi module &#8212; DOcplex.MP: Mathematical Programming Modeling for Python V2.25 documentation</title>
    <link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/javascript" src="_static/bizstyle.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="docplex.mp.linear module" href="docplex.mp.linear.html" />
    <link rel="prev" title="docplex.mp.error_handler module" href="docplex.mp.error_handler.html" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <!--[if lt IE 9]>
    <script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
    <![endif]-->
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="docplex.mp.linear.html" title="docplex.mp.linear module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="docplex.mp.error_handler.html" title="docplex.mp.error_handler module"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">DOcplex.MP: Mathematical Programming Modeling for Python V2.25 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="refman.html" accesskey="U"><strong>docplex.mp</strong> reference manual</a> &#187;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="docplex.mp.error_handler.html"
                        title="previous chapter">docplex.mp.error_handler module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="docplex.mp.linear.html"
                        title="next chapter">docplex.mp.linear module</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="docplex-mp-kpi-module">
<h1>docplex.mp.kpi module<a class="headerlink" href="#docplex-mp-kpi-module" title="Permalink to this headline">&para;</a></h1>
<div class="toctree-wrapper compound">
</div>
<span class="target" id="module-docplex.mp.kpi"></span><dl class="class">
<dt id="docplex.mp.kpi.DecisionKPI">
<em class="property">class </em><code class="descclassname">docplex.mp.kpi.</code><code class="descname">DecisionKPI</code><span class="sig-paren">(</span><em>kpi_op</em>, <em>name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#DecisionKPI"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.DecisionKPI" title="Permalink to this definition">&para;</a></dt>
<dd><p>Bases: <a class="reference internal" href="#docplex.mp.kpi.KPI" title="docplex.mp.kpi.KPI"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.kpi.KPI</span></code></a></p>
<p>Specialized class of Key Performance Indicator, based on expressions.</p>
<p>This subclass is built from a decision variable or a linear expression.
The <a class="reference internal" href="#docplex.mp.kpi.DecisionKPI.compute" title="docplex.mp.kpi.DecisionKPI.compute"><code class="xref py py-func docutils literal notranslate"><span class="pre">compute()</span></code></a> method evaluate the value of the KPI in a solution. This solution can either be passed
to the <cite>compute</cite> method, or using th emodel&#8217;s solution. In the latter case, the model must have been solved
with a solution.</p>
<dl class="method">
<dt id="docplex.mp.kpi.DecisionKPI.compute">
<code class="descname">compute</code><span class="sig-paren">(</span><em>s=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#DecisionKPI.compute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.DecisionKPI.compute" title="Permalink to this definition">&para;</a></dt>
<dd><p>Redefinition of the abstract <cite>compute(s=None)</cite> method.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The value of the decision expression in the solution.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Evaluating a KPI requires a solution object. This solution can either be passed explicitly
in the <cite>s</cite> argument, otherwise the model solution is used. In the latter case, th emodel must
have been solved with a solution, otherwise an exception is raised.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
<li>Evaluating a KPI raises an exception if no <cite>s</cite> solution has been passed</li>
<li>and the underlying model has not been solved with a solution.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="docplex.mp.solution.html#docplex.mp.solution.SolveSolution" title="docplex.mp.solution.SolveSolution"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.solution.SolveSolution</span></code></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="docplex.mp.kpi.DecisionKPI.get_model">
<code class="descname">get_model</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#DecisionKPI.get_model"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.DecisionKPI.get_model" title="Permalink to this definition">&para;</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The model instance on which the KPI is defined.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="docplex.mp.model.html#docplex.mp.model.Model" title="docplex.mp.model.Model"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.model.Model</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="docplex.mp.kpi.DecisionKPI.is_decision_expression">
<code class="descname">is_decision_expression</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#DecisionKPI.is_decision_expression"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.DecisionKPI.is_decision_expression" title="Permalink to this definition">&para;</a></dt>
<dd><p>returns True if the KPI is based on a decision expression or variable.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="docplex.mp.kpi.FunctionalKPI">
<em class="property">class </em><code class="descclassname">docplex.mp.kpi.</code><code class="descname">FunctionalKPI</code><span class="sig-paren">(</span><em>fn</em>, <em>model</em>, <em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#FunctionalKPI"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.FunctionalKPI" title="Permalink to this definition">&para;</a></dt>
<dd><p>Bases: <a class="reference internal" href="#docplex.mp.kpi.KPI" title="docplex.mp.kpi.KPI"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.kpi.KPI</span></code></a></p>
<dl class="method">
<dt id="docplex.mp.kpi.FunctionalKPI.get_model">
<code class="descname">get_model</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#FunctionalKPI.get_model"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.FunctionalKPI.get_model" title="Permalink to this definition">&para;</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The model instance on which the KPI is defined.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="docplex.mp.model.html#docplex.mp.model.Model" title="docplex.mp.model.Model"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.model.Model</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="docplex.mp.kpi.FunctionalKPI.is_decision_expression">
<code class="descname">is_decision_expression</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#FunctionalKPI.is_decision_expression"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.FunctionalKPI.is_decision_expression" title="Permalink to this definition">&para;</a></dt>
<dd><p>returns True if the KPI is based on a decision expression or variable.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="docplex.mp.kpi.KPI">
<em class="property">class </em><code class="descclassname">docplex.mp.kpi.</code><code class="descname">KPI</code><span class="sig-paren">(</span><em>name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#KPI"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.KPI" title="Permalink to this definition">&para;</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.basic._AbstractNamable</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.basic._AbstractValuable</span></code></p>
<p>Base class for key performance indicators (KPIs).</p>
<p>Each KPI has a unique name. A KPI is attached to a model instance and can compute a numerical value,
using the <code class="xref py py-func docutils literal notranslate"><span class="pre">compute()</span></code> method. The <cite>compute</cite> method takes an optional solution argument;
if passed a valid SolveSolution object, this solution is used to evaluate the KPI, else compute()
will attempt to access th emodel&#8217;s solution. If the model has no attached solution, then an exception
is raised by <cite>compute</cite>.</p>
<dl class="method">
<dt id="docplex.mp.kpi.KPI.get_model">
<code class="descname">get_model</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#KPI.get_model"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.KPI.get_model" title="Permalink to this definition">&para;</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The model instance on which the KPI is defined.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="docplex.mp.model.html#docplex.mp.model.Model" title="docplex.mp.model.Model"><code class="xref py py-class docutils literal notranslate"><span class="pre">docplex.mp.model.Model</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="docplex.mp.kpi.KPI.is_decision_expression">
<code class="descname">is_decision_expression</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/docplex/mp/kpi.html#KPI.is_decision_expression"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#docplex.mp.kpi.KPI.is_decision_expression" title="Permalink to this definition">&para;</a></dt>
<dd><p>returns True if the KPI is based on a decision expression or variable.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="docplex.mp.linear.html" title="docplex.mp.linear module"
             >next</a> |</li>
        <li class="right" >
          <a href="docplex.mp.error_handler.html" title="docplex.mp.error_handler module"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">DOcplex.MP: Mathematical Programming Modeling for Python V2.25 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="refman.html" ><strong>docplex.mp</strong> reference manual</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2016-2022, IBM&reg;.
    </div>
  </body>
</html>