Class KLinearRelaxation


  • public class KLinearRelaxation
    extends java.lang.Object
    This class represents a linear relaxation of a domain.

    A linear relaxation consists of the following.
    - A set of involved variables
    - A type for each variable (either continuous or global). The type of a variable in
    a relaxation need not be the same as its "intrinsic" type. For instance, a KIntVar
    (which is a global variable) can be set continuous in a relaxation. On the contrary,
    making a KFloatVar global in a relaxation is forbidden since it would not make much sense
    to "relax" the domain of a variable by restricting it.
    - A set of linear relations (KLinRel) representing linear (in)equalities with these variables

    Since:
    2016.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean swigCMemOwn  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(KLinearRelaxation relax)
      Merge two linear relaxations.

      void add​(KLinRel klr)
      Add a KLinRel (linear relation).

      This method adds a linear (in)equality (and all variables involved) to the relaxation object.
      void addSOS​(KLinRel sos)
      Add a SOS of type 1 or 2.

      SOS are stored as KLinRel, the constant of the KLinRel being either 1 or 2 depending on the type of the SOS.

      A SOS1 (special ordered set of type 1) is a set of variables with the constraint that
      at most one variable in the set may be non-zero.
      static KLinearRelaxation bigM​(KLinearRelaxation arg0, KLinearRelaxation arg1)
      Big-M method.

      Get a new linear relaxation which is the big-M disjunction of the two arguments.
      Note: deleting it is user's responsibility.
      static KLinearRelaxation bigM​(com.artelys.kalis.SWIGTYPE_p_p_KLinearRelaxation arg0, int numberOfRelax)
      Big-M method with any number of arguments.

      Get a new linear relaxation which is the big-M disjunction of the arguments.
      Note: deleting it is user's responsibility.
      static KLinearRelaxation convexHull​(KLinearRelaxation arg0, KLinearRelaxation arg1)
      Convex hull method.

      Get a new linear relaxation which is the convex hull of the two arguments.
      Note: deleting it is user's responsibility.
      static KLinearRelaxation convexHull​(com.artelys.kalis.SWIGTYPE_p_p_KLinearRelaxation arg0, int numberOfRelax)
      Convex hull method, with any number of arguments.

      Get a new linear relaxation which is the convex hull of the arguments.
      Note: deleting it is user's responsibility.
      void delete()  
      protected void finalize()  
      protected static long getCPtr​(KLinearRelaxation obj)  
      com.artelys.kalis.SWIGTYPE_p_KLinearRelaxation_I getInternalPtr()  
      long getRank​(KAuxVar var)
      Get the rank of a KAuxVar.

      Note that method close() must be called first, otherwise ranks are undefined.
      long getRank​(KNumVar var)
      Get the rank of a KNumVar variable.

      Note that method close() must be called first, otherwise ranks are undefined.
      void insertVar​(KIntVar var)
      Insert a KIntVar variable.

      Inserting a variable "manually" to the list of variables involved in the relaxation is not necessary
      in most cases, since variables are added automatically when a constraint in which they are involved
      is added to the Relaxation.

      Note: if the KIntVar has indicators, they are automatically inserted in the relaxation as well.
      boolean isExact()
      Check whether the relaxation is exact or not.

      A relaxation is said to be "exact" when it represents exactly the underlying set of constraints
      (constraints that were relaxed), so it is not an intrinsic property.
      void isExact​(boolean arg0)
      Setter for isRelaxationExact.

      Same remark as for the previous getter.
      void print()
      Print method.

      This methods prints all variables, KLinRel and SOS involved in the relaxation to the default output
      void print​(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)  
      void printStat()
      Print statistics about the relaxation.
      Print only the number of variables (with their type), KLinRel and SOS involved.
      void printStats​(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)  
      void printViolated​(KHybridSolution arg0)
      Print KLinRel that are violated by an hybrid solution (if any).

      Useful to check whether a solution contained in a KHybridSolution object is valid.
      void setGlobal​(KAuxVar var, boolean global)  
      void setGlobal​(KIntVar var, boolean global)
      set or unset a KIntVar global
      void setName​(java.lang.String arg0)
      set object name
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • swigCMemOwn

        protected transient boolean swigCMemOwn
    • Constructor Detail

      • KLinearRelaxation

        protected KLinearRelaxation​(long cPtr,
                                    boolean cMemoryOwn)
      • KLinearRelaxation

        public KLinearRelaxation​(com.artelys.kalis.SWIGTYPE_p_std__vectorT_KLinearRelaxation_p_t instances)
        Constructor with a list of instances.
      • KLinearRelaxation

        public KLinearRelaxation​(KProblem problem)
        Constructor with a problem.
      • KLinearRelaxation

        public KLinearRelaxation​(KProblem problem,
                                 java.lang.String name)
        Constructor with a problem and a name.
      • KLinearRelaxation

        public KLinearRelaxation​(KLinearRelaxation arg0)
        Copy constructor.
      • KLinearRelaxation

        public KLinearRelaxation​(com.artelys.kalis.SWIGTYPE_p_KLinearRelaxation_I arg0)
    • Method Detail

      • finalize

        protected void finalize()
        Overrides:
        finalize in class java.lang.Object
      • delete

        public void delete()
      • add

        public void add​(KLinRel klr)
        Add a KLinRel (linear relation).

        This method adds a linear (in)equality (and all variables involved) to the relaxation object.
      • add

        public void add​(KLinearRelaxation relax)
        Merge two linear relaxations.

        Parameters:
        relax - the linear relaxation to add to the current object
      • addSOS

        public void addSOS​(KLinRel sos)
        Add a SOS of type 1 or 2.

        SOS are stored as KLinRel, the constant of the KLinRel being either 1 or 2 depending on the type of the SOS.

        A SOS1 (special ordered set of type 1) is a set of variables with the constraint that
        at most one variable in the set may be non-zero. Note that the comparator and the coefficients
        of the KLinRel plays no role.

        A SOS2 (special ordered set of type 2) is a set of variables with the constraint that
        at most two variables in the set may be non-zero, and if there are two non-zeros, they must be adjacent.
        Adjacency is defined by the weights (coefficients in the KLinRel), which must be unique. Note that the
        comparator of the KLinRel plays no role.

        Parameters:
        sos - the sos to add
      • insertVar

        public void insertVar​(KIntVar var)
        Insert a KIntVar variable.

        Inserting a variable "manually" to the list of variables involved in the relaxation is not necessary
        in most cases, since variables are added automatically when a constraint in which they are involved
        is added to the Relaxation.

        Note: if the KIntVar has indicators, they are automatically inserted in the relaxation as well.
        Parameters:
        var - variable to add (with its indicators, if any)
      • getRank

        public long getRank​(KNumVar var)
        Get the rank of a KNumVar variable.

        Note that method close() must be called first, otherwise ranks are undefined.
        Parameters:
        var - variable to rank
      • getRank

        public long getRank​(KAuxVar var)
        Get the rank of a KAuxVar.

        Note that method close() must be called first, otherwise ranks are undefined.
        Parameters:
        var - variable to rank
      • isExact

        public boolean isExact()
        Check whether the relaxation is exact or not.

        A relaxation is said to be "exact" when it represents exactly the underlying set of constraints
        (constraints that were relaxed), so it is not an intrinsic property. This flag is meant to inform the
        user, not the solver ! (it is not used by the solver in any way).
      • isExact

        public void isExact​(boolean arg0)
        Setter for isRelaxationExact.

        Same remark as for the previous getter.
      • setName

        public void setName​(java.lang.String arg0)
        set object name
      • print

        public void print()
        Print method.

        This methods prints all variables, KLinRel and SOS involved in the relaxation to the default output
      • print

        public void print​(com.artelys.kalis.SWIGTYPE_p_void ctx,
                          com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
      • printStats

        public void printStats​(com.artelys.kalis.SWIGTYPE_p_void ctx,
                               com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
      • setGlobal

        public void setGlobal​(KIntVar var,
                              boolean global)
        set or unset a KIntVar global
      • setGlobal

        public void setGlobal​(KAuxVar var,
                              boolean global)
      • printStat

        public void printStat()
        Print statistics about the relaxation.
        Print only the number of variables (with their type), KLinRel and SOS involved.
      • convexHull

        public static KLinearRelaxation convexHull​(com.artelys.kalis.SWIGTYPE_p_p_KLinearRelaxation arg0,
                                                   int numberOfRelax)
        Convex hull method, with any number of arguments.

        Get a new linear relaxation which is the convex hull of the arguments.
        Note: deleting it is user's responsibility.
      • bigM

        public static KLinearRelaxation bigM​(com.artelys.kalis.SWIGTYPE_p_p_KLinearRelaxation arg0,
                                             int numberOfRelax)
        Big-M method with any number of arguments.

        Get a new linear relaxation which is the big-M disjunction of the arguments.
        Note: deleting it is user's responsibility.
      • getInternalPtr

        public com.artelys.kalis.SWIGTYPE_p_KLinearRelaxation_I getInternalPtr()
      • printViolated

        public void printViolated​(KHybridSolution arg0)
        Print KLinRel that are violated by an hybrid solution (if any).

        Useful to check whether a solution contained in a KHybridSolution object is valid.