docplex.mp.kpi module¶

class
docplex.mp.kpi.
DecisionKPI
(kpi_op, name=None)[source]¶ Bases:
docplex.mp.kpi.KPI
Specialized class of Key Performance Indicator, based on expressions.
This subclass is built from a decision variable or a linear expression. The
compute()
method evaluate the value of the KPI in a solution. This solution can either be passed to the compute method, or using th emodel’s solution. In the latter case, the model must have been solved with a solution.
compute
(s=None)[source]¶ Redefinition of the abstract compute(s=None) method.
Returns: The value of the decision expression in the solution. Return type: float Note
Evaluating a KPI requires a solution object. This solution can either be passed explicitly in the s 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.
Raises:  Evaluating a KPI raises an exception if no s solution has been passed
 and the underlying model has not been solved with a solution.
See also

get_model
()[source]¶ Returns: The model instance on which the KPI is defined. Return type: docplex.mp.model.Model


class
docplex.mp.kpi.
FunctionalKPI
(fn, model, name)[source]¶ Bases:
docplex.mp.kpi.KPI

get_model
()[source]¶ Returns: The model instance on which the KPI is defined. Return type: docplex.mp.model.Model


class
docplex.mp.kpi.
KPI
(name=None)[source]¶ Bases:
docplex.mp.basic._AbstractNamable
,docplex.mp.basic._AbstractValuable
Base class for key performance indicators (KPIs).
Each KPI has a unique name. A KPI is attached to a model instance and can compute a numerical value, using the
compute()
method. The compute 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’s solution. If the model has no attached solution, then an exception is raised by compute.
get_model
()[source]¶ Returns: The model instance on which the KPI is defined. Return type: docplex.mp.model.Model
