Sugar version 1.13 Core API Specification

jp.ac.kobe_u.cs.sugar.csp
Class LinearSum

java.lang.Object
  extended by jp.ac.kobe_u.cs.sugar.csp.LinearSum

public class LinearSum
extends Object

A class for linear expressions. A linear expression represents the following formula:
a0*x0+a1*x1+...+an*xn+b
where ai's and b are integer constants and xi's are integer variables of CSP.

See Also:
CSP, LinearLiteral

Constructor Summary
LinearSum(int b)
           
LinearSum(IntegerVariable v0)
           
LinearSum(int a0, IntegerVariable v0, int b)
           
LinearSum(LinearSum e)
           
 
Method Summary
 void add(LinearSum linearSum)
          Adds the given linear expression.
 void divide(int c)
           
 boolean equals(LinearSum linearSum)
          Returns true when the linear expression is equal to the given linear expression.
 boolean equals(Object obj)
          Returns true when the linear expression is equal to the given object.
 int factor()
           
 void factorize()
           
 Integer getA(IntegerVariable v)
           
 int getB()
           
 SortedMap<IntegerVariable,Integer> getCoef()
           
 IntegerDomain getDomain()
           
 IntegerDomain getDomainExcept(IntegerVariable v)
           
 int getValue()
          Returns the value of the linear expression.
 Set<IntegerVariable> getVariables()
           
 IntegerVariable[] getVariablesByCoef()
           
 int hashCode()
          Returns the hash code of the linear expression.
 boolean isDomainLargerThan(long limit)
           
 boolean isIntegerVariable()
           
 boolean isSimple()
          Returns true when the linear expression is simple.
 void multiply(int c)
          Multiplies the given constant.
 void setA(int a, IntegerVariable v)
           
 int size()
          Returns the size of the linear expression.
 LinearSum[] split()
           
 void subtract(LinearSum linearSum)
          Subtracts the given linear expression.
 Expression toExpression()
           
 String toString()
           
 String toString0()
          Returns the string representation of the linear expression.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearSum

public LinearSum(int b)

LinearSum

public LinearSum(int a0,
                 IntegerVariable v0,
                 int b)

LinearSum

public LinearSum(IntegerVariable v0)

LinearSum

public LinearSum(LinearSum e)
Method Detail

size

public int size()
Returns the size of the linear expression.

Returns:
the size

getB

public int getB()

getCoef

public SortedMap<IntegerVariable,Integer> getCoef()

getVariables

public Set<IntegerVariable> getVariables()

isIntegerVariable

public boolean isIntegerVariable()

isSimple

public boolean isSimple()
Returns true when the linear expression is simple. A linear expression is simple if it has at most one integer variable.

Returns:
true when the linear expression is simple

getA

public Integer getA(IntegerVariable v)

setA

public void setA(int a,
                 IntegerVariable v)

isDomainLargerThan

public boolean isDomainLargerThan(long limit)

add

public void add(LinearSum linearSum)
Adds the given linear expression.

Parameters:
linearSum - the linear expression to be added.

subtract

public void subtract(LinearSum linearSum)
Subtracts the given linear expression.

Parameters:
linearSum - the linear expression to be subtracted.

multiply

public void multiply(int c)
Multiplies the given constant.

Parameters:
c - the constant to be multiplied by

divide

public void divide(int c)

factor

public int factor()

factorize

public void factorize()

getDomain

public IntegerDomain getDomain()
                        throws SugarException
Throws:
SugarException

getDomainExcept

public IntegerDomain getDomainExcept(IntegerVariable v)
                              throws SugarException
Throws:
SugarException

split

public LinearSum[] split()

getVariablesByCoef

public IntegerVariable[] getVariablesByCoef()

toExpression

public Expression toExpression()

getValue

public int getValue()
Returns the value of the linear expression.

Returns:
the value of the linear expression

equals

public boolean equals(LinearSum linearSum)
Returns true when the linear expression is equal to the given linear expression.

Parameters:
linearSum - the linear expression to be compared
Returns:
true when the linear expression is equal to the given linear expression

equals

public boolean equals(Object obj)
Returns true when the linear expression is equal to the given object.

Overrides:
equals in class Object
Parameters:
obj - the object to be compared
Returns:
true when the linear expression is equal to the given object.

hashCode

public int hashCode()
Returns the hash code of the linear expression.

Overrides:
hashCode in class Object
Returns:
the hash code

toString0

public String toString0()
Returns the string representation of the linear expression.

Returns:
the string representation

toString

public String toString()
Overrides:
toString in class Object

Sugar version 1.13 Core API Specification

Sugar: A SAT-based Constraint Solver