Changeset 12387
- Timestamp:
- 05/09/15 17:26:10 (10 years ago)
- Location:
- branches/PTSP/HeuristicLab.Problems.PTSP/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/EstimatedPTSP.cs
r12380 r12387 23 23 24 24 #region Parameter Properties 25 public IValueParameter<ItemList<ItemList<IntValue>>> RealizationsParameter {26 get { return ( IValueParameter<ItemList<ItemList<IntValue>>>)Parameters["Realizations"]; }25 public ValueParameter<ItemList<ItemList<IntValue>>> RealizationsParameter { 26 get { return (ValueParameter<ItemList<ItemList<IntValue>>>)Parameters["Realizations"]; } 27 27 } 28 public ValueParameter<IntValue> RealizationsSizeParameter { 29 get { return (ValueParameter<IntValue>)Parameters["RealizationsSize"]; } 30 } 31 28 32 #endregion 29 33 … … 33 37 set { RealizationsParameter.Value = value; } 34 38 } 39 40 public IntValue RealizationsSize { 41 get { return RealizationsSizeParameter.Value; } 42 set { RealizationsSizeParameter.Value = value; } 43 } 35 44 #endregion 36 45 … … 39 48 private EstimatedProbabilisticTravelingSalesmanProblem(EstimatedProbabilisticTravelingSalesmanProblem original, Cloner cloner) 40 49 : base(original, cloner) { 50 RegisterEventHandlers(); 51 } 52 public EstimatedProbabilisticTravelingSalesmanProblem() { 53 Parameters.Add(new ValueParameter<IntValue>("RealizationsSize", "Size of the sample for the estimation-based evaluation")); 54 Parameters.Add(new ValueParameter<ItemList<ItemList<IntValue>>>("Realizations", "The concrete...")); 55 Operators.Add(new PTSPEstimatedInversionEvaluator()); 56 Operators.Add(new PTSPEstimatedInsertionEvaluator()); 57 Operators.Add(new PTSPExhaustiveInversionLocalImprovement()); 58 Operators.Add(new PTSPExhaustiveInsertionLocalImprovement()); 59 60 Operators.Add(new Exhaustive25MoveGenerator()); 61 Operators.Add(new Stochastic25MultiMoveGenerator()); 62 Operators.Add(new Stochastic25SingleMoveGenerator()); 63 Operators.Add(new TwoPointFiveMoveMaker()); 64 Operators.Add(new PTSP25MoveEvaluator()); 65 66 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); 67 foreach (var twopointfiveMoveOperator in Operators.OfType<I25MoveOperator>()) { 68 twopointfiveMoveOperator.TwoPointFiveMoveParameter.ActualName = "Permutation.TwoPointFiveMove"; 69 } 70 RealizationsSize = new IntValue(100); 71 RegisterEventHandlers(); 41 72 } 42 73 … … 101 132 } 102 133 103 public EstimatedProbabilisticTravelingSalesmanProblem() { 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...")); 106 Operators.Add(new PTSPEstimatedInversionEvaluator()); 107 Operators.Add(new PTSPEstimatedInsertionEvaluator()); 108 Operators.Add(new PTSPExhaustiveInversionLocalImprovement()); 109 Operators.Add(new PTSPExhaustiveInsertionLocalImprovement()); 134 110 135 111 Operators.Add(new Exhaustive25MoveGenerator()); 112 Operators.Add(new Stochastic25MultiMoveGenerator()); 113 Operators.Add(new Stochastic25SingleMoveGenerator()); 114 Operators.Add(new TwoPointFiveMoveMaker()); 115 Operators.Add(new PTSP25MoveEvaluator()); 116 117 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); 118 foreach (var twopointfiveMoveOperator in Operators.OfType<I25MoveOperator>()) { 119 twopointfiveMoveOperator.TwoPointFiveMoveParameter.ActualName = "Permutation.TwoPointFiveMove"; 120 } 136 private void RegisterEventHandlers() { 137 //RealizationsSizeParameter.ValueChanged += new EventHandler(RealizationsSizeParameter_ValueChanged); 138 RealizationsSize.ValueChanged += new EventHandler(RealizationsSizeParameter_ValueChanged); 139 //RealizationsSizeParameter.Value.ValueChanged += new EventHandler(RealizationsSizeParameter_ValueChanged); 121 140 } 122 141 123 public override void Load(PTSPData data) { 124 base.Load(data); 125 RealizationsSize = new IntValue(100); 142 private void RealizationsSizeParameter_ValueChanged(object sender, EventArgs e) { 143 UpdateRealizations(); 144 } 145 146 private void UpdateRealizations() { 126 147 MersenneTwister r = new MersenneTwister(); 127 128 // TODO : This should be made in another function and attached to a listener129 148 int countOnes = 0; 130 149 Realizations = new ItemList<ItemList<IntValue>>(RealizationsSize.Value); … … 134 153 countOnes = 0; 135 154 newRealization.Clear(); 136 for (int j = 0; j < data.Dimension; j++) {155 for (int j = 0; j < DistanceMatrix.Rows; j++) { 137 156 if (ProbabilityMatrix[j] > r.NextDouble()) { 138 157 newRealization.Add(new IntValue(1)); … … 146 165 Realizations.Add(newRealization); 147 166 } 167 } 168 169 public override void Load(PTSPData data) { 170 base.Load(data); 171 UpdateRealizations(); 148 172 149 173 foreach (var op in Operators.OfType<PTSPMoveEvaluator>()) { -
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/PTSP.cs
r12306 r12387 59 59 get { return (ValueParameter<DoubleArray>)Parameters["ProbabilityMatrix"]; } 60 60 } 61 public ValueParameter<IntValue> RealizationsSizeParameter { 62 get { return (ValueParameter<IntValue>)Parameters["RealizationsSize"]; } 63 } 61 64 62 65 63 #endregion … … 86 84 set { ProbabilityMatrixParameter.Value = value; } 87 85 } 88 public IntValue RealizationsSize { 89 get { return RealizationsSizeParameter.Value; } 90 set { RealizationsSizeParameter.Value = value; } 91 } 86 92 87 #endregion 93 88
Note: See TracChangeset
for help on using the changeset viewer.