docplex.mp.basic module

class docplex.mp.basic.Expr[source]

Bases: ModelObject, Operand, _AbstractValuable

Parent class for all expression classes.

contains_var(dvar)[source]

Checks whether a variable is present in the expression.

Param:

dvar (docplex.mp.dvar.Var): A decision variable.

Returns:

True if the variable is present in the expression, else False.

Return type:

Boolean

is_quad_expr()[source]

Returns True if the expression is quadratic

number_of_variables()[source]
Returns:

The number of variables in the expression.

Return type:

integer

class docplex.mp.basic.IndexableObject(model, name=None, index=-2)[source]

Bases: ModelingObjectBase

is_generated()[source]

Checks whether this object has been generated by another modeling object.

If so, the origin object is stored in the _origin attribute.

Returns:

True if the objects has been generated.

property model

This property returns the docplex.mp.model.Model to which the object belongs.

class docplex.mp.basic.ModelObject(model)[source]

Bases: _AbstractModelObject

class docplex.mp.basic.ModelingObjectBase[source]

Bases: ModelObject, _AbstractNamable

Parent class for all modeling objects (variables and constraints).

This class is not intended to be instantiated directly.

has_name()[source]

Checks whether the object has a name.

Returns:

True if the object has a name.

has_user_name()[source]

Checks whether the object has a valid name given by the user.

Returns:

True if the object has a valid name given by the user.

property model

This property returns the docplex.mp.model.Model to which the object belongs.

property name

This property is used to get or set the name of the modeling object.