Package cplex :: Package _internal :: Module _subinterfaces :: Class ConflictInterface
 

Class ConflictInterface


Methods for identifying conflicts among constraints.
Instance Methods
 
__init__(self, cplex)
Creates a new ConflictInterface.
 
all_constraints(self)
Returns an object instructing the conflict refiner to include all constraints.
 
upper_bound_constraints(self, *args)
Returns an object instructing the conflict refiner to include all upper bounds.
 
lower_bound_constraints(self, *args)
Returns an object instructing the conflict refiner to include all lower bounds.
 
linear_constraints(self, *args)
Returns an object instructing the conflict refiner to include all linear constraints.
 
quadratic_constraints(self, *args)
Returns an object instructing the conflict refiner to include all quadratic constraints.
 
indicator_constraints(self, *args)
Returns an object instructing the conflict refiner to include all indicator constraints.
 
pwl_constraints(self, *args)
Returns an object instructing the conflict refiner to include all PWL constraints.
 
SOS_constraints(self, *args)
Returns an object instructing the conflict refiner to include all SOS constraints.
 
refine_MIP_start(self, MIP_start, *args)
Identifies a minimal conflict among a set of constraints for a given MIP start.
 
refine(self, *args)
Identifies a minimal conflict among a set of constraints.
 
get(self, *args)
Returns the status of a set of groups of constraints.
 
get_num_groups(self)
Returns the number of constraint groups used in the last call to refine() or refine_MIP_start().
 
get_groups(self, *args)
Returns the groups of constraints used in the last call to refine() or refine_MIP_start().
 
write(self, filename)
Writes the conflict to a file.

Inherited from _baseinterface.BaseInterface: get_indices

Class Variables
  group_status = ConflictStatus()
See ConflictStatus()
  constraint_type = ConflictConstraintType()
See ConflictConstraintType()
Method Details

__init__(self, cplex)
(Constructor)

 

Creates a new ConflictInterface.

The conflict interface is exposed by the top-level Cplex class as Cplex.conflict. This constructor is not meant to be used externally.

Overrides: _baseinterface.BaseInterface.__init__

all_constraints(self)

 

Returns an object instructing the conflict refiner to include all constraints.

Calling Cplex.conflict.refine(Cplex.conflict.all_constraints()) or Cplex.conflict.refine_MIP_start(Cplex.conflict.all_constraints()) will result in every constraint being included in the search for conflicts with equal preference.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.all_constraints()

upper_bound_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all upper bounds.

If called with no arguments, every upper bound is assigned weight 1.0.

If called with one or more arguments, every upper bound is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of upper bounds to be included. If one variable index or name is specified, it is the only upper bound that will be included. If two variable indices or names are specified, then upper bounds of all variables between the first and the second, inclusive, will be included. If a sequence of variable names or indices is passed in, all of their upper bounds will be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.upper_bound_constraints()

lower_bound_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all lower bounds.

If called with no arguments, every lower bound is assigned weight 1.0.

If called with one or more arguments, every lower bound is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of lower bounds to be included. If one variable index or name is specified, it is the only lower bound that will be included. If two variable indices or names are specified, then lower bounds of all variables between the first and the second, inclusive, will be included. If a sequence of variable names or indices is passed in, all of their lower bounds will be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.lower_bound_constraints()

linear_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all linear constraints.

If called with no arguments, every linear constraint is assigned weight 1.0.

If called with one or more arguments, every linear constraint is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of linear constraints to be included. If one linear constraint index or name is specified, it is the only linear constraint that will be included. If two linear constraint indices or names are specified, then all linear constraints between the first and the second, inclusive, will be included. If a sequence of linear constraint names or indices is passed in, they will all be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.linear_constraints()

quadratic_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all quadratic constraints.

If called with no arguments, every quadratic constraint is assigned weight 1.0.

If called with one or more arguments, every quadratic constraint is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of quadratic constraints to be included. If one quadratic constraint index or name is specified, it is the only quadratic constraint that will be included. If two quadratic constraint indices or names are specified, then all quadratic constraints between the first and the second, inclusive, will be included. If a sequence of quadratic constraint names or indices is passed in, they will all be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.quadratic_constraints()

indicator_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all indicator constraints.

If called with no arguments, every indicator constraint is assigned weight 1.0.

If called with one or more arguments, every indicator constraint is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of indicator constraints to be included. If one indicator constraint index or name is specified, it is the only indicator constraint that will be included. If two indicator constraint indices or names are specified, the all indicator constraints between the first and the second, inclusive, will be included. If a sequence of indicator constraint names or indices is passed in, they will all be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.indicator_constraints()

pwl_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all PWL constraints.

If called with no arguments, every PWL constraint is assigned weight 1.0.

If called with one or more arguments, every PWL constraint is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of PWL constraints to be included. If one PWL constraint index or name is specified, it is the only PWL constraint that will be included. If two PWL constraint indices or names are specified, then all PWL constraints between the first and the second, inclusive, will be included. If a sequence of PWL constraint names or indices is passed in, they will all be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.pwl_constraints()

SOS_constraints(self, *args)

 

Returns an object instructing the conflict refiner to include all SOS constraints.

If called with no arguments, every SOS constraint is assigned weight 1.0.

