From 67929c69ccc3a920b029ea2c831d0b2a6c617dc9 Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Tue, 29 Jun 2010 21:49:07 +0200 Subject: [PATCH] getter/setter methods for EAS, ASRank and ACS Parameters initial version of subclassed Parameter files --- aco/mediator/ACOMediator.java | 24 +++++++++ aco/parameter/ACSParameter.java | 40 ++++++++++++++ aco/parameter/ASRankParameter.java | 106 +++++++++++++++++++++++++++++++++++++ aco/parameter/EASParameter.java | 106 +++++++++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+) create mode 100644 aco/parameter/ACSParameter.java create mode 100644 aco/parameter/ASRankParameter.java create mode 100644 aco/parameter/EASParameter.java diff --git a/aco/mediator/ACOMediator.java b/aco/mediator/ACOMediator.java index 3bd611b..40abbb6 100644 --- a/aco/mediator/ACOMediator.java +++ b/aco/mediator/ACOMediator.java @@ -144,6 +144,30 @@ public class ACOMediator { ((ASRankParameter)acop).setAlpha(Alpha); } + public double getE() { + return ((EASParameter) acop).getE(); + } + + public void setE(double E) { + ((EASParameter) acop).setE(E); + } + + public double getW() { + return ((ASRankParameter) acop).getW(); + } + + public void setW(double W) { + ((ASRankParameter) acop).setW(W); + } + + public double getQZero(){ + return ((ACSParameter)acop).getQZero(); + } + + public void setQZero(double QZero){ + ((ACSParameter)acop).setQZero(QZero); + } + public double getBeta() { return acop.getBeta(); } diff --git a/aco/parameter/ACSParameter.java b/aco/parameter/ACSParameter.java new file mode 100644 index 0000000..9f76fde --- /dev/null +++ b/aco/parameter/ACSParameter.java @@ -0,0 +1,40 @@ +package aco.parameter; + +public class ACSParameter extends ACOParameter { + + protected double qZero; + + public ACSParameter() { + super(); + } + + public double getQZero() { + return this.qZero; + } + + public void setQZero(double qZero){ + this.qZero = qZero; + } + + public double getAlpha() { + return 1; + } + + public void setAlpha(double Alpha) { } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("Roh: " + Roh + "\n"); + result.append("Beta: " + Beta + "\n"); + result.append("QZero: " + qZero + "\n"); + result.append("TauZero: " + TauZero + "\n"); + result.append("NumOfAnts: " + NumOfAnts + "\n"); + result.append("NumOfCities: " + NumOfCities + "\n"); + result.append("MaxNumOfTours: " + MaxNumOfTours + "\n"); + result.append("NearestNeighbourListDepth: " + NearestNeighbourListDepth + "\n"); + + return result.toString(); + } + +} diff --git a/aco/parameter/ASRankParameter.java b/aco/parameter/ASRankParameter.java new file mode 100644 index 0000000..65c9aab --- /dev/null +++ b/aco/parameter/ASRankParameter.java @@ -0,0 +1,106 @@ +package aco.parameter; + +import aco.strategy.*; + +public class ASRankParameter + extends ACOParameter { + + protected double Alpha; + protected double W; + + public ASRankParameter() { + super(); + } + + public ASRankParameter( + int NumOfCities, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + super(5.0, 0.5, 0.0001, + 0, NumOfCities, NumOfCities, NumOfCities, + acos, gs, tzs, ds, ps, cis, his); + } + + public ASRankParameter( + int NumOfAnts, int NumOfCities, int NearestNeighbourListDepth, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + super(5.0, 0.5, 0.0001, + 0, NumOfAnts, NumOfCities, NearestNeighbourListDepth, + acos, gs, tzs, ds, ps, cis, his); + } + + public ASRankParameter( + double Alpha, double Beta, double Roh, double TauZero, + int MaxNumOfTours, int NumOfAnts, int NumOfCities, + int NearestNeighbourListDepth, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + + this.Alpha = Alpha; + this.Beta = Beta; + this.Roh = Roh; + this.TauZero = TauZero; + + this.MaxNumOfTours = 0; + this.NumOfAnts = NumOfAnts; + this.NumOfCities = NumOfCities; + this.NearestNeighbourListDepth = NearestNeighbourListDepth; + + this.acos = acos; + this.gs = gs; + this.tzs = tzs; + this.ds = ds; + this.ps = ps; + this.cis = cis; + this.his = his; + } + + public double getAlpha() { + return this.Alpha; + } + + public void setAlpha(double Alpha) { + this.Alpha = Alpha; + } + + public double getW() { + return this.W; + } + + public void setW(double W) { + this.W = W; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("Alpha: " + Alpha + "\n"); + result.append("Beta: " + Beta + "\n"); + result.append("Roh: " + Roh + "\n"); + result.append("W: " + W + "\n"); + result.append("TauZero: " + TauZero + "\n"); + result.append("NumOfAnts: " + NumOfAnts + "\n"); + result.append("NumOfCities: " + NumOfCities + "\n"); + result.append("MaxNumOfTours: " + MaxNumOfTours + "\n"); + result.append("NearestNeighbourListDepth: " + NearestNeighbourListDepth + "\n"); + + return result.toString(); + } + +} diff --git a/aco/parameter/EASParameter.java b/aco/parameter/EASParameter.java new file mode 100644 index 0000000..baecc84 --- /dev/null +++ b/aco/parameter/EASParameter.java @@ -0,0 +1,106 @@ +package aco.parameter; + +import aco.strategy.*; + +public class EASParameter + extends ACOParameter { + + protected double Alpha; + protected double E; + + public EASParameter() { + super(); + } + + public EASParameter( + int NumOfCities, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + super(5.0, 0.5, 0.0001, + 0, NumOfCities, NumOfCities, NumOfCities, + acos, gs, tzs, ds, ps, cis, his); + } + + public EASParameter( + int NumOfAnts, int NumOfCities, int NearestNeighbourListDepth, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + super(5.0, 0.5, 0.0001, + 0, NumOfAnts, NumOfCities, NearestNeighbourListDepth, + acos, gs, tzs, ds, ps, cis, his); + } + + public EASParameter( + double Alpha, double Beta, double Roh, double TauZero, + int MaxNumOfTours, int NumOfAnts, int NumOfCities, + int NearestNeighbourListDepth, + ACOStrategy acos, + GraphStrategy gs, + TauZeroStrategy tzs, + DistanceStrategy ds, + PheromoneStrategy ps, + ChoiceInformationStrategy cis, + HeuristicInformationStrategy his) { + + this.Alpha = Alpha; + this.Beta = Beta; + this.Roh = Roh; + this.TauZero = TauZero; + + this.MaxNumOfTours = 0; + this.NumOfAnts = NumOfAnts; + this.NumOfCities = NumOfCities; + this.NearestNeighbourListDepth = NearestNeighbourListDepth; + + this.acos = acos; + this.gs = gs; + this.tzs = tzs; + this.ds = ds; + this.ps = ps; + this.cis = cis; + this.his = his; + } + + public double getAlpha() { + return this.Alpha; + } + + public void setAlpha(double Alpha) { + this.Alpha = Alpha; + } + + public double getE() { + return this.E; + } + + public void setE(double E) { + this.E = E; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("Alpha: " + Alpha + "\n"); + result.append("Beta: " + Beta + "\n"); + result.append("Roh: " + Roh + "\n"); + result.append("E: " + E + "\n"); + result.append("TauZero: " + TauZero + "\n"); + result.append("NumOfAnts: " + NumOfAnts + "\n"); + result.append("NumOfCities: " + NumOfCities + "\n"); + result.append("MaxNumOfTours: " + MaxNumOfTours + "\n"); + result.append("NearestNeighbourListDepth: " + NearestNeighbourListDepth + "\n"); + + return result.toString(); + } + +} -- 2.11.4.GIT