Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2385


Ignore:
Timestamp:
09/24/09 11:37:28 (15 years ago)
Author:
gkronber
Message:

Implemented #762 (ValidationQuality improvment progress as additional stopping criterion for default StructId Engines)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.Algorithms/3.2/AlgorithmBase.cs

    r2377 r2385  
    495495    }
    496496    #endregion
     497
     498
     499    public static IOperator CombineTerminationCriterions(IOperator criterion1, IOperator criterion2) {
     500      ConditionalBranch branch = new ConditionalBranch();
     501      branch.GetVariableInfo("Condition").ActualName = "TerminationCriterion";
     502      branch.AddSubOperator(new EmptyOperator());
     503      branch.AddSubOperator(criterion2);
     504
     505      SequentialProcessor seq = new SequentialProcessor();
     506      seq.AddSubOperator(criterion1);
     507      seq.AddSubOperator(branch);
     508
     509      return seq;
     510    }
    497511  }
    498512}
  • trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffspringSelectionGP.cs

    r2341 r2385  
    178178      selPresComparator.GetVariableInfo("Result").ActualName = "TerminationCriterion";
    179179
    180       IOperator baseAndSelPresTerminationCriterion = CombineTerminationCriterions(base.CreateTerminationCondition(), selPresComparator);
     180      IOperator baseAndSelPresTerminationCriterion = AlgorithmBase.CombineTerminationCriterions(base.CreateTerminationCondition(), selPresComparator);
    181181
    182182      GreaterThanComparator evalSolutionsComparer = new GreaterThanComparator();
     
    185185      evalSolutionsComparer.GetVariableInfo("Result").ActualName = "TerminationCriterion";
    186186
    187       IOperator combinedTerminationCritertion = CombineTerminationCriterions(baseAndSelPresTerminationCriterion, evalSolutionsComparer);
     187      IOperator combinedTerminationCritertion = AlgorithmBase.CombineTerminationCriterions(baseAndSelPresTerminationCriterion, evalSolutionsComparer);
    188188
    189189      terminationCritertion.OperatorGraph.AddOperator(combinedTerminationCritertion);
    190190      terminationCritertion.OperatorGraph.InitialOperator = combinedTerminationCritertion;
    191191      return terminationCritertion;
    192     }
    193 
    194     private IOperator CombineTerminationCriterions(IOperator criterion1, IOperator criterion2) {
    195       ConditionalBranch branch = new ConditionalBranch();
    196       branch.GetVariableInfo("Condition").ActualName = "TerminationCriterion";
    197       branch.AddSubOperator(new EmptyOperator());
    198       branch.AddSubOperator(criterion2);
    199 
    200       SequentialProcessor seq = new SequentialProcessor();
    201       seq.AddSubOperator(criterion1);
    202       seq.AddSubOperator(branch);
    203 
    204       return seq;
    205192    }
    206193
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs

    r2363 r2385  
    6868      individualProc.AddSubOperator(validationEvaluator);
    6969
     70      Counter bestValidationSolutionAgeCounter = new Counter();
     71      bestValidationSolutionAgeCounter.Name = "BestSolutionAgeCounter";
     72      bestValidationSolutionAgeCounter.GetVariableInfo("Value").ActualName = "BestValidationSolutionAge";
     73
    7074      BestSolutionStorer solutionStorer = new BestSolutionStorer();
    7175      solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
     
    8892
    8993      seq.AddSubOperator(subScopesProc);
     94      seq.AddSubOperator(bestValidationSolutionAgeCounter);
    9095      seq.AddSubOperator(solutionStorer);
    9196      seq.AddSubOperator(validationQualityCalculator);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGPRegression.cs

    r2375 r2385  
    3333using HeuristicLab.DataAnalysis;
    3434using HeuristicLab.Operators.Programmable;
     35using HeuristicLab.GP.Algorithms;
    3536
    3637namespace HeuristicLab.GP.StructureIdentification {
     
    100101      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
    101102      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
     103    }
     104
     105    public virtual int MaxBestValidationSolutionAge {
     106      get { return GetVariableInjector().GetVariable("MaxBestValidationSolutionAge").GetValue<IntData>().Data; }
     107      set { GetVariableInjector().GetVariable("MaxBestValidationSolutionAge").GetValue<IntData>().Data = value; }
    102108    }
    103109
     
    116122      : base() {
    117123      PunishmentFactor = 10.0;
     124      MaxBestValidationSolutionAge = 10;
    118125    }
    119126
     
    160167      selectionPressureStorer.GetVariableInfo("Output").ActualName = "SelectionPressure";
    161168
     169      ProgrammableOperator resetBestSolutionAge = new ProgrammableOperator();
     170      resetBestSolutionAge.RemoveVariable("Result");
     171      resetBestSolutionAge.AddVariableInfo(
     172        new VariableInfo("BestValidationSolutionAge", "Age of best validation solution", typeof(IntData), VariableKind.In | VariableKind.Out));
     173      resetBestSolutionAge.Code = "BestValidationSolutionAge.Data = 0;";
     174
    162175      seq.AddSubOperator(evaluatedSolutionsStorer);
    163176      seq.AddSubOperator(selectionPressureStorer);
     177      seq.AddSubOperator(resetBestSolutionAge);
    164178
    165179      op.OperatorGraph.AddOperator(seq);
     
    171185      VariableInjector injector = base.CreateGlobalInjector();
    172186      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
     187      injector.AddVariable(new HeuristicLab.Core.Variable("BestValidationSolutionAge", new IntData()));
     188      injector.AddVariable(new HeuristicLab.Core.Variable("MaxBestValidationSolutionAge", new IntData()));
    173189      return injector;
    174190    }
     
    203219    }
    204220
     221    protected override IOperator CreateTerminationCondition() {
     222      CombinedOperator terminationCritertion = new CombinedOperator();
     223      terminationCritertion.Name = "TerminationCondition";
     224      GreaterThanComparator bestSolutionAge = new GreaterThanComparator();
     225      bestSolutionAge.GetVariableInfo("LeftSide").ActualName = "BestValidationSolutionAge";
     226      bestSolutionAge.GetVariableInfo("RightSide").ActualName = "MaxBestValidationSolutionAge";
     227      bestSolutionAge.GetVariableInfo("Result").ActualName = "TerminationCriterion";
     228
     229      IOperator combinedTerminationCriterion = AlgorithmBase.CombineTerminationCriterions(base.CreateTerminationCondition(), bestSolutionAge);
     230
     231      terminationCritertion.OperatorGraph.AddOperator(combinedTerminationCriterion);
     232      terminationCritertion.OperatorGraph.InitialOperator = combinedTerminationCriterion;
     233      return terminationCritertion;
     234    }
     235
    205236    protected override IOperator CreatePostProcessingOperator() {
    206237      CombinedOperator op = new CombinedOperator();
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGPRegression.cs

    r2375 r2385  
    3232using HeuristicLab.DataAnalysis;
    3333using HeuristicLab.Operators.Programmable;
     34using HeuristicLab.GP.Algorithms;
    3435
    3536namespace HeuristicLab.GP.StructureIdentification {
     
    101102      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
    102103      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
     104    }
     105
     106    public virtual int MaxBestValidationSolutionAge {
     107      get { return GetVariableInjector().GetVariable("MaxBestValidationSolutionAge").GetValue<IntData>().Data; }
     108      set { GetVariableInjector().GetVariable("MaxBestValidationSolutionAge").GetValue<IntData>().Data = value; }
    103109    }
    104110
     
    116122    public StandardGPRegression()
    117123      : base() {
    118 
    119124      PunishmentFactor = 10.0;
     125      MaxBestValidationSolutionAge = 15;
    120126    }
    121127
     
    156162      evaluatedSolutionsStorer.Code = "Output.Data = Input.Data;";
    157163
     164      ProgrammableOperator resetBestSolutionAge = new ProgrammableOperator();
     165      resetBestSolutionAge.RemoveVariable("Result");
     166      resetBestSolutionAge.AddVariableInfo(
     167        new VariableInfo("BestValidationSolutionAge", "Age of best validation solution", typeof(IntData), VariableKind.In | VariableKind.Out));
     168      resetBestSolutionAge.Code = "BestValidationSolutionAge.Data = 0;";
     169
    158170      seq.AddSubOperator(evaluatedSolutionsStorer);
     171      seq.AddSubOperator(resetBestSolutionAge);
    159172
    160173      op.OperatorGraph.AddOperator(seq);
     
    167180      VariableInjector injector = base.CreateGlobalInjector();
    168181      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
     182      injector.AddVariable(new HeuristicLab.Core.Variable("BestValidationSolutionAge", new IntData()));
     183      injector.AddVariable(new HeuristicLab.Core.Variable("MaxBestValidationSolutionAge", new IntData()));
    169184      return injector;
    170185    }
     
    197212    }
    198213
     214    protected override IOperator CreateTerminationCondition() {
     215      CombinedOperator terminationCritertion = new CombinedOperator();
     216      terminationCritertion.Name = "TerminationCondition";
     217      GreaterThanComparator bestSolutionAge = new GreaterThanComparator();
     218      bestSolutionAge.GetVariableInfo("LeftSide").ActualName = "BestValidationSolutionAge";
     219      bestSolutionAge.GetVariableInfo("RightSide").ActualName = "MaxBestValidationSolutionAge";
     220      bestSolutionAge.GetVariableInfo("Result").ActualName = "TerminationCriterion";
     221
     222      IOperator combinedTerminationCriterion = AlgorithmBase.CombineTerminationCriterions(base.CreateTerminationCondition(), bestSolutionAge);
     223     
     224      terminationCritertion.OperatorGraph.AddOperator(combinedTerminationCriterion);
     225      terminationCritertion.OperatorGraph.InitialOperator = combinedTerminationCriterion;
     226      return terminationCritertion;
     227    }
     228
     229
    199230    protected override IOperator CreatePostProcessingOperator() {
    200231      CombinedOperator op = new CombinedOperator();
Note: See TracChangeset for help on using the changeset viewer.