choco.cp.solver.variables.integer
Class IntTerm

java.lang.Object
  extended by choco.cp.solver.variables.integer.IntTerm
All Implemented Interfaces:
IntExp

public class IntTerm
extends Object
implements IntExp

Implements linear terms: Sigma_i(a_i*X_i), where a_i are search coefficients, and X_i are search domain variable


Field Summary
protected  int[] coefficients
          The coefficients
protected  int constant
          the integer constant involved in the term
protected  int nbVars
          number of variables involved in the term
protected  IntVar[] variables
          The variables
static IntTerm ZERO
          A constant denoting a null integer term.
 
Constructor Summary
  IntTerm(int capacity)
          Constructor
  IntTerm(int[] lc, IntVar[] lv)
           
  IntTerm(IntTerm t1)
          Constructor by copy
protected IntTerm(IntTerm t1, int nbMore, boolean moreFirst)
           
  IntTerm(IntVar[] lv)
           
 
Method Summary
 int getCoefficient(int index)
          retrieve the i-th coefficient
 int[] getCoefficients()
          retrieve the array of coefficients
 int getConstant()
          returns the integer constant involved in the linear term
 IntDomainVar getIntDVar(int index)
           
 int[] getOppositeCoefficients()
           
 int getSize()
          returns the term capacity
 IntVar getVariable(int index)
          retrieve the i-th variable
 IntVar[] getVariables()
          retrieve the array of variables
 boolean isBinary()
           
 boolean isBinaryMinus()
           
 boolean isBinaryPlus()
           
 boolean isConstant()
           
 boolean isUnary()
           
static IntTerm minus(int coeff, IntVar var, IntTerm t1)
           
static IntTerm minus(IntTerm t1, IntTerm t2)
           
static IntTerm opposite(IntTerm t1)
           
static IntTerm plus(IntTerm t1, int coeff, IntVar var, boolean varFirst)
           
static IntTerm plus(IntTerm t1, IntTerm t2)
           
 String pretty()
          Pretty print of the expression
 void setCoefficient(int index, int coef)
          sets the i-th coefficient
 void setConstant(int constant)
          sets the integer constant involved in the linear term
 void setVariable(int index, IntVar var)
          sets the i-th variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final IntTerm ZERO
A constant denoting a null integer term. This is useful to make the API more robust, for instance with linear expression with null coefficients.


coefficients

protected final int[] coefficients
The coefficients


variables

protected final IntVar[] variables
The variables


nbVars

protected final int nbVars
number of variables involved in the term


constant

protected int constant
the integer constant involved in the term

Constructor Detail

IntTerm

public IntTerm(int capacity)
Constructor

Parameters:
capacity - number of variables that will be involved in the term

IntTerm

public IntTerm(IntTerm t1)
Constructor by copy

Parameters:
t1 - the IntTerm to be copied

IntTerm

public IntTerm(int[] lc,
               IntVar[] lv)

IntTerm

public IntTerm(IntVar[] lv)

IntTerm

protected IntTerm(IntTerm t1,
                  int nbMore,
                  boolean moreFirst)
Method Detail

opposite

public static IntTerm opposite(IntTerm t1)

plus

public static IntTerm plus(IntTerm t1,
                           int coeff,
                           IntVar var,
                           boolean varFirst)

minus

public static IntTerm minus(int coeff,
                            IntVar var,
                            IntTerm t1)

plus

public static IntTerm plus(IntTerm t1,
                           IntTerm t2)

minus

public static IntTerm minus(IntTerm t1,
                            IntTerm t2)

isConstant

public final boolean isConstant()

isUnary

public final boolean isUnary()

isBinary

public final boolean isBinary()

isBinaryMinus

public final boolean isBinaryMinus()

isBinaryPlus

public final boolean isBinaryPlus()

pretty

public String pretty()
Pretty print of the expression


getCoefficients

public final int[] getCoefficients()
retrieve the array of coefficients

Returns:
the integer coefficients that are involved in the term

getVariables

public final IntVar[] getVariables()
retrieve the array of variables

Returns:
the variables that are involved in the term

getCoefficient

public final int getCoefficient(int index)
retrieve the i-th coefficient

Parameters:
index - the index of the variable/coefficient in the expression
Returns:
the coefficient

getVariable

public final IntVar getVariable(int index)
retrieve the i-th variable

Parameters:
index - the index of the variable/coefficient in the expression
Returns:
the coefficient

getIntDVar

public final IntDomainVar getIntDVar(int index)

setCoefficient

public final void setCoefficient(int index,
                                 int coef)
sets the i-th coefficient

Parameters:
index - the index of the variable/coefficient in the expression
coef - the coefficient

setVariable

public final void setVariable(int index,
                              IntVar var)
sets the i-th variable

Parameters:
index - the index of the variable/coefficient in the expression
var - the variable

getSize

public final int getSize()
returns the term capacity

Returns:
the capacity that has been reserved for storing coefficients and varibales

getConstant

public final int getConstant()
returns the integer constant involved in the linear term

Returns:
the value of the integer constant

setConstant

public final void setConstant(int constant)
sets the integer constant involved in the linear term

Parameters:
constant - the target value

getOppositeCoefficients

public final int[] getOppositeCoefficients()


Copyright © 2012. All Rights Reserved.