javax.constraints.impl.search
Class BasicSolution

java.lang.Object
  extended by javax.constraints.impl.search.BasicSolution
All Implemented Interfaces:
Solution

public class BasicSolution
extends java.lang.Object
implements Solution


Constructor Summary
BasicSolution(Solver solver, int solutionNumber)
           
 
Method Summary
 int getAt(java.lang.String name)
          A synonym for getValue(name).
 int getMax(int i)
          Returns the maximum value in the domain of the solution variable with index i.
 int getMax(java.lang.String name)
          Returns the maximum value in the domain of the solution variable with the given name.
 int getMin(int i)
          Returns the minimum value in the domain of the solution variable with the index i.
 int getMin(java.lang.String name)
          Returns the minimum value in the domain of the solution variable with the given name.
 int getNumberOfVarReals()
          Returns the number of decision integer variables in the solution
 int getNumberOfVars()
          Returns the number of decision integer variables in the solution
 int getNumberOfVarSets()
          Returns the number of decision integer variables in the solution
 Problem getProblem()
          Returns the problem that this Solution is a solution to.
 double getRealValue(int i)
          Returns the value of the solution real variable with the index i, throws a RuntimeException if the real variable is not bound.
 double getRealValue(java.lang.String name)
          Returns the value of the solution real variable with the given name, throws a RuntimeException if the real variable is not bound.
 int getSolutionNumber()
          Returns the number identifying this Solution.
 Solver getSolver()
          Returns the solver that created this Solution.
 int getValue(int i)
          Returns the value of the solution variable with the index i, throws a RuntimeException if the variable is not bound.
 int getValue(java.lang.String name)
          Returns the value of the solution variable with the given name, throws a RuntimeException if the variable is not bound.
 boolean isBound()
          Returns true if all the solution variables are bound, i.e.
 boolean isBound(int i)
          Returns true if the domain of the solution variable with the index i is a single value, i.e.
 boolean isBound(java.lang.String name)
          Returns true if the domain of the solution variable with the given name is a single value, i.e.
 void log()
          Logs the solution in the information log
 void log(int varPerLinePar)
          Logs the solution in the information log.
 void logVarReals()
          Logs real variables of the solution in the information log
 void logVars()
          Logs integer variables of the solution in the information log
 void logVarSets()
          Logs set variables of the solution in the information log
 void setSolutionNumber(int number)
          Sets the number identifying this Solution.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicSolution

public BasicSolution(Solver solver,
                     int solutionNumber)
Method Detail

getAt

public int getAt(java.lang.String name)
A synonym for getValue(name). Used by Groovy to overload the operator solution["Name"]

Specified by:
getAt in interface Solution
Parameters:
name -
Returns:
int

getMax

public int getMax(int i)
Description copied from interface: Solution
Returns the maximum value in the domain of the solution variable with index i.

Specified by:
getMax in interface Solution
Parameters:
i - the index of the desired solution variable.
Returns:
maximum value of the solution variable with the given name.

getMax

public int getMax(java.lang.String name)
Description copied from interface: Solution
Returns the maximum value in the domain of the solution variable with the given name.

Specified by:
getMax in interface Solution
Parameters:
name - the name of the desired solution variable.
Returns:
maximum value of the solution variable with the given name.

getMin

public int getMin(int i)
Description copied from interface: Solution
Returns the minimum value in the domain of the solution variable with the index i.

Specified by:
getMin in interface Solution
Parameters:
i - the index of the desired solution variable.
Returns:
minimum value of the solution variable with the given name.

getMin

public int getMin(java.lang.String name)
Description copied from interface: Solution
Returns the minimum value in the domain of the solution variable with the given name.

Specified by:
getMin in interface Solution
Parameters:
name - the name of the desired solution variable.
Returns:
minimum value of the solution variable with the given name.

getNumberOfVarReals

public int getNumberOfVarReals()
Returns the number of decision integer variables in the solution

Specified by:
getNumberOfVarReals in interface Solution
Returns:
the number of decision integer variables in the solution

getNumberOfVars

