Changeset 5682
- Timestamp:
- 03/15/11 09:51:22 (14 years ago)
- Location:
- branches/SuccessProgressAnalysis
- Files:
-
- 1 added
- 1 deleted
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.csproj
r5379 r5682 116 116 <Compile Include="OffspringSelectionGeneticAlgorithmMainOperator.cs" /> 117 117 <Compile Include="Properties\AssemblyInfo.cs" /> 118 <Compile Include="Success ProgressAnalysis\SuccessProgressAnalyzer.cs" />118 <Compile Include="SuccessfulOffspringAnalysis\SuccessfulOffspringAnalyzer.cs" /> 119 119 </ItemGroup> 120 120 <ItemGroup> -
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs
r5366 r5682 249 249 [Storable] 250 250 private ValueAnalyzer selectionPressureAnalyzer; 251 [Storable] 252 private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer; 251 253 #endregion 252 254 … … 255 257 [StorableHook(HookType.AfterDeserialization)] 256 258 private void AfterDeserialization() { 259 #region Backwards Compatibility 260 if (successfulOffspringAnalyzer == null) 261 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 262 #endregion 263 257 264 Initialize(); 258 265 } … … 263 270 islandSelectionPressureAnalyzer = cloner.Clone(original.islandSelectionPressureAnalyzer); 264 271 selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer); 272 successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer); 265 273 Initialize(); 266 274 } … … 386 394 selectionPressureAnalyzer = new ValueAnalyzer(); 387 395 islandSelectionPressureAnalyzer = new ValueAnalyzer(); 396 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 388 397 ParameterizeAnalyzers(); 389 398 UpdateAnalyzers(); … … 554 563 selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History"; 555 564 565 successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results"; 566 successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations"; 567 successfulOffspringAnalyzer.SuccessfulOffspringFlag.Value.Value = "SuccessfulOffspring"; 568 successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(2); 569 556 570 if (Problem != null) { 557 571 islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 616 630 Analyzer.Operators.Add(qualityAnalyzer); 617 631 Analyzer.Operators.Add(selectionPressureAnalyzer); 632 Analyzer.Operators.Add(successfulOffspringAnalyzer); 633 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 618 634 } 619 635 private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { -
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r5366 r5682 197 197 [Storable] 198 198 private ValueAnalyzer selectionPressureAnalyzer; 199 [Storable] 200 private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer; 199 201 #endregion 200 202 … … 203 205 [StorableHook(HookType.AfterDeserialization)] 204 206 private void AfterDeserialization() { 207 #region Backwards Compatibility 208 if (successfulOffspringAnalyzer == null) 209 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 210 #endregion 211 205 212 Initialize(); 206 213 } … … 209 216 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 210 217 selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer); 218 successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer); 211 219 Initialize(); 212 220 } … … 291 299 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 292 300 selectionPressureAnalyzer = new ValueAnalyzer(); 301 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 293 302 ParameterizeAnalyzers(); 294 303 UpdateAnalyzers(); … … 407 416 selectionPressureAnalyzer.ValueParameter.Depth = 0; 408 417 selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History"; 418 successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results"; 419 successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations"; 420 successfulOffspringAnalyzer.SuccessfulOffspringFlag.Value.Value = "SuccessfulOffspring"; 421 successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(1); 409 422 if (Problem != null) { 410 423 qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 462 475 Analyzer.Operators.Add(qualityAnalyzer); 463 476 Analyzer.Operators.Add(selectionPressureAnalyzer); 477 Analyzer.Operators.Add(successfulOffspringAnalyzer); 478 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 464 479 } 465 480 private OffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { -
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs
r5366 r5682 225 225 [Storable] 226 226 private ValueAnalyzer selectionPressureAnalyzer; 227 [Storable] 228 private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer; 227 229 #endregion 228 230 … … 231 233 [StorableHook(HookType.AfterDeserialization)] 232 234 private void AfterDeserialization() { 235 #region Backwards Compatibility 236 if (successfulOffspringAnalyzer == null) 237 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 238 #endregion 239 233 240 Initialize(); 234 241 } … … 239 246 selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer); 240 247 villageSelectionPressureAnalyzer = cloner.Clone(original.villageSelectionPressureAnalyzer); 248 successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer); 241 249 Initialize(); 242 250 } … … 344 352 selectionPressureAnalyzer = new ValueAnalyzer(); 345 353 villageSelectionPressureAnalyzer = new ValueAnalyzer(); 354 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 346 355 ParameterizeAnalyzers(); 347 356 UpdateAnalyzers(); … … 492 501 selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History"; 493 502 503 successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results"; 504 successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations"; 505 successfulOffspringAnalyzer.SuccessfulOffspringFlag.Value.Value = "SuccessfulOffspring"; 506 successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(2); 507 494 508 if (Problem != null) { 495 509 villageQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 554 568 Analyzer.Operators.Add(qualityAnalyzer); 555 569 Analyzer.Operators.Add(selectionPressureAnalyzer); 570 Analyzer.Operators.Add(successfulOffspringAnalyzer); 571 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 556 572 } 557 573 private SASEGASAMainLoop FindMainLoop(IOperator start) { -
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SuccessfulOffspringAnalysis/SuccessfulOffspringAnalyzer.cs
r5674 r5682 33 33 using HeuristicLab.Analysis; 34 34 35 namespace HeuristicLab.Algorithms.OffspringSelection Algorithm.SuccessProgressAnalysis{35 namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm { 36 36 /// <summary> 37 37 /// An operator for analyzing the solution diversity in a population. 38 38 /// </summary> 39 [Item("Success ProgressAnalyzer", "An operator for analyzing the success progress in a population.")]39 [Item("SuccessfulOffspringAnalyzer", "An operator for analyzing certain properties in the successful offspring. The properties to be analyzed can be specified in the CollectedValues parameter.")] 40 40 [StorableClass] 41 public sealed class Success ProgressAnalyzer: SingleSuccessorOperator, IAnalyzer {41 public sealed class SuccessfulOffspringAnalyzer : SingleSuccessorOperator, IAnalyzer { 42 42 public ValueParameter<StringValue> SuccessfulOffspringFlag { 43 43 get { return (ValueParameter<StringValue>)Parameters["SuccessfulOffspringFlag"]; } … … 52 52 } 53 53 54 public LookupParameter<IntValue> Generations{54 public ILookupParameter<IntValue> GenerationsParameter { 55 55 get { return (LookupParameter<IntValue>)Parameters["Generations"]; } 56 } 57 58 public ValueParameter<IntValue> DepthParameter { 59 get { return (ValueParameter<IntValue>)Parameters["Depth"]; } 56 60 } 57 61 58 62 public override IDeepCloneable Clone(Cloner cloner) { 59 return new Success ProgressAnalyzer(this, cloner);63 return new SuccessfulOffspringAnalyzer(this, cloner); 60 64 } 61 65 [StorableConstructor] 62 private Success ProgressAnalyzer(bool deserializing) : base(deserializing) { }63 private Success ProgressAnalyzer(SuccessProgressAnalyzer original, Cloner cloner) : base(original, cloner) { }64 public Success ProgressAnalyzer()66 private SuccessfulOffspringAnalyzer(bool deserializing) : base(deserializing) { } 67 private SuccessfulOffspringAnalyzer(SuccessfulOffspringAnalyzer original, Cloner cloner) : base(original, cloner) { } 68 public SuccessfulOffspringAnalyzer() 65 69 : base() { 66 Parameters.Add(new ValueParameter<StringValue>("SuccessfulOffspringFlag", " Indicates if the individual was successful.", new StringValue("SuccessfulOffspring")));67 Parameters.Add(new ValueParameter<ItemCollection<StringValue>>("CollectedValues", "The valuesthat should be collected.", new ItemCollection<StringValue>()));70 Parameters.Add(new ValueParameter<StringValue>("SuccessfulOffspringFlag", "The name of the flag which indicates if the individual was successful.", new StringValue("SuccessfulOffspring"))); 71 Parameters.Add(new ValueParameter<ItemCollection<StringValue>>("CollectedValues", "The properties of the successful offspring that should be collected.", new ItemCollection<StringValue>())); 68 72 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the succedd progress analysis results should be stored.")); 69 73 Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations.")); 74 Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1))); 70 75 } 71 76 72 77 public override IOperation Apply() { 73 78 ResultCollection results = ResultsParameter.ActualValue; 74 79 80 List<IScope> scopes = new List<IScope>() { ExecutionContext.Scope }; 81 for (int i = 0; i < DepthParameter.Value.Value; i++) 82 scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b)).ToList(); 83 75 84 ItemCollection<StringValue> collectedValues = CollectedValues.Value; 76 85 foreach (StringValue collected in collectedValues) { 86 //collect the values of the successful offspring 77 87 Dictionary<String, int> counts = new Dictionary<String, int>(); 78 for (int i = 0; i < ExecutionContext.Scope.SubScopes.Count; i++) {79 IScope child = ExecutionContext.Scope.SubScopes[i];88 for (int i = 0; i < scopes.Count; i++) { 89 IScope child = scopes[i]; 80 90 string successfulOffspringFlag = SuccessfulOffspringFlag.Value.Value; 81 91 if (child.Variables.ContainsKey(collected.Value) && … … 92 102 } 93 103 104 //create a data table containing the collected values 94 105 DataTable successProgressAnalysis; 95 106 string resultKey = "Success Progress " + collected.Value; … … 111 122 if (!successProgressAnalysis.Rows.ContainsKey(value)) { 112 123 row = new DataRow(value); 113 int iterations = Generations .ActualValue.Value;124 int iterations = GenerationsParameter.ActualValue.Value; 114 125 126 //fill up all values seen the first time 115 127 for (int i = 1; i < iterations; i++) 116 128 row.Values.Add(0); … … 124 136 } 125 137 138 //fill up all values that are not present in the current generation 126 139 foreach (DataRow row in successProgressAnalysis.Rows) { 127 140 if (!counts.ContainsKey(row.Name)) -
branches/SuccessProgressAnalysis/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs
r5492 r5682 49 49 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 50 50 } 51 public ValueParameter<BoolValue> ReportExecutedOperatorParameter {52 get { return (ValueParameter<BoolValue>)Parameters[" ReportExecutedOperator"]; }51 public ValueParameter<BoolValue> TraceSelectedOperatorParameter { 52 get { return (ValueParameter<BoolValue>)Parameters["TraceSelectedOperator"]; } 53 53 } 54 public ValueLookupParameter<StringValue> ExecutedOperatorParameter {55 get { return (ValueLookupParameter<StringValue>)Parameters[" ExecutedOperator"]; }54 public ValueLookupParameter<StringValue> SelectedOperatorParameter { 55 get { return (ValueLookupParameter<StringValue>)Parameters["SelectedOperator"]; } 56 56 } 57 57 … … 64 64 private void AfterDeserializationHook() { 65 65 #region Backwards Compatibility 66 if (!Parameters.ContainsKey(" ExecutedOperator")) {67 Parameters.Add(new ValueLookupParameter<StringValue>(" ExecutedOperator", "The operator that was executed."));66 if (!Parameters.ContainsKey("SelectedOperator")) { 67 Parameters.Add(new ValueLookupParameter<StringValue>("SelectedOperator", "If the TraceSelectedOperator flag is set, the name of the operator is traced in this parameter.")); 68 68 } 69 if (!Parameters.ContainsKey(" ReportExecutedOperator")) {70 Parameters.Add(new ValueParameter<BoolValue>(" ReportExecutedOperator", "Report the executed operator", new BoolValue(false)));69 if (!Parameters.ContainsKey("TraceSelectedOperator")) { 70 Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false))); 71 71 } 72 72 #endregion … … 86 86 Parameters.Add(new ValueLookupParameter<DoubleArray>("Probabilities", "The array of relative probabilities for each operator.", new DoubleArray())); 87 87 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 88 Parameters.Add(new ValueLookupParameter<StringValue>(" ExecutedOperator", "The operator that was executed."));89 Parameters.Add(new ValueParameter<BoolValue>(" ReportExecutedOperator", "Report the executed operator", new BoolValue(false)));88 Parameters.Add(new ValueLookupParameter<StringValue>("SelectedOperator", "If the TraceSelectedOperator flag is set, the name of the operator is traced in this parameter.")); 89 Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false))); 90 90 } 91 91 … … 136 136 } 137 137 IOperator successor = null; 138 int index = -1; 138 139 var checkedOperators = Operators.CheckedItems; 139 140 if (checkedOperators.Count() > 0) { … … 147 148 if (sum > r) { 148 149 successor = indexedItem.Value; 150 index = indexedItem.Index; 149 151 break; 150 152 } … … 153 155 OperationCollection next = new OperationCollection(base.Apply()); 154 156 if (successor != null) { 155 if (ReportExecutedOperatorParameter.Value.Value)156 ExecutedOperatorParameter.ActualValue = new StringValue(successor.Name);157 if (TraceSelectedOperatorParameter.Value.Value) 158 SelectedOperatorParameter.ActualValue = new StringValue(index + ": " + successor.Name); 157 159 158 160 if (CreateChildOperation) … … 160 162 else next.Insert(0, ExecutionContext.CreateOperation(successor)); 161 163 } else { 162 if ( ReportExecutedOperatorParameter.Value.Value)163 ExecutedOperatorParameter.ActualValue = new StringValue("");164 if (TraceSelectedOperatorParameter.Value.Value) 165 SelectedOperatorParameter.ActualValue = new StringValue(""); 164 166 } 165 167 return next; -
branches/SuccessProgressAnalysis/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
r5493 r5682 156 156 OperationCollection next = new OperationCollection(successorOp); 157 157 if (successor != null) { 158 ExecutedOperatorParameter.ActualValue = new StringValue(successor.GetType().Name);158 SelectedOperatorParameter.ActualValue = new StringValue(successor.GetType().Name); 159 159 160 160 if (CreateChildOperation) … … 162 162 else next.Insert(0, ExecutionContext.CreateOperation(successor)); 163 163 } else { 164 ExecutedOperatorParameter.ActualValue = new StringValue("");164 SelectedOperatorParameter.ActualValue = new StringValue(""); 165 165 } 166 166 -
branches/SuccessProgressAnalysis/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
r5493 r5682 156 156 OperationCollection next = new OperationCollection(successorOp); 157 157 if (successor != null) { 158 ExecutedOperatorParameter.ActualValue = new StringValue(successor.GetType().Name);158 SelectedOperatorParameter.ActualValue = new StringValue(successor.GetType().Name); 159 159 160 160 if (CreateChildOperation) … … 162 162 else next.Insert(0, ExecutionContext.CreateOperation(successor)); 163 163 } else { 164 ExecutedOperatorParameter.ActualValue = new StringValue("");164 SelectedOperatorParameter.ActualValue = new StringValue(""); 165 165 } 166 166
Note: See TracChangeset
for help on using the changeset viewer.