choco.integer.var
Class IntTerm

java.lang.Object
  extended by choco.integer.var.IntTerm
All Implemented Interfaces:
IntExp

public class IntTerm
extends java.lang.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
 
Constructor Summary
IntTerm(int capacity)
          Constructor
IntTerm(IntTerm t1)
          Constructor by copy
 
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
 int getSize()
          returns the term capacity
 IntVar getVariable(int index)
          retrieve the i-th variable
 IntVar[] getVariables()
          retrieve the array of variables
 java.lang.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

coefficients

protected final int[] coefficients
The coefficients


variables

protected final IntVar[] variables
The variables


nbVars

protected 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
Method Detail

pretty

public java.lang.String pretty()
Pretty print of the expression


getCoefficients

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

Returns:
the integer coefficients that are involved in the term

getVariables

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

Returns:
the variables that are involved in the term

getCoefficient

public 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 IntVar getVariable(int index)
retrieve the i-th variable

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

setCoefficient

public 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 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 int getSize()
returns the term capacity

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

getConstant

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

Returns:
the value of the integer constant

setConstant

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

Parameters:
constant - the target value