Been fiddling around with my main method's looping for the last hour or so, to no avail. The issue is coming from Array Out of Bounding in both the values array and the identity matrix.
Assume all other methods etc. are functional.
public static void main(String args[])
{
double adjacency_matrix[][] = new double[80][80];
double[] values = new double[160];
String[]contents = new String[160];
FileIO reader = new FileIO();
contents = reader.load("C:\\Users\\Mark\\Documents\\Java Workspace\\CS211\\src\\TSP\\locations.txt");
double temp1,temp2,temp3,temp4;
int count = 0,count2 = 0;
for(int i=0; i<values.length; i++)
{
values[i] = Double.parseDouble(contents[i].substring(0,contents[i].length()-1));
}
for(int i=0; i<=79;i++)
{
for(int j=0; j<=79; j++)
{
if(i == j)
{
adjacency_matrix[i][j] = 0.0;
count2+=1;
}
else
{
temp1 = values[i+count];
temp2 = values[i + count + 1];
temp3 = values[j + count2];
temp4 = values[j +count2 + 1];
adjacency_matrix[i][j] = GPSDistanceHarversine.gpsDistance(temp1, temp2, temp3, temp4);
count2+=1;
}
count+=1;
count2 = 0;
}
}
System.out.println("The cities are visited as follows:");
TspMain tspNearestNeighbour = new TspMain();
tspNearestNeighbour.tsp(adjacency_matrix);
}
The nested distance checking loop is causing the issues. Can anyone see what could be screwing up?