-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAntMapper.java
More file actions
70 lines (57 loc) · 1.72 KB
/
AntMapper.java
File metadata and controls
70 lines (57 loc) · 1.72 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* \file AntMapper.java
*
* Framework class representing each map task (thread work)
* One of the central classes in the framework, the AntMapper expresses the
* tasks for which each map thread is responsible.
*
* "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
*/
// package br.ufmg.dcc.MapRedACO;
import java.util.concurrent.Callable;
import java.util.Vector;
public abstract class AntMapper implements Callable<Pheromone>
{
protected static Pheromone currentPheromone;
protected static Graph problemGraph;
public Pheromone call()
{
return map();
}
public void mapsetup()
{
setup();
}
public void setup()
{
// should be implemented if there's something that should be
// done before the mappers start working (executed once, before any map)
}
public Pheromone map()
{
// each task (~thread) applies the core ant operations
antRandomPosition();
antBuildSolution();
antEvalSolution();
return antUpdatePheromone();
}
public void mapcleanup()
{
cleanup();
}
public void cleanup()
{
// should be implemented if there's something that should be
// done after the mappers finish working (executed once after all maps)
}
public abstract void antRandomPosition();
public abstract void antBuildSolution();
public abstract void antEvalSolution();
public abstract Pheromone antUpdatePheromone();
}