choco.mem
Class Environment

java.lang.Object
  extended by choco.mem.Environment

public class Environment
extends java.lang.Object

The root class for managing memory and sessions.

A environment is associated to each problem. It is responsible for managing backtrackable data.


Field Summary
static int BOOL_TRAIL
          Index of the StoredBoolTrail for storing booleans.
 int currentWorld
          The current world number (should be less than maxWorld).
static int FLOAT_TRAIL
          Index of the StoredFloatTrail for storing integer vectors.
static int INT_TRAIL
          Index of the StoredIntTrail for storing integers.
static int INT_VECTOR_TRAIL
          Index of the StoredIntVectorTrail for storing integer vectors.
static int LONG_TRAIL
          Index of the StoredLongTrail for storing integer vectors.
protected  ITrailStorage[] trails
          Contains all the ITrailStorage trails for storing different kinds of data.
static int VECTOR_TRAIL
          Index of the StoredVectorTrail for storing vectors.
 
Constructor Summary
Environment()
          Constructs a new Environment with the default stack sizes : 50000 and 1000.
 
Method Summary
 int getIntTrailSize()
          returns the size of the trail used for storing integers
 int getIntVectorTrailSize()
          returns the size of the trail used for storing search arrays
 ITrailStorage getTrail(int i)
          Returns the ith trail in the trail array.
 int getTrailSize()
          returns the size of the trail
 int getWorldIndex()
          Returns the world number.
 StoredBitSet makeBitSet(int size)
          Factory pattern: new StoredBitSetVector objects are created by the environment
 StoredBitSet makeBitSet(int[] entries)
           
 IStateBool makeBool(boolean initialValue)
          Factory pattern: new IStateBool objects are created by the environment
 StoredFloat makeFloat()
          Factory pattern: new IStateFloat objects are created by the environment (no initial value is assigned to the backtrackable search)
 StoredFloat makeFloat(double initialValue)
          Factory pattern: new IStateFloat objects are created by the environment
 IStateInt makeInt()
          Factory pattern: new IStateInt objects are created by the environment (no initial value is assigned to the backtrackable search)
 IStateInt makeInt(int initialValue)
          Factory pattern: new IStateInt objects are created by the environment
 StoredIntVector makeIntVector()
          Factory pattern: new IStateIntVector objects are created by the environment.
 StoredIntVector makeIntVector(int[] entries)
          Factory pattern: new IStateIntVector objects are created by the environment
 StoredIntVector makeIntVector(int size, int initialValue)
          Factory pattern: new IStateIntVector objects are created by the environment
 PartiallyStoredIntVector makePartiallyStoredIntVector()
           
 PartiallyStoredVector makePartiallyStoredVector()
           
 void worldCommit()
          Accepts all modifications since the previous choice point in the search tree.
 void worldPop()
          Backtracks to the previous choice point in the search tree.
 void worldPush()
          Starts a new branch in the search tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOL_TRAIL

public static final int BOOL_TRAIL
Index of the StoredBoolTrail for storing booleans.

See Also:
Constant Field Values

INT_TRAIL

public static final int INT_TRAIL
Index of the StoredIntTrail for storing integers.

See Also:
Constant Field Values

VECTOR_TRAIL

public static final int VECTOR_TRAIL
Index of the StoredVectorTrail for storing vectors.

See Also:
Constant Field Values

INT_VECTOR_TRAIL

public static final int INT_VECTOR_TRAIL
Index of the StoredIntVectorTrail for storing integer vectors.

See Also:
trails, Constant Field Values

FLOAT_TRAIL

public static final int FLOAT_TRAIL
Index of the StoredFloatTrail for storing integer vectors.

See Also:
trails, Constant Field Values

LONG_TRAIL

public static final int LONG_TRAIL
Index of the StoredLongTrail for storing integer vectors.

See Also:
trails, Constant Field Values

currentWorld

public int currentWorld
The current world number (should be less than maxWorld).


trails

protected ITrailStorage[] trails
Contains all the ITrailStorage trails for storing different kinds of data.

Constructor Detail

Environment

public Environment()
Constructs a new Environment with the default stack sizes : 50000 and 1000.

Method Detail

getTrail

public ITrailStorage getTrail(int i)
Returns the ith trail in the trail array.

Parameters:
i - index of the trail.

getWorldIndex

public int getWorldIndex()
Returns the world number.

See Also:
currentWorld

worldPush

public void worldPush()
Starts a new branch in the search tree.


worldPop

public void worldPop()
Backtracks to the previous choice point in the search tree.


worldCommit

public void worldCommit()
Accepts all modifications since the previous choice point in the search tree.


makeInt

public IStateInt makeInt()
Factory pattern: new IStateInt objects are created by the environment (no initial value is assigned to the backtrackable search)


makeInt

public IStateInt makeInt(int initialValue)
Factory pattern: new IStateInt objects are created by the environment

Parameters:
initialValue - the initial value of the backtrackable integer

makeBool

public IStateBool makeBool(boolean initialValue)
Factory pattern: new IStateBool objects are created by the environment

Parameters:
initialValue - the initial value of the backtrackable boolean

makeIntVector

public StoredIntVector makeIntVector()
Factory pattern: new IStateIntVector objects are created by the environment. Creates an empty vector


makeIntVector

public StoredIntVector makeIntVector(int size,
                                     int initialValue)
Factory pattern: new IStateIntVector objects are created by the environment

Parameters:
size - the number of entries in the vector
initialValue - the common initial value for all entries (backtrackable integers)

makeIntVector

public StoredIntVector makeIntVector(int[] entries)
Factory pattern: new IStateIntVector objects are created by the environment

Parameters:
entries - an array to be copied as set of initial contents of the vector

makePartiallyStoredVector

public PartiallyStoredVector makePartiallyStoredVector()

makePartiallyStoredIntVector

public PartiallyStoredIntVector makePartiallyStoredIntVector()

makeBitSet

public StoredBitSet makeBitSet(int size)
Factory pattern: new StoredBitSetVector objects are created by the environment


makeBitSet

public StoredBitSet makeBitSet(int[] entries)

makeFloat

public StoredFloat makeFloat()
Factory pattern: new IStateFloat objects are created by the environment (no initial value is assigned to the backtrackable search)


makeFloat

public StoredFloat makeFloat(double initialValue)
Factory pattern: new IStateFloat objects are created by the environment

Parameters:
initialValue - the initial value of the backtrackable search

getTrailSize

public int getTrailSize()
returns the size of the trail


getIntTrailSize

public int getIntTrailSize()
returns the size of the trail used for storing integers


getIntVectorTrailSize

public int getIntVectorTrailSize()
returns the size of the trail used for storing search arrays