net.sourceforge.cilib.functions.discrete
Class KnightsTour

java.lang.Object
  extended by net.sourceforge.cilib.functions.Function
      extended by net.sourceforge.cilib.functions.DiscreteFunction
          extended by net.sourceforge.cilib.functions.discrete.KnightsTour
All Implemented Interfaces:
Serializable, Cloneable

public class KnightsTour
extends DiscreteFunction

An implementation of the Knight's Tour problem function. It is important to note that this implementation implements a repair to the evaluation of the potential solution. The reasoning behind this is that the knight all too often during the testing phase would jump off the board and remain off the board. The repair is a simple in-order operation that determines the position where the error occoured and tries to replace the error move with one of the possible 7 moves remaining. Once the tour can continue, the move is replaced and evaluation continues.

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
KnightsTour()
           
 
Method Summary
 double evaluate(Vector x)
          Evaluate the function output, given the function input, x.
 int getBoardSize()
           
 KnightsTour getClone()
          Create a cloned copy of the current object and return it.
 Object getMaximum()
          Accessor for the function maximum.
 Object getMinimum()
          Accessor for the function minimum.
 String getStartingPos()
           
 boolean isCyclic()
           
 void setBoardSize(int boardSize)
           
 void setCyclic(boolean cyclic)
           
 void setStartingPos(String startingPos)
          Set the starting position on the board.
 
Methods inherited from class net.sourceforge.cilib.functions.DiscreteFunction
evaluate
 
Methods inherited from class net.sourceforge.cilib.functions.Function
getBehavioralDomainRegistry, getDimension, getDomain, getDomainRegistry, setBehavioralDomain, setBehaviouralDomainRegistry, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnightsTour

public KnightsTour()
Method Detail

getClone

public KnightsTour getClone()
Description copied from interface: Cloneable
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getMaximum

public Object getMaximum()
Description copied from class: DiscreteFunction
Accessor for the function maximum. This is the maximum value of the function in the given domain.

Overrides:
getMaximum in class DiscreteFunction
Returns:
The maximum of the function.

getMinimum

public Object getMinimum()
Description copied from class: DiscreteFunction
Accessor for the function minimum. This is the minimum value of the function in the given domain.

Overrides:
getMinimum in class DiscreteFunction
Returns:

evaluate

public double evaluate(Vector x)
Description copied from class: DiscreteFunction
Evaluate the function output, given the function input, x.

Specified by:
evaluate in class DiscreteFunction
Parameters:
x - The Vector representing the function input.
Returns:
The result of the evaluation.

getBoardSize

public int getBoardSize()
Returns:
Returns the boardSize.

setBoardSize

public void setBoardSize(int boardSize)
Parameters:
boardSize - The boardSize to set.

isCyclic

public boolean isCyclic()
Returns:
Returns the cyclic.

setCyclic

public void setCyclic(boolean cyclic)
Parameters:
cyclic - The cyclic to set.

getStartingPos

public String getStartingPos()
Returns:
Returns the startingPos.

setStartingPos

public void setStartingPos(String startingPos)
Set the starting position on the board. Following the normal chess convention the rows are described by letters (A-H) on the 8x8 board and columns (0-7). These row and column values can obviously be adjusted to the currenly set board size.

Parameters:
startingPos - The startingPos to set.


Copyright © 2009 CIRG. All Rights Reserved.