3 import java
.util
.HashMap
;
4 import java
.util
.SortedMap
;
10 import aco
.strategy
.*;
11 import aco
.parameter
.*;
12 import aco
.environment
.*;
14 public class ACOMediator
15 implements AntViewObservable
{
17 protected ACOGraph acog
;
18 protected ACOParameter acop
;
19 protected Environment env
;
21 public ACOMediator() {
27 public ACOMediator(ACOParameter acop
) {
33 public ACOMediator(ACOGraph acog
, ACOParameter acop
) {
39 public ACOMediator(ACOGraph acog
, ACOParameter acop
, Environment env
) {
45 public ACOGraph
getACOGraph() {
49 public void setACOGraph(ACOGraph acog
) {
53 public ACOParameter
getACOParameter() {
57 public void setACOParameter(ACOParameter acop
) {
61 public Environment
getEnvironment() {
65 public void setEnvironment(Environment env
) {
69 public ACOStrategy
getACOStrategy() {
70 return acop
.getACOStrategy();
73 public void setACOStrategy(ACOStrategy acos
) {
74 acop
.setACOStrategy(acos
);
77 public GraphStrategy
getGraphStrategy() {
78 return acop
.getGraphStrategy();
81 public void setGraphStrategy(GraphStrategy gs
) {
82 acop
.setGraphStrategy(gs
);
85 public TauZeroStrategy
getTauZeroStrategy() {
86 return acop
.getTauZeroStrategy();
89 public void setTauZeroStrategy(TauZeroStrategy tzs
) {
90 acop
.setTauZeroStrategy(tzs
);
93 public DistanceStrategy
getDistanceStrategy() {
94 return acop
.getDistanceStrategy();
97 public void setDistanceStrategy(DistanceStrategy ds
) {
98 acop
.setDistanceStrategy(ds
);
101 public PheromoneStrategy
getPheromoneStrategy() {
102 return acop
.getPheromoneStrategy();
105 public void setPheromoneStrategy(PheromoneStrategy ps
) {
106 acop
.setPheromoneStrategy(ps
);
109 public ChoiceInformationStrategy
getChoiceInformationStrategy() {
110 return acop
.getChoiceInformationStrategy();
113 public void setChoiceInformationStrategy(ChoiceInformationStrategy cis
) {
114 acop
.setChoiceInformationStrategy(cis
);
117 public HeuristicInformationStrategy
getHeuristicInformationStrategy() {
118 return acop
.getHeuristicInformationStrategy();
121 public void setHeuristicInformationStrategy(HeuristicInformationStrategy his
) {
122 acop
.setHeuristicInformationStrategy(his
);
125 public int getInfinity() {
126 return acop
.getInfinity();
129 public double getBeta() {
130 return acop
.getBeta();
133 public void setBeta(double Beta
) {
137 public double getRoh() {
138 return acop
.getRoh();
141 public void setRoh(double Roh
) {
145 public double getTauZero() {
146 return acop
.getTauZero();
149 public void setTauZero(double TauZero
) {
150 acop
.setTauZero(TauZero
);
153 public int getMaxNumOfTours() {
154 return acop
.getMaxNumOfTours();
157 public void setMaxNumOfTours(int v
) {
158 acop
.setMaxNumOfTours(v
);
161 public int getNumOfAnts() {
162 return acop
.getNumOfAnts();
165 public void setNumOfAnts(int v
) {
166 acop
.setNumOfAnts(v
);
169 public int getNumOfCities() {
170 return acop
.getNumOfCities();
173 public void setNumOfCities(int v
) {
174 acop
.setNumOfCities(v
);
177 public int getNearestNeighbourListDepth() {
178 return acop
.getNearestNeighbourListDepth();
181 public void setNearestNeighbourListDepth(int NearestNeighbourListDepth
) {
182 acop
.setNearestNeighbourListDepth(NearestNeighbourListDepth
);
185 public int getNearestNeighbour(int x
, int y
) {
186 return acog
.getNearestNeighbour(x
, y
);
189 public int getDistance(int x
, int y
) {
190 return acog
.getDistance(x
, y
);
193 public void setDistance(int x
, int y
, int v
) {
194 acog
.setDistance(x
, y
, v
);
197 public CoordinatePair
<Integer
, Integer
> getCoordinates(int City
) {
198 return acog
.getCoordinates(City
);
201 public HashMap
<Integer
, CoordinatePair
<Integer
, Integer
>> getCoordinateData() {
202 return acog
.getCoordinateData();
205 public double getPheromone(int x
, int y
) {
206 return acog
.getPheromone(x
, y
);
209 public void setPheromone(int x
, int y
, double v
) {
210 acog
.setPheromone(x
, y
, v
);
213 public double getChoiceInformation(int x
, int y
) {
214 return acog
.getChoiceInformation(x
, y
);
217 public void setChoiceInformation(int x
, int y
, double v
) {
218 acog
.setChoiceInformation(x
, y
, v
);
221 public double getHeuristicInformation(int x
, int y
) {
222 return acog
.getHeuristicInformation(x
, y
);
225 public void setHeuristicInformation(int x
, int y
, double v
) {
226 acog
.setHeuristicInformation(x
, y
, v
);
229 public void computeTauZero() {
230 acop
.getTauZeroStrategy().computeTauZero();
233 public void computeChoiceInformation() {
234 acop
.getChoiceInformationStrategy().computeChoiceInformation();
237 public void computeHeuristicInformation() {
238 acop
.getHeuristicInformationStrategy().computeHeuristicInformation();
241 public void computeNearestNeighbourListDepth() {
242 acop
.getGraphStrategy().computeNearestNeighbourListDepth();
245 public int[][] computeDistances() {
246 return acop
.getDistanceStrategy().computeDistances();
249 public void setInitialPheromones(double TauZero
) {
250 acop
.getPheromoneStrategy().setInitialPheromones(TauZero
);
253 public int nearestNeighbourHeuristicRandomStart() {
254 return acop
.getGraphStrategy().nearestNeighbourHeuristicRandomStart();
257 public void pheromoneUpdate(Ant
[] ants
) {
258 acop
.getPheromoneStrategy().pheromoneUpdate(ants
);
261 public void computeTourLength(Ant ant
) {
262 acop
.getACOStrategy().computeTourLength(ant
);
265 public void pickInitialRandomCity(Ant ant
) {
266 acop
.getACOStrategy().pickInitialRandomCity(ant
);
269 public void neighbourListASDecisionRule(Ant ant
, int Step
) {
270 acop
.getACOStrategy().neighbourListASDecisionRule(ant
, Step
);
273 public int getGlobalBestTourMapSize() {
274 return acop
.getGlobalBestTourMapSize();
277 public void setGlobalBestTourMapSize(int GlobalBestTourMapSize
) {
278 acop
.setGlobalBestTourMapSize(GlobalBestTourMapSize
);
281 public SortedMap
<Integer
, int[]> getGlobalBestTourMap() {
282 return env
.getGlobalBestTourMap();
285 public void addGlobalBestTour(Integer TourLength
, int[] Tour
) {
286 env
.addGlobalBestTour(TourLength
, Tour
);
289 public int[] getGlobalBestTour() {
290 return env
.getGlobalBestTour();
293 public int getGlobalBestTour(int index
) {
294 return env
.getGlobalBestTour(index
);
297 public void setGlobalBestTour(int[] GlobalBestTour
) {
298 env
.setGlobalBestTour(GlobalBestTour
);
301 public void setGlobalBestTour(int index
, int GlobalBestTour
) {
302 env
.setGlobalBestTour(index
, GlobalBestTour
);
305 public int getGlobalBestTourLength() {
306 return env
.getGlobalBestTourLength();
309 public void setGlobalBestTourLength(int GlobalBestTourLength
) {
310 env
.setGlobalBestTourLength(GlobalBestTourLength
);
313 public int getGlobalBestTourIteration() {
314 return env
.getGlobalBestTourIteration();
317 public void setGlobalBestTourIteration(int GlobalBestTourIteration
) {
318 env
.setGlobalBestTourIteration(GlobalBestTourIteration
);