public int getNumberOfVars()
Returns the number of decision integer variables in the solution

Specified by:
getNumberOfVars in interface Solution
Returns:
the number of decision integer variables in the solution

getNumberOfVarSets

public int getNumberOfVarSets()
Returns the number of decision integer variables in the solution

Specified by:
getNumberOfVarSets in interface Solution
Returns:
the number of decision integer variables in the solution

getProblem

public Problem getProblem()
Description copied from interface: Solution
Returns the problem that this Solution is a solution to.

Specified by:
getProblem in interface Solution
Returns:
the problem that this Solution is a solution to.

getRealValue

public double getRealValue(int i)
Description copied from interface: Solution
Returns the value of the solution real variable with the index i, throws a RuntimeException if the real variable is not bound.

Specified by:
getRealValue in interface Solution
Parameters:
i - the index of the desired solution real variable .
Returns:
the value of solution real variable with the given name, assuming that the real variable is bound.

getRealValue

public double getRealValue(java.lang.String name)
Description copied from interface: Solution
Returns the value of the solution real variable with the given name, throws a RuntimeException if the real variable is not bound.

Specified by:
getRealValue in interface Solution
Parameters:
name - the name of the desired solution real variable .
Returns:
the value of solution real variable with the given name, assuming that the real variable is bound.

getSolutionNumber

public int getSolutionNumber()
Description copied from interface: Solution
Returns the number identifying this Solution.

Specified by:
getSolutionNumber in interface Solution
Returns:
the number identifying this Solution.

getSolver

public Solver getSolver()
Description copied from interface: Solution
Returns the solver that created this Solution.

Specified by:
getSolver in interface Solution
Returns:
the solver that created this Solution.

getValue

public int getValue(int i)
Description copied from interface: Solution
Returns the value of the solution variable with the index i, throws a RuntimeException if the variable is not bound.

Specified by:
getValue in interface Solution
Parameters:
i - the index of the desired solution variable .
Returns:
the value of solution variable with the given name, assuming that the variable is bound.

getValue

public int getValue(java.lang.String name)
Description copied from interface: Solution
Returns the value of the solution variable with the given name, throws a RuntimeException if the variable is not bound.

Specified by:
getValue in interface Solution
Parameters:
name - the name of the desired solution variable .
Returns:
the value of solution variable with the given name, assuming that the variable is bound.

isBound

public boolean isBound()
Description copied from interface: Solution
Returns true if all the solution variables are bound, i.e. if isBound(name) returns true for all solution variables.

Specified by:
isBound in interface Solution
Returns:
true if all the solutions variables are bound.
See Also:
Solution.isBound(String)

isBound

public boolean isBound(int i)
Description copied from interface: Solution
Returns true if the domain of the solution variable with the index i is a single value, i.e. getMin(name) == getMax(name).

Specified by:
isBound in interface Solution
Parameters:
i - the index of the desired solution variable.
Returns:
true if the domain of the solution variable with the given name is a single value.

isBound

public boolean isBound(java.lang.String name)
Description copied from interface: Solution
Returns true if the domain of the solution variable with the given name is a single value, i.e. getMin(name) == getMax(name).

Specified by:
isBound in interface Solution
Parameters:
name - the name of the desired solution variable.
Returns:
true if the domain of the solution variable with the given name is a single value.

log

public void log()
Description copied from interface: Solution
Logs the solution in the information log

Specified by:
log in interface Solution

log

public void log(int varPerLinePar)
Logs the solution in the information log. Logs only "varPerLine" variables per line. By default varPerLine = 8.

Specified by:
log in interface Solution

logVarReals

public void logVarReals()
Logs real variables of the solution in the information log


logVars

public void logVars()
Logs integer variables of the solution in the information log


logVarSets

public void logVarSets()
Logs set variables of the solution in the information log


setSolutionNumber

public void setSolutionNumber(int number)
Description copied from interface: Solution
Sets the number identifying this Solution.

Specified by:
setSolutionNumber in interface Solution
Parameters:
number - the number identifying this Solution.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object