a method for setting the initial pheromone value
[aco.git] / aco / mediator / ACOMediator.java
blob3bd611baf061c555c80950addb60ac00eb59aee1
1 package aco.mediator;
3 import java.util.HashMap;
4 import java.util.SortedMap;
6 import aco.ant.*;
7 import aco.misc.*;
8 import aco.graph.*;
9 import aco.strategy.*;
10 import aco.parameter.*;
11 import aco.environment.*;
13 public class ACOMediator {
15 protected ACOGraph acog;
16 protected ACOParameter acop;
17 protected Environment env;
19 public ACOMediator() {
20 this.acog = null;
21 this.acop = null;
22 this.env = null;
25 public ACOMediator(ACOParameter acop) {
26 this.acog = null;
27 this.acop = acop;
28 this.env = null;
31 public ACOMediator(ACOGraph acog, ACOParameter acop) {
32 this.acog = acog;
33 this.acop = acop;
34 this.env = null;
37 public ACOMediator(ACOGraph acog, ACOParameter acop, Environment env) {
38 this.acog = acog;
39 this.acop = acop;
40 this.env = env;
43 public ACOGraph getACOGraph() {
44 return acog;
47 public void setACOGraph(ACOGraph acog) {
48 this.acog = acog;
51 public ACOParameter getACOParameter() {
52 return acop;
55 public void setACOParameter(ACOParameter acop) {
56 this.acop = acop;
59 public Environment getEnvironment() {
60 return env;
63 public void setEnvironment(Environment env) {
64 this.env = env;
67 public ACOStrategy getACOStrategy() {
68 return acop.getACOStrategy();
71 public void setACOStrategy(ACOStrategy acos) {
72 acop.setACOStrategy(acos);
75 public GraphStrategy getGraphStrategy() {
76 return acop.getGraphStrategy();
79 public void setGraphStrategy(GraphStrategy gs) {
80 acop.setGraphStrategy(gs);
83 public TauZeroStrategy getTauZeroStrategy() {
84 return acop.getTauZeroStrategy();
87 public void setTauZeroStrategy(TauZeroStrategy tzs) {
88 acop.setTauZeroStrategy(tzs);
91 public DistanceStrategy getDistanceStrategy() {
92 return acop.getDistanceStrategy();
95 public void setDistanceStrategy(DistanceStrategy ds) {
96 acop.setDistanceStrategy(ds);
99 public PheromoneStrategy getPheromoneStrategy() {
100 return acop.getPheromoneStrategy();
103 public void setPheromoneStrategy(PheromoneStrategy ps) {
104 acop.setPheromoneStrategy(ps);
107 public ChoiceInformationStrategy getChoiceInformationStrategy() {
108 return acop.getChoiceInformationStrategy();
111 public void setChoiceInformationStrategy(ChoiceInformationStrategy cis) {
112 acop.setChoiceInformationStrategy(cis);
115 public HeuristicInformationStrategy getHeuristicInformationStrategy() {
116 return acop.getHeuristicInformationStrategy();
119 public void setHeuristicInformationStrategy(HeuristicInformationStrategy his) {
120 acop.setHeuristicInformationStrategy(his);
123 public int getInfinity() {
124 return acop.getInfinity();
127 public double getAlpha() {
128 if (acop instanceof ASParameter)
129 return ((ASParameter)acop).getAlpha();
130 else if (acop instanceof EASParameter)
131 return ((EASParameter)acop).getAlpha();
132 else if (acop instanceof ASRankParameter)
133 return ((ASRankParameter)acop).getAlpha();
134 else
135 return 0.0;
138 public void setAlpha(double Alpha) {
139 if (acop instanceof ASParameter)
140 ((ASParameter)acop).setAlpha(Alpha);
141 else if (acop instanceof EASParameter)
142 ((EASParameter)acop).setAlpha(Alpha);
143 else if (acop instanceof ASRankParameter)
144 ((ASRankParameter)acop).setAlpha(Alpha);
147 public double getBeta() {
148 return acop.getBeta();
151 public void setBeta(double Beta) {
152 acop.setBeta(Beta);
155 public double getRoh() {
156 return acop.getRoh();
159 public void setRoh(double Roh) {
160 acop.setRoh(Roh);
163 public double getTauZero() {
164 return acop.getTauZero();
167 public void setTauZero(double TauZero) {
168 acop.setTauZero(TauZero);
171 public int getMaxNumOfTours() {
172 return acop.getMaxNumOfTours();
175 public void setMaxNumOfTours(int v) {
176 acop.setMaxNumOfTours(v);
179 public int getNumOfAnts() {
180 return acop.getNumOfAnts();
183 public void setNumOfAnts(int v) {
184 acop.setNumOfAnts(v);
187 public int getNumOfCities() {
188 return acop.getNumOfCities();
191 public void setNumOfCities(int v) {
192 acop.setNumOfCities(v);
195 public int getNearestNeighbourListDepth() {
196 return acop.getNearestNeighbourListDepth();
199 public void setNearestNeighbourListDepth(int NearestNeighbourListDepth) {
200 acop.setNearestNeighbourListDepth(NearestNeighbourListDepth);
203 public int getNearestNeighbour(int x, int y) {
204 return acog.getNearestNeighbour(x, y);
207 public int getDistance(int x, int y) {
208 return acog.getDistance(x, y);
211 public void setDistance(int x, int y, int v) {
212 acog.setDistance(x, y, v);
215 public CoordinatePair<Integer, Integer> getCoordinates(int City) {
216 return acog.getCoordinates(City);
219 public HashMap<Integer, CoordinatePair<Integer, Integer>> getCoordinateData() {
220 return acog.getCoordinateData();
223 public double getPheromone(int x, int y) {
224 return acog.getPheromone(x, y);
227 public void setPheromone(int x, int y, double v) {
228 acog.setPheromone(x, y, v);
231 public double getChoiceInformation(int x, int y) {
232 return acog.getChoiceInformation(x, y);
235 public void setChoiceInformation(int x, int y, double v) {
236 acog.setChoiceInformation(x, y, v);
239 public double getHeuristicInformation(int x, int y) {
240 return acog.getHeuristicInformation(x, y);
243 public void setHeuristicInformation(int x, int y, double v) {
244 acog.setHeuristicInformation(x, y, v);
247 public void computeTauZero() {
248 acop.getTauZeroStrategy().computeTauZero();
251 public void computeChoiceInformation() {
252 acop.getChoiceInformationStrategy().computeChoiceInformation();
255 public void computeHeuristicInformation() {
256 acop.getHeuristicInformationStrategy().computeHeuristicInformation();
259 public void computeNearestNeighbourListDepth() {
260 acop.getGraphStrategy().computeNearestNeighbourListDepth();
263 public int[][] computeDistances() {
264 return acop.getDistanceStrategy().computeDistances();
267 public void setInitialPheromones(double TauZero) {
268 acop.getPheromoneStrategy().setInitialPheromones(TauZero);
271 public int nearestNeighbourHeuristicRandomStart() {
272 return acop.getGraphStrategy().nearestNeighbourHeuristicRandomStart();
275 public void pheromoneUpdate(Ant[] ants) {
276 acop.getPheromoneStrategy().pheromoneUpdate(ants);
279 public void computeTourLength(Ant ant) {
280 acop.getACOStrategy().computeTourLength(ant);
283 public void pickInitialRandomCity(Ant ant) {
284 acop.getACOStrategy().pickInitialRandomCity(ant);
287 public void neighbourListASDecisionRule(Ant ant, int Step) {
288 acop.getACOStrategy().neighbourListASDecisionRule(ant, Step);
291 public int getGlobalBestTourMapSize() {
292 return acop.getGlobalBestTourMapSize();
295 public void setGlobalBestTourMapSize(int GlobalBestTourMapSize) {
296 acop.setGlobalBestTourMapSize(GlobalBestTourMapSize);
299 public SortedMap<Integer, int[]> getGlobalBestTourMap() {
300 return env.getGlobalBestTourMap();
303 public void addGlobalBestTour(Integer TourLength, int[] Tour) {
304 env.addGlobalBestTour(TourLength, Tour);
307 public int[] getGlobalBestTour() {
308 return env.getGlobalBestTour();
311 public int getGlobalBestTour(int index) {
312 return env.getGlobalBestTour(index);
315 public void setGlobalBestTour(int[] GlobalBestTour) {
316 env.setGlobalBestTour(GlobalBestTour);
319 public void setGlobalBestTour(int index, int GlobalBestTour) {
320 env.setGlobalBestTour(index, GlobalBestTour);
323 public int getGlobalBestTourLength() {
324 return env.getGlobalBestTourLength();
327 public void setGlobalBestTourLength(int GlobalBestTourLength) {
328 env.setGlobalBestTourLength(GlobalBestTourLength);
331 public int getGlobalBestTourIteration() {
332 return env.getGlobalBestTourIteration();
335 public void setGlobalBestTourIteration(int GlobalBestTourIteration) {
336 env.setGlobalBestTourIteration(GlobalBestTourIteration);