SugarTrace version 1.0.1 Core API Specification

sugartracer.decoder
Class Variable

java.lang.Object
  extended by sugartracer.decoder.Variable

public class Variable
extends Object

This is a class for CSP integer variables and boolean variables.


Method Summary
 boolean contains(int code)
          Returns true when the propositional variable code is used for this variable.
 String domainString(Assignment assignment)
          Returns the string representation of the domain under given assignment
 String domainStringSaved()
          Returns the string representation of the saved domain
 int getCodeMax()
          Returns the maximum propositional variable index used to encode this variable.
 int getCodeMin()
          Returns the minimum propositional variable index used to encode this variable.
 String getName()
          Returns the name of this variable.
 boolean isAux()
          Returns true when this object is an aux variable.
 boolean isBool()
          Returns true when this object is a CSP boolean variable.
 boolean isModified(Assignment assignment)
          Returns true when the domain is modified.
 int lb()
          Returns the lower bound value of this variable.
 int lb(Assignment assignment)
          Returns the lower bound value of this variable under given assignment.
static Variable newBoolVariable(String name, int code)
          Creates a new CSP boolean variable object.
static Variable newIntVariable(String name, int code, int[][] domain)
          Creates a new CSP integer variable object.
 void reset()
          Resets the variable to initial state
 void saveDomain(Assignment assignment)
          Saves the domain information under given assignment.
 int toCode(int value)
          Returns the index of the propositional variable corresponding to the value.
 String toString()
           
 String[] toStrings(Assignment assignment, boolean showOldDomain)
          Returns the string representation of this variable
 int toValue(int code)
          Returns the value of this integer variable corresponding to code.
 int ub()
          Returns the upper bound value of this variable.
 int ub(Assignment assignment)
          Returns the upper bound value of this variable under given assignment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newIntVariable

public static Variable newIntVariable(String name,
                                      int code,
                                      int[][] domain)
Creates a new CSP integer variable object.

Parameters:
name - then name of the variable
code - the minimum propositional variable index used to encode this variable
domain - array of intervals
Returns:
the CSP variable created

newBoolVariable

public static Variable newBoolVariable(String name,
                                       int code)
Creates a new CSP boolean variable object.

Parameters:
name - then name of the variable
code - the minimum propositional variable index used to encode this variable
Returns:
the CSP variable created

reset

public void reset()
Resets the variable to initial state


getName

public String getName()
Returns the name of this variable.

Returns:
the name of this variable

isBool

public boolean isBool()
Returns true when this object is a CSP boolean variable.

Returns:
true when this object is a CSP boolean variable

isAux

public boolean isAux()
Returns true when this object is an aux variable.

Returns:
true when this object is an aux variable

contains

public boolean contains(int code)
Returns true when the propositional variable code is used for this variable.

Parameters:
code - the index of the propositional variable
Returns:
true when code is used for this

getCodeMin

public int getCodeMin()
Returns the minimum propositional variable index used to encode this variable.

Returns:
the minimum propositional variable index

getCodeMax

public int getCodeMax()
Returns the maximum propositional variable index used to encode this variable.

Returns:
the maximum propositional variable index

lb

public int lb()
Returns the lower bound value of this variable. 0 is returned when this is a boolean variable.

Returns:
the lower bound value

ub

public int ub()
Returns the upper bound value of this variable. 1 is returned when this is a boolean variable.

Returns:
the upper bound value

toValue

public int toValue(int code)
            throws TracerException
Returns the value of this integer variable corresponding to code. Exception is raised when this is a boolean variable, or code is not used to encode this object.

Parameters:
code - the index of the propositional variable
Returns:
the value of this integer variable corresponding
Throws:
TracerException

toCode

public int toCode(int value)
           throws TracerException
Returns the index of the propositional variable corresponding to the value.

Parameters:
value - the value of the variable
Returns:
the index of the propositional variable corresponding
Throws:
TracerException

lb

public int lb(Assignment assignment)
Returns the lower bound value of this variable under given assignment.

Parameters:
assignment - the assignment
Returns:
the lower bound value under assignment

ub

public int ub(Assignment assignment)
Returns the upper bound value of this variable under given assignment.

Parameters:
assignment - the assignment
Returns:
the upper bound value under assignment

saveDomain

public void saveDomain(Assignment assignment)
Saves the domain information under given assignment.

Parameters:
assignment - the assignment

isModified

public boolean isModified(Assignment assignment)
Returns true when the domain is modified.

Parameters:
assignment -
Returns:
true when the domain is modified

domainString

public String domainString(Assignment assignment)
Returns the string representation of the domain under given assignment

Parameters:
assignment - the assignment
Returns:
the string representation

domainStringSaved

public String domainStringSaved()
Returns the string representation of the saved domain

Returns:
the string representation

toStrings

public String[] toStrings(Assignment assignment,
                          boolean showOldDomain)
Returns the string representation of this variable

Parameters:
assignment -
showOldDomain -
Returns:
the string representation of this variable

toString

public String toString()
Overrides:
toString in class Object

SugarTrace version 1.0.1 Core API Specification

SugarTracer: Tracer of Sugar