Interface Variable

All Superinterfaces:
Serializable
All Known Implementing Classes:
BinaryIntegerVariable, BinaryVariable, Grammar, Permutation, Program, RealVariable, Subset

public interface Variable extends Serializable
Interface for decision variables. This interface ensures independent copies of decision variables can be constructed. Implementations are strongly encouraged to also override Object.equals(Object) and Object.hashCode().
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an independent copy of this decision variable.
    void
    decode(String value)
    Parses and loads the value of this variable from a string.
    Encodes the value of this variable as a string.
    void
    Randomly assign the value of this variable.
    Returns a human-readable representation of this value.
  • Method Details

    • copy

      Variable copy()
      Returns an independent copy of this decision variable. It is required that x.copy() is completely independent from x. This means any method invoked on x.copy() in no way alters the state of x and vice versa. It is typically the case that x.copy().getClass() == x.getClass() and x.copy().equals(x).
      Returns:
      an independent copy of this decision variable
    • randomize

      void randomize()
      Randomly assign the value of this variable. In general, the randomization should follow a uniform distribution.
    • toString

      String toString()
      Returns a human-readable representation of this value.
      Overrides:
      toString in class Object
      Returns:
      the value of this variable formatted as a string
    • encode

      String encode()
      Encodes the value of this variable as a string. This should reflect the internal representation of the value and not necessarily the actual value. For example, a binary-encoded integer should display the bits and not the integer value. Implementations should make an effort to display the value in a meaningful format, but that is not required. Instead, use toString() if a human-readable format is required. This method along with decode(String) are used primarily for storing values in text files. To make parsing easier, the resulting string must: 1. Only contain ASCII characters 2. Contain no whitespace (no spaces, tabs, newlines, etc.)
      Returns:
      the encoded value as a string
    • decode

      void decode(String value)
      Parses and loads the value of this variable from a string. This must be able to process any string produced by encode().
      Parameters:
      value - the value as a string