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 returns the solution value after a successful solve.

compute(s=None)[source]

Redefinition of the abstract compute() method.

Returns:The value of the decision expression at the solution.
Return type:float
Raises:Evaluating this KPI raises an exception if the underlying model has not been solved successfully.
class docplex.mp.kpi.KPI[source]

Bases: object

Abstract 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.

Some KPIs require a valid solution of the model, while others do not. Use requires_solution() to check whether a given KPI requires a solution.

get_model()[source]
Returns:The model instance on which the KPI is defined.
Return type:docplex.mp.model.Model
get_name()[source]
Returns:The published name of the KPI, a non-empty, unique string.
Return type:string
requires_solution()[source]

KPIs based on decision expressions or variables require a successful solution to be computed.

Returns:True if the KPI requires a valid solution.
Return type:Boolean