Class KLinTerm


  • public class KLinTerm
    extends KTerm
    This class represent a linear term of the form Sum(coeffs[i].lvars[i]) + cst

    Example :
    
    KProblem p(...);
    KIntVarArray X(...);
    
    KLinTerm linTerm;
    
    linTerm = 3 * X[0];
    linTerm = linTerm + 5;
    linTerm = linTerm + 2 * X[1];
    linTerm = linTerm - 3 * X[2] + 5 * X[3];
    linTerm = linTerm - 7;
    // these lines are equivalent to :
    // linTerm = 3 * X[0] + 2 * X[1] - 3 * X[2] + 5 * X[3] - 2
    
    // posting the constraint  3 * X[0] + 2 * X[1] - 3 * X[2] + 5 * X[3] - 2 >= 5
    // will be converted into  -3 * X[0] - 2 * X[1] + 3 * X[2] - 5 * X[3] + 7 <= 0
    p.post(linTerm >= 5);
    

    Since:
    2016.1
    See Also:
    KLinComb
    • Constructor Detail

      • KLinTerm

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

        public KLinTerm()
        Default constructor
      • KLinTerm

        public KLinTerm​(KNumVarArray lvars,
                        double cste)
        Each KIntVar has a coefficient 1
      • KLinTerm

        public KLinTerm​(KLinTerm linTermToCopy)
        Copy constructor
      • KLinTerm

        public KLinTerm​(KLinTerm linTermToCopy,
                        int pb)
        Copy constructor for a specific instance
      • KLinTerm

        public KLinTerm​(KNumVarArray lvars,
                        KIntArray coeffs,
                        double cste)
        Constructor with a KIntArray (integers are casted to double)
      • KLinTerm

        public KLinTerm​(KIntVarArray lvars,
                        KDoubleArray coeffs,
                        double cste)
        Constructor with a KIntVarArray and double array
      • KLinTerm

        public KLinTerm​(KIntVarArray lvars,
                        KIntArray coeffs,
                        double cste)
        Constructor with a KIntVars KIntArray (integers are casted to double)
      • KLinTerm

        public KLinTerm​(KNumVar intVar)
        Cast a KIntVar into a KLinTerm
      • KLinTerm

        public KLinTerm​(KUnTerm unTerm)
        Cast a KNumUnTerm into a KLinTerm
      • KLinTerm

        public KLinTerm​(KBinTerm binTerm)
        Cast a KNumBinTerm into a KLinTerm
    • Method Detail

      • getCPtr

        protected static long getCPtr​(KLinTerm obj)
      • finalize

        protected void finalize()
        Overrides:
        finalize in class KTerm
      • delete

        public void delete()
        Overrides:
        delete in class KTerm
      • print

        public void print​(com.artelys.kalis.SWIGTYPE_p_std__ostream fout)
        pretty print method
      • print

        public void print()
        Description copied from class: KTerm
        pretty print method
        Overrides:
        print in class KTerm
      • 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)
        Overrides:
        print in class KTerm
      • add

        public void add​(KNumVar var,
                        double cste)