|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRoute
public class Route
Route is a representation of a path in a TSP problem. Routes are primarily manipulated and constructed by agents. The class stores nodes in an ArrayList of Integers.
Field Summary | |
---|---|
private java.util.ArrayList |
al
|
private boolean |
calculated
|
private int |
length
|
Constructor Summary | |
---|---|
Route()
Constructs a blank Route. |
Method Summary | |
---|---|
void |
addNewNode(int n)
Adds a node onto the end of the Route. |
int |
calcDistanceOfRoute(PherMatrix pherMatrix)
Returns the length of the route. |
int |
calcDistanceOfRouteOverride(PherMatrix pherMatrix)
Helper method for local optimization methods, such as 2-opt and 3-opt. |
void |
clear()
Clears the current Route. |
void |
clearRoute()
Clears the current Route. |
Route |
deepCopy()
Returns a copy of the Route. |
int |
get(int n)
Returns the Node number at a particular index of the Route. |
int |
getCurrentNode()
Returns the node at the end of the Route. |
int |
getSize()
Returns the current size of the Route. |
int |
removeIndex(int x)
Removes the node at a particular index in the Route and returns its number. |
void |
swap(int x,
int y)
Helper method for local optimization methods, such as 2-opt and 3-opt. |
java.lang.String |
toString()
Debugging method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.ArrayList al
private boolean calculated
private int length
Constructor Detail |
---|
public Route()
Method Detail |
---|
public void addNewNode(int n)
n
- Node to be added onto the Routepublic int get(int n)
n
- Index number of the Route
public int getSize()
public void clearRoute()
public int removeIndex(int x)
x
- Index of the node to be removed in the Route
public java.lang.String toString()
toString
in class java.lang.Object
public int getCurrentNode()
public int calcDistanceOfRoute(PherMatrix pherMatrix)
pherMatrix
- PherMatrix storing the distance values between nodes
public int calcDistanceOfRouteOverride(PherMatrix pherMatrix)
pherMatrix
- PherMatrix storing the distance values between nodes
public void clear()
public void swap(int x, int y)
x
- First nodey
- Second nodepublic Route deepCopy()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |