|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectACS
public class ACS
ACS is the main class that keeps track of all agents and manipulates pheromone as necessary. The important functions of ACS include:
| Field Summary | |
|---|---|
java.util.ArrayList |
ants
|
Route |
bestSoFar
|
(package private) double |
CONSTANTQ
|
ACSDisplay |
display
|
int[][] |
distances
|
boolean |
dynamic
|
int |
iterationChanged
|
int |
lastRouteLength
|
double[] |
lengthIterationStorage
|
Node[] |
nodes
|
PherMatrix |
phers
|
int |
STRECH
|
int |
totalLengths
|
int[] |
valids
|
int |
validsChanged
|
| Constructor Summary | |
|---|---|
ACS(java.lang.String filename,
int n,
int strech,
boolean changing,
ACSDisplay tempDisplay)
Creates ACS. |
|
| Method Summary | |
|---|---|
void |
accountPherNode(int n)
Notify the PherMatrix of a node addition. |
void |
ACSUpdatePhers()
Calls PherMatrix to update pheromone values using the Ant Colony System (ACS) implementation. |
void |
actIndependent()
Continues a ACO algorithm automatically until an end condition. |
void |
changeValids()
Changes the set of valid nodes in the DTSP problem and notifies PherMatrix of changes. |
int |
findDistance(int x,
int y)
Helper method for intializing the distance matrix. |
void |
intializeAnts(boolean changing)
Intializes ants ArrayList. |
void |
intializeDistances()
Intializes distances matrix. |
void |
intializeFile(java.lang.String filename,
boolean changing)
Intializes TSP from file. |
void |
intializePher()
Intializes PherMatrix for the TSP. |
void |
intializeRandom(int num,
boolean changing)
Intializes TSP randomly. |
void |
intializeValids(boolean changing)
Intializes valids array that relates to whether a node in nodes array is currently active. |
void |
intializeVariables(java.lang.String filename,
int n,
boolean changing)
Decides whether or not the TSP is coming from a file or to be generated randomly. |
void |
iteration(boolean changing)
One step of ACO algorithm. |
void |
MinMaxUpdatePhers()
Calls multiple PherMatrix methods to effectively update pheromone values using the Min-Max implementation. |
boolean |
nodesContains(int x,
int y,
int n)
Helper method for random generation to insure that two nodes do not occupy the same location. |
void |
removePherNode(int n)
Notify the PherMatrix of a node removal. |
void |
updatePhers()
Updates pheromone values after agents have generated their Routes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public java.util.ArrayList ants
public Node[] nodes
public int[][] distances
public int[] valids
public double[] lengthIterationStorage
public PherMatrix phers
public Route bestSoFar
public int STRECH
public int totalLengths
public int lastRouteLength
public ACSDisplay display
public boolean dynamic
public int validsChanged
public int iterationChanged
double CONSTANTQ
| Constructor Detail |
|---|
public ACS(java.lang.String filename,
int n,
int strech,
boolean changing,
ACSDisplay tempDisplay)
filename - The name of the file containing TSP data. If the problem is to be generated randomly, the filename "random" will be passedn - The size of a random problem.strech - The scale of the problem. For drawing purposes involving ACSDisplaychanging - Indicates if the problem is dynamictempDisplay - Pointer to an ACSDisplay if it is being used. null if not used| Method Detail |
|---|
public void actIndependent()
iteration(boolean changing)public void iteration(boolean changing)
Agent,
PherMatrixpublic void updatePhers()
ACSUpdatePhers(),
MinMaxUpdatePhers()public void ACSUpdatePhers()
PherMatrixpublic void MinMaxUpdatePhers()
PherMatrixpublic void changeValids()
removePherNode(int n),
accountPherNode(int n),
PherMatrixpublic void removePherNode(int n)
n - Node number being removedPherMatrixpublic void accountPherNode(int n)
n - Node number being addedPherMatrix
public void intializeVariables(java.lang.String filename,
int n,
boolean changing)
filename - The name of the file containing TSP data. If the problem is to be generated randomly, the filename "random" will be passedn - The size of a random problem.changing - Indicates if the problem is dynamicintializeRandom(int num, boolean changing),
intializeFile(String filename, boolean changing)
public void intializeFile(java.lang.String filename,
boolean changing)
filename - The name of the file containing TSP datachanging - Indicates if the problem is dynamicintializeValids(boolean changing),
intializeDistances(),
intializePher(),
intializeAnts(boolean changing)
public void intializeRandom(int num,
boolean changing)
num - The number of nodes to be included in the TSP problemchanging - Indicates if the problem is dynamicnodesContains(int x, int y, int n),
intializeValids(boolean changing),
intializeDistances(),
intializePher(),
intializeAnts(boolean changing)public void intializeValids(boolean changing)
changing - Indicates if the problem is dynamicpublic void intializeDistances()
findDistance(int x, int y)public void intializePher()
PherMatrixpublic void intializeAnts(boolean changing)
changing - Indicates if the problem is dynamic
public boolean nodesContains(int x,
int y,
int n)
x - X coordinate of point to be addedy - Y coordinate of point to be addedn - The number of nodes added to the problem so far
public int findDistance(int x,
int y)
x - 1st node numbery - 2nd node number
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||