If called with one or more arguments, every SOS constraint is assigned a weight equal to the float passed in as the first argument.

If additional arguments are specified, they determine a subset of SOS constraints to be included. If one SOS constraint index or name is specified, it is the only SOS constraint that will be included. If two SOS constraint indices or names are specified, then all SOS constraints between the first and the second, inclusive, will be included. If a sequence of SOS constraint names or indices is passed in, they will all be included.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> group = c.conflict.SOS_constraints()

refine_MIP_start(self, MIP_start, *args)

 

Identifies a minimal conflict among a set of constraints for a given MIP start.

This method can take arbitrarily many arguments. The first argument must be either a name or index of a MIP start. Additional arguments are optional and can be the object returned by all_constraints() or any combination of constraint groups and objects returned by upper_bound_constraints(), lower_bound_constraints(), linear_constraints(), quadratic_constraints(), indicator_constraints(), pwl_constraints(), or SOS_constraints() may be used to specify the constraints to consider. If no additional arguments are specified, then constraint groups are created automatically as in the CPLEX interactive.

Constraint groups are sequences of length two, the first entry of which is the preference for the group (a float), the second of which is a sequence of pairs (type, id), where type is an attribute of conflict.constraint_type and id is either an index or a valid name for the type.

See CPXrefinemipstartconflictext and in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> indices = c.variables.add([1], [0], [0], c.variables.type.binary)
>>> indices = c.variables.add([2], [0], [0], c.variables.type.binary)
>>> c.solve()
>>> indices = c.linear_constraints.add(
...     lin_expr=[[[0, 1], [1.0, 1.0]]], senses="E", rhs=[2.0])
>>> c.conflict.refine_MIP_start(0, c.conflict.all_constraints())
>>> c.conflict.get()
[-1, -1, -1, -1, 3]
>>> c.conflict.group_status[3], c.conflict.group_status[-1]
('member', 'excluded')
>>> c.conflict.get_groups(0, 3)
[(1.0, ((2, 0),)), (1.0, ((2, 1),)), (1.0, ((1, 0),)), (1.0, ((1, 1),))]

refine(self, *args)

 

Identifies a minimal conflict among a set of constraints.

This method can take arbitrarily many arguments. Either the object returned by all_constraints() or any combination of constraint groups and objects returned by upper_bound_constraints(), lower_bound_constraints(), linear_constraints(), quadratic_constraints(), indicator_constraints(), pwl_constraints(), or SOS_constraints() may be used to specify the constraints to consider. Alternatively, if no arguments are specified, then constraint groups are created automatically as in the CPLEX interactive.

Constraint groups are sequences of length two, the first entry of which is the preference for the group (a float), the second of which is a sequence of pairs (type, id), where type is an attribute of conflict.constraint_type and id is either an index or a valid name for the type.

See CPXrefineconflictext in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> c.read("infeasible.lp")
>>> c.conflict.refine(c.conflict.linear_constraints(),
...                   c.conflict.lower_bound_constraints())
>>> c.conflict.get()
[3, -1, 3, -1, -1, -1]
>>> c.conflict.group_status[3], c.conflict.group_status[-1]
('member', 'excluded')
>>> c.conflict.get_groups([0, 2])
[(1.0, ((3, 0),)), (1.0, ((1, 0),))]

get(self, *args)

 

Returns the status of a set of groups of constraints.

Can be called by four forms.

If called with no arguments, returns a list containing the status of all constraint groups.

If called with one integer argument, returns the status of that constraint group.

If called with two integer arguments, returns the status of all constraint groups between the first and second argument, inclusive.

If called with a sequence of integers as its argument, returns the status of all constraint groups in the sequence.

The status codes are attributes of Cplex.conflict.group_status.

See CPXgetconflictext in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> c.read("infeasible.lp")
>>> c.conflict.refine(c.conflict.all_constraints())
>>> confstatus = c.conflict.get()

get_num_groups(self)

 

Returns the number of constraint groups used in the last call to refine() or refine_MIP_start().

See CPXgetconflictnumgroups in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> c.read("infeasible.lp")
>>> c.conflict.refine(c.conflict.all_constraints())
>>> c.conflict.get_num_groups()
10

get_groups(self, *args)

 

Returns the groups of constraints used in the last call to refine() or refine_MIP_start().

Can be called by four forms.

If called with no arguments, returns a list containing all constraint groups.

If called with one integer argument, returns that constraint group.

If called with two integer arguments, returns all constraint groups between the first and second argument, inclusive.

If called with a sequence of integers as its argument, returns all constraint groups in the sequence.

Constraint groups are tuples of length two, the first entry of which is the preference for the group (a float), the second of which is a tuple of pairs (type, id), where type is an attribute of conflict.constraint_type and id is either an index or a valid name for the type.

See CPXgetconflictgroups in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> c.read("infeasible.lp")
>>> c.conflict.refine(c.conflict.all_constraints())
>>> groups = c.conflict.get_groups()

write(self, filename)

 

Writes the conflict to a file.

See CPXclpwrite in the Callable Library Reference Manual.

Example usage:

>>> import cplex
>>> c = cplex.Cplex()
>>> out = c.set_results_stream(None)
>>> c.read("infeasible.lp")
>>> c.conflict.refine(c.conflict.all_constraints())
>>> c.conflict.write("conflict.clp")