-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyTSPSolution.java
More file actions
56 lines (48 loc) · 1.21 KB
/
myTSPSolution.java
File metadata and controls
56 lines (48 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* \file myTSPSolution.java
*
* TSP client implementing the framework interface for each candidate solution to the problem.
*
* "Map Ants, Reduce Work": a research project regarding a MapReduce inspired
* parallel framework for the Ant Colony Optimization (ACO) algorithm, under
* development at UFMG (Universidade Federal de Minas Gerais, Brazil).
*
* \author Phillippe Samer <phillippes@gmail.com>
*
* \date 16.01.2011
*/
public class myTSPSolution implements Solution<Long>
{
public int[] solution;
public long value;
public myTSPSolution()
{
solution = new int[Config.num_cities];
}
public myTSPSolution(int[] sol, long val)
{
solution = sol;
value = val;
}
@Override
public String toString()
{
// user-friendly solution
String answer = "";
for (int k = 0; k < Config.num_cities-1; ++k)
answer += (solution[k] + "-");
answer += solution[Config.num_cities-1];
return answer;
}
@Override
public Long getValue()
{
// solution quality (~fitness)
return new Long(value);
}
@Override
public void setValue(long x)
{
value = x;
}
}