Search code examples
pythongetconflictcplex

What does it mean the value 5 as the return of get in conflict of cplex?


I am using cplex.conflict for a problem and when i use cplex.conflict.refine and then ask for the cplex.conflict.get it gives the value 5 for some of the constraints (an infeasible example). Does anyone knows what it means? Here is an example in python:

> python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cplex
>>> c = cplex.Cplex()
>>> c.variables.add(names = ["x0"])
>>> c.linear_constraints.add(lin_expr = [[[0], [-1.0]], [[0], [1.0]]], senses = "LL", rhs = [-10,9]) 
>>> c.conflict.refine(c.conflict.linear_constraints())
>>> c.conflict.get()
[5, 5]
>>> 

The api only refers to returned values of -1, 0 or 3.


Solution

  • c.conflict.get() may return conflict.constraint_type as well. In your case, the two constraints are members of the conflict and cplex returns types of the constraints:

    >>> c.conflict.group_status[5]
    None
    >>> c.conflict.constraint_type[5]
    SOS
    

    i.e., your constraints are of SOS-type which is strange as SOS constraints are for integer variables (binary). If you add a redundant constraint, e.g.

    >>> c.linear_constraints.add(lin_expr = [[[0], [-1.0]], [[0], [1.0]], \
    [[0], [1.0]]], senses = "LLL", rhs = [-10,9,10]) 
    >>> c.conflict.refine(c.conflict.linear_constraints()) 
    [5, 5, -1]
    

    meaning the last one is excluded as not being a member of the conflict. I would recommend you to use c.conflict.get_groups() for more information.

    Edit:

    If you specify variables' types when defining everything works fine:

    >>> c.variables.add(names = ["x0"], obj=[1.0], types=[c.variables.type.continuous])
    ...etc...
    >>> c.conflict.refine(c.conflict.linear_constraints()) 
    Refine conflict on 3 members...
    
    Iteration  Max Members  Min Members
         1            2            0
         2            2            1
         3            2            2
    
    [3, 3, -1]