replace the observer pattern with a simple update function
[aco.git] / protoas / ChoiceInformation.java
blobdd0c553566482919ac4291e46157c597e805c6b5
1 package protoas;
3 class ChoiceInformation {
5 protected Graph graph;
6 protected double[][] ChoiceInformation;
8 ChoiceInformation(Graph graph) {
9 this.graph = graph;
10 ChoiceInformation = new double[graph.getNumOfCities()][graph.getNumOfCities()];
12 for (int i = 0; i < graph.getNumOfCities(); i++) {
13 for (int j = 0; j < graph.getNumOfCities(); j++) {
14 setChoiceInformation(i,j, 0);
19 public void computeChoiceInformation() {
20 for (int i = 0; i < graph.getNumOfCities(); i++) {
21 for (int j = 0; j < graph.getNumOfCities(); j++) {
22 setChoiceInformation(i,j,
23 Math.pow( graph.getPheromone(i,j), graph.getALPHA() ) *
24 Math.pow( (1.0/(double)graph.getDistance(i,j)), graph.getBETA() ));
29 public double[][] getChoiceInformation() {
30 return this.ChoiceInformation;
33 public double getChoiceInformation(int x, int y) {
34 return this.ChoiceInformation[x][y];
37 public void setChoiceInformation(double[][] ChoiceInformation) {
38 this.ChoiceInformation = ChoiceInformation;
41 public void setChoiceInformation(int x, int y, double ChoiceInformation) {
42 this.ChoiceInformation[x][y] = ChoiceInformation;