nenok.va.sr
Class Configuration

java.lang.Object
  extended by nenok.va.sr.Configuration

public class Configuration
extends Object

Utility class for the representation of configurations. This class encodes configurations (object arrays) into the according integer position of their standard enumeration.

Version:
$LastChangedRevision: 560 $
$LastChangedDate: 2008-03-26 14:37:05 +0100 (Mi, 26 Mrz 2008) $
Author:
Marc Pouly

Constructor Summary
Configuration()
           
 
Method Summary
static int convert(int conf, FiniteVariable[] from, FiniteVariable[] to)
          Converts a configuration encoding relative to some variable array into the encoding relative to another variable array.
static String[] decode(int conf, FiniteVariable[] vars)
          Decodes the given configuration (integer) into an object array.
static int encode(Object[] conf, FiniteVariable[] vars)
          Encodes the given configuration (object array) into an integer.
static String[] getConfigurations(FiniteVariable[] vars)
          Transforms configurations into string representation.
static int getSymbolIndex(FiniteVariable[] vars, int var, int conf)
          This method returns the index of the variable's value at a specifique configuration.
static int indexOf(Object[] objects, Object item)
          Finds an item in an array of objects.
static Object[] project(Object[] conf, FiniteVariable[] from, FiniteVariable[] to)
          Projects a configuration given as object array to some sub-set of variables.
static Object[] union(Object[] c1, FiniteVariable[] v1, Object[] c2, FiniteVariable[] v2, FiniteVariable[] result)
          Computes the union of two partial configurations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Method Detail

encode

public static int encode(Object[] conf,
                         FiniteVariable[] vars)
Encodes the given configuration (object array) into an integer. The variable array defines the configuration's order.

Parameters:
conf - The configuration to encode.
vars - The variable array to specify the configuration's order.
Returns:
The encoded configuration relative to the variable array.

decode

public static String[] decode(int conf,
                              FiniteVariable[] vars)
Decodes the given configuration (integer) into an object array. The variable array defines the configuration's code order.

Parameters:
conf - The configuration to decode.
vars - The variable array to specify the configuration's order.
Returns:
The decoded configuration relative to the variable array.

convert

public static int convert(int conf,
                          FiniteVariable[] from,
                          FiniteVariable[] to)
Converts a configuration encoding relative to some variable array into the encoding relative to another variable array.

Parameters:
conf - The configuration to convert.
from - The variable array to which the input configuration is relative.
to - The variable array to which the output configuration is relative.
Returns:
The converted configuration.

project

public static Object[] project(Object[] conf,
                               FiniteVariable[] from,
                               FiniteVariable[] to)
Projects a configuration given as object array to some sub-set of variables.

Parameters:
conf - The configuration that has to be projected.
from - The variable array to which the argument configuration is relative.
to - The target array to which the projection is executed.
Returns:
The argument configuration projected (and relative) to to.

union

public static Object[] union(Object[] c1,
                             FiniteVariable[] v1,
                             Object[] c2,
                             FiniteVariable[] v2,
                             FiniteVariable[] result)
Computes the union of two partial configurations.

Parameters:
c1 - The first configuration.
v1 - The variable array that specifies the first configuration's order.
c2 - The second configuration.
v2 - The variable array that specifies the second configuration's order.
result - The variable array that specifies the result's order.
Returns:
The union configuration of the two argument configuration relative to the given variable array.

getConfigurations

public static String[] getConfigurations(FiniteVariable[] vars)
Transforms configurations into string representation.

Parameters:
vars - The order of variables that defines the configurations.
Returns:
Configurations as stings.

getSymbolIndex

public static int getSymbolIndex(FiniteVariable[] vars,
                                 int var,
                                 int conf)
This method returns the index of the variable's value at a specifique configuration.

Parameters:
vars - The order of variables that defines the configuration.
var - The variable caracterized by its position.
conf - The configuration whose index has to be found.
Returns:
The symbol of the variable at the given configuration. Example:
getSymbol(vars, 0,3) returns the index of variable 0's symbol in vars at configuration 3.

indexOf

public static int indexOf(Object[] objects,
                          Object item)
Finds an item in an array of objects.

Parameters:
objects - The array of objects.
item - The item to find.
Returns:
The item's position in the given array or -1 if the item cannot be found.