- Timestamp:
- 04/13/15 17:43:28 (10 years ago)
- Location:
- branches/PTSP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PTSP/HeuristicLab.Problems.PTSP.Views/3.3/PathPTSPTourView.cs
r12269 r12306 120 120 } 121 121 for (int i = 0; i < points.Length; i++) 122 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, Convert.ToInt32(probabilities[i] * 10), Convert.ToInt32(probabilities[i] * 10));122 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, Convert.ToInt32(probabilities[i] * 20), Convert.ToInt32(probabilities[i] * 20)); 123 123 } 124 124 } else { -
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/AnalyticalPTSP.cs
r12269 r12306 19 19 [StorableClass] 20 20 public sealed class AnalyticalProbabilisticTravelingSalesmanProblem : ProbabilisticTravelingSalesmanProblem, IStorableContent, 21 IProblemInstanceConsumer< TSPData> {21 IProblemInstanceConsumer<PTSPData> { 22 22 23 23 [StorableConstructor] … … 137 137 } 138 138 139 public override void Load( TSPData data) {139 public override void Load(PTSPData data) { 140 140 base.Load(data); 141 141 foreach (var op in Operators.OfType<PTSPAnalyticalInversionMovePathEvaluator>()) { -
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/EstimatedPTSP.cs
r12272 r12306 19 19 [StorableClass] 20 20 public sealed class EstimatedProbabilisticTravelingSalesmanProblem : ProbabilisticTravelingSalesmanProblem, IStorableContent, 21 IProblemInstanceConsumer< TSPData> {21 IProblemInstanceConsumer<PTSPData> { 22 22 23 private ItemList<ItemList<IntValue>> realizations; 23 24 #region Parameter Properties 25 public IValueParameter<ItemList<ItemList<IntValue>>> RealizationsParameter { 26 get { return (IValueParameter<ItemList<ItemList<IntValue>>>)Parameters["Realizations"]; } 27 } 28 #endregion 29 30 #region Properties 31 public ItemList<ItemList<IntValue>> Realizations { 32 get { return RealizationsParameter.Value; } 33 set { RealizationsParameter.Value = value; } 34 } 35 #endregion 24 36 25 37 [StorableConstructor] … … 38 50 MersenneTwister r = new MersenneTwister(); 39 51 double estimatedSum = 0; 40 for (int i = 0; i < realizations.Count; i++) {52 for (int i = 0; i < Realizations.Count; i++) { 41 53 int singleRealization = -1, firstNode = -1; 42 for (int j = 0; j < realizations[i].Count; j++) {43 if ( realizations[i][p[j]].Value == 1) {54 for (int j = 0; j < Realizations[i].Count; j++) { 55 if (Realizations[i][p[j]].Value == 1) { 44 56 if (singleRealization != -1) { 45 57 estimatedSum += DistanceMatrix[singleRealization, p[j]]; … … 54 66 } 55 67 } 56 return estimatedSum / SampleSize.Value;68 return estimatedSum / RealizationsSize.Value; 57 69 } 58 70 … … 90 102 91 103 public EstimatedProbabilisticTravelingSalesmanProblem() { 92 Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Size of the sample for the estimation-based evaluation")); 104 Parameters.Add(new ValueParameter<IntValue>("RealizationsSize", "Size of the sample for the estimation-based evaluation")); 105 Parameters.Add(new ValueParameter<ItemList<ItemList<IntValue>>>("Realizations", "The concrete...")); 93 106 Operators.Add(new PTSPEstimatedInversionMovePathEvaluator()); 94 107 Operators.Add(new PTSPEstimatedInsertionEvaluator()); … … 134 147 } 135 148 136 public override void Load( TSPData data) {149 public override void Load(PTSPData data) { 137 150 base.Load(data); 138 151 // For now uses sample size of 20 but should use Student's t-test 139 152 //Ttest(data.Dimension); 140 SampleSize = new IntValue(100);153 RealizationsSize = new IntValue(100); 141 154 MersenneTwister r = new MersenneTwister(); 142 155 int countOnes = 0; 143 realizations = new ItemList<ItemList<IntValue>>(SampleSize.Value);144 for (int i = 0; i < SampleSize.Value; i++) {156 Realizations = new ItemList<ItemList<IntValue>>(RealizationsSize.Value); 157 for (int i = 0; i < RealizationsSize.Value; i++) { 145 158 ItemList<IntValue> newRealization = new ItemList<IntValue>(); 146 159 while (countOnes < 4) { //only generate realizations with at least 4 cities visited … … 157 170 } 158 171 countOnes = 0; 159 realizations.Add(newRealization);172 Realizations.Add(newRealization); 160 173 } 161 174 162 175 foreach (var op in Operators.OfType<PTSPPathMoveEvaluator>()) { 163 op.RealizationsParameter.Value = realizations;176 op.RealizationsParameter.Value = Realizations; 164 177 } 165 178 foreach (var op in Operators.OfType<PTSPExhaustiveInversionLocalImprovement>()) { 166 op.RealizationsParameter.Value = realizations;179 op.RealizationsParameter.Value = Realizations; 167 180 } 168 181 foreach (var op in Operators.OfType<PTSP25MoveEvaluator>()) { 169 op.RealizationsParameter.Value = realizations;182 op.RealizationsParameter.Value = Realizations; 170 183 } 171 184 -
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/PTSP.cs
r12261 r12306 40 40 [StorableClass] 41 41 public abstract class ProbabilisticTravelingSalesmanProblem : SingleObjectiveBasicProblem<PermutationEncoding>, IStorableContent, 42 IProblemInstanceConsumer< TSPData> {42 IProblemInstanceConsumer<PTSPData> { 43 43 private static readonly int DistanceMatrixSizeLimit = 1000; 44 44 … … 59 59 get { return (ValueParameter<DoubleArray>)Parameters["ProbabilityMatrix"]; } 60 60 } 61 public ValueParameter<IntValue> SampleSizeParameter {62 get { return (ValueParameter<IntValue>)Parameters[" SampleSize"]; }61 public ValueParameter<IntValue> RealizationsSizeParameter { 62 get { return (ValueParameter<IntValue>)Parameters["RealizationsSize"]; } 63 63 } 64 64 … … 86 86 set { ProbabilityMatrixParameter.Value = value; } 87 87 } 88 public IntValue SampleSize {89 get { return SampleSizeParameter.Value; }90 set { SampleSizeParameter.Value = value; }88 public IntValue RealizationsSize { 89 get { return RealizationsSizeParameter.Value; } 90 set { RealizationsSizeParameter.Value = value; } 91 91 } 92 92 #endregion … … 121 121 } 122 122 123 public virtual void Load( TSPData data) {123 public virtual void Load(PTSPData data) { 124 124 if (data.Coordinates == null && data.Distances == null) 125 125 throw new System.IO.InvalidDataException("The given instance specifies neither coordinates nor distances!"); … … 134 134 Description = data.Description; 135 135 136 // Get Probabilities of cities using random with seed from hash function on the Name of the instance 137 double[] tempMatrix = new double[data.Dimension]; 138 MersenneTwister r = new MersenneTwister((uint)data.Name.GetHashCode()); 139 for (int i = 0; i < data.Dimension; i++) { 140 tempMatrix[i] = r.NextDouble(); 141 } 142 ProbabilityMatrix = new DoubleArray(tempMatrix); 136 ProbabilityMatrix = new DoubleArray(data.Probabilities); 143 137 144 138 if (data.BestKnownTour != null) {
Note: See TracChangeset
for help on using the changeset viewer.