Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5683


Ignore:
Timestamp:
03/15/11 10:55:15 (14 years ago)
Author:
svonolfe
Message:

Integrated successful offspring analysis into trunk (#1392)

Location:
trunk/sources
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.csproj

    r5163 r5683  
    1212    <AssemblyName>HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    115116    <Compile Include="OffspringSelectionGeneticAlgorithmMainOperator.cs" />
    116117    <Compile Include="Properties\AssemblyInfo.cs" />
     118    <Compile Include="SuccessfulOffspringAnalysis\SuccessfulOffspringAnalyzer.cs" />
    117119  </ItemGroup>
    118120  <ItemGroup>
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs

    r5445 r5683  
    249249    [Storable]
    250250    private ValueAnalyzer selectionPressureAnalyzer;
     251    [Storable]
     252    private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer;
    251253    #endregion
    252254
     
    255257    [StorableHook(HookType.AfterDeserialization)]
    256258    private void AfterDeserialization() {
     259      #region Backwards Compatibility
     260      if (successfulOffspringAnalyzer == null)
     261        successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
     262      #endregion
     263     
    257264      Initialize();
    258265    }
     
    263270      islandSelectionPressureAnalyzer = cloner.Clone(original.islandSelectionPressureAnalyzer);
    264271      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
     272      successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
    265273      Initialize();
    266274    }
     
    386394      selectionPressureAnalyzer = new ValueAnalyzer();
    387395      islandSelectionPressureAnalyzer = new ValueAnalyzer();
     396      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
    388397      ParameterizeAnalyzers();
    389398      UpdateAnalyzers();
     
    554563      selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
    555564
     565      successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results";
     566      successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations";
     567      successfulOffspringAnalyzer.SuccessfulOffspringFlag.Value.Value = "SuccessfulOffspring";
     568      successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(2);
     569
    556570      if (Problem != null) {
    557571        islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    616630      Analyzer.Operators.Add(qualityAnalyzer);
    617631      Analyzer.Operators.Add(selectionPressureAnalyzer);
     632      Analyzer.Operators.Add(successfulOffspringAnalyzer);
     633      Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false);
    618634    }
    619635    private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs

    r5445 r5683  
    197197    [Storable]
    198198    private ValueAnalyzer selectionPressureAnalyzer;
     199    [Storable]
     200    private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer;
    199201    #endregion
    200202
     
    203205    [StorableHook(HookType.AfterDeserialization)]
    204206    private void AfterDeserialization() {
     207      #region Backwards Compatibility
     208      if (successfulOffspringAnalyzer == null)
     209        successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
     210      #endregion
     211     
    205212      Initialize();
    206213    }
     
    209216      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    210217      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
     218      successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
    211219      Initialize();
    212220    }
     
    291299      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    292300      selectionPressureAnalyzer = new ValueAnalyzer();
     301      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
    293302      ParameterizeAnalyzers();
    294303      UpdateAnalyzers();
     
    407416      selectionPressureAnalyzer.ValueParameter.Depth = 0;
    408417      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);
    409422      if (Problem != null) {
    410423        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    462475      Analyzer.Operators.Add(qualityAnalyzer);
    463476      Analyzer.Operators.Add(selectionPressureAnalyzer);
     477      Analyzer.Operators.Add(successfulOffspringAnalyzer);
     478      Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false);
    464479    }
    465480    private OffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs

    r5445 r5683  
    225225    [Storable]
    226226    private ValueAnalyzer selectionPressureAnalyzer;
     227    [Storable]
     228    private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer;
    227229    #endregion
    228230
     
    231233    [StorableHook(HookType.AfterDeserialization)]
    232234    private void AfterDeserialization() {
     235      #region Backwards Compatibility
     236      if (successfulOffspringAnalyzer == null)
     237        successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
     238      #endregion
     239
    233240      Initialize();
    234241    }
     
    239246      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
    240247      villageSelectionPressureAnalyzer = cloner.Clone(original.villageSelectionPressureAnalyzer);
     248      successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
    241249      Initialize();
    242250    }
     
    344352      selectionPressureAnalyzer = new ValueAnalyzer();
    345353      villageSelectionPressureAnalyzer = new ValueAnalyzer();
     354      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
    346355      ParameterizeAnalyzers();
    347356      UpdateAnalyzers();
     
    492501      selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
    493502
     503      successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results";
     504      successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations";
     505      successfulOffspringAnalyzer.SuccessfulOffspringFlag.Value.Value = "SuccessfulOffspring";
     506      successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(2);
     507
    494508      if (Problem != null) {
    495509        villageQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    554568      Analyzer.Operators.Add(qualityAnalyzer);
    555569      Analyzer.Operators.Add(selectionPressureAnalyzer);
     570      Analyzer.Operators.Add(successfulOffspringAnalyzer);
     571      Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false);
    556572    }
    557573    private SASEGASAMainLoop FindMainLoop(IOperator start) {
  • trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r5445 r5683  
    4949      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    5050    }
     51    public ValueParameter<BoolValue> TraceSelectedOperatorParameter {
     52      get { return (ValueParameter<BoolValue>)Parameters["TraceSelectedOperator"]; }
     53    }
     54    public ValueLookupParameter<StringValue> SelectedOperatorParameter {
     55      get { return (ValueLookupParameter<StringValue>)Parameters["SelectedOperator"]; }
     56    }
    5157
    5258    public DoubleArray Probabilities {
    5359      get { return ProbabilitiesParameter.Value; }
    5460      set { ProbabilitiesParameter.Value = value; }
     61    }
     62
     63    [StorableHook(HookType.AfterDeserialization)]
     64    private void AfterDeserializationHook() {
     65      #region Backwards Compatibility
     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      }
     69      if (!Parameters.ContainsKey("TraceSelectedOperator")) {
     70        Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false)));
     71      }
     72      #endregion
    5573    }
    5674
     
    6886      Parameters.Add(new ValueLookupParameter<DoubleArray>("Probabilities", "The array of relative probabilities for each operator.", new DoubleArray()));
    6987      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
     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)));
    7090    }
    7191
     
    116136      }
    117137      IOperator successor = null;
     138      int index = -1;
    118139      var checkedOperators = Operators.CheckedItems;
    119140      if (checkedOperators.Count() > 0) {
     
    127148          if (sum > r) {
    128149            successor = indexedItem.Value;
     150            index = indexedItem.Index;
    129151            break;
    130152          }
     
    133155      OperationCollection next = new OperationCollection(base.Apply());
    134156      if (successor != null) {
     157        if (TraceSelectedOperatorParameter.Value.Value)
     158          SelectedOperatorParameter.ActualValue = new StringValue(index + ": " + successor.Name);
     159
    135160        if (CreateChildOperation)
    136161          next.Insert(0, ExecutionContext.CreateChildOperation(successor));
    137162        else next.Insert(0, ExecutionContext.CreateOperation(successor));
     163      } else {
     164        if (TraceSelectedOperatorParameter.Value.Value)
     165          SelectedOperatorParameter.ActualValue = new StringValue("");
    138166      }
    139167      return next;
Note: See TracChangeset for help on using the changeset viewer.