Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1236


Ignore:
Timestamp:
03/02/09 16:31:55 (16 years ago)
Author:
gkronber
Message:

Fixed bugs in OffspringSelectionGP and the associated editor. #224 (Simple frontend for GP for non-expert users (similar to HeurisicLab.SGA))

Location:
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/AlgorithmBase.cs

    r1231 r1236  
    245245      BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
    246246      validationQualityCalculator.Name = "ValidationQualityCalculator";
     247      validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    247248      validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
    248249      validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
     
    261262      QualityLogger qualityLogger = new QualityLogger();
    262263      QualityLogger validationQualityLogger = new QualityLogger();
    263       validationQualityCalculator.Name = "ValidationQualityLogger";
     264      validationQualityLogger.Name = "ValidationQualityLogger";
    264265      validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    265266      validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";
     
    330331    }
    331332
    332     internal  virtual IOperator CreateChildCreater() {
     333    internal virtual IOperator CreateChildCreater() {
    333334      CombinedOperator childCreater = new CombinedOperator();
    334335      childCreater.Name = "Create children";
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffSpringSelectionGpEditor.cs

    r1202 r1236  
    129129        executeButton.Enabled = true;
    130130        abortButton.Enabled = false;
     131        resetButton.Enabled = true;
    131132      }
    132133    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffspringSelectionGP.cs

    r1235 r1236  
    3939  public class OffspringSelectionGP : StandardGP {
    4040
    41     private IntData maxEvaluatedSolutions = new IntData();
    42     public int MaxEvaluatedSolutions {
    43       get { return maxEvaluatedSolutions.Data; }
    44       set { maxEvaluatedSolutions.Data = value; }
    45     }
    46 
    4741    private DoubleData selectionPressureLimit = new DoubleData();
    4842    public double SelectionPressureLimit {
     
    6660      PopulationSize = 1000;
    6761      Parents = 20;
    68       MaxEvaluatedSolutions = 1000000;
     62      MaxGenerations = 300;
    6963      SelectionPressureLimit = 300;
    7064      ComparisonFactor = 1.0;
     
    7569      VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
    7670      injector.RemoveVariable("TournamentSize");
    77       injector.RemoveVariable("MaxGenerations");
    78       injector.AddVariable(new HeuristicLab.Core.Variable("MaxEvaluatedSolutions", maxEvaluatedSolutions));
    7971      injector.AddVariable(new HeuristicLab.Core.Variable("ComparisonFactor", comparisonFactor));
    8072      injector.AddVariable(new HeuristicLab.Core.Variable("SelectionPressureLimit", selectionPressureLimit));
     
    113105    }
    114106
    115     internal override IOperator CreateMainLoop() {
    116       CombinedOperator main = new CombinedOperator();
     107    internal override IOperator CreateChildCreater() {
     108      CombinedOperator childCreater = new CombinedOperator();
     109      childCreater.Name = "Create children";
    117110      SequentialProcessor seq = new SequentialProcessor();
    118111      SequentialProcessor offspringSelectionSeq = new SequentialProcessor();
    119       SequentialSubScopesProcessor subScopesProc = new SequentialSubScopesProcessor();
    120       EmptyOperator emptyOp = new EmptyOperator();
    121       OffspringSelector offspringSelector = new OffspringSelector();
    122 
    123112      OperatorExtractor selector = new OperatorExtractor();
    124113      selector.Name = "Selector (extr.)";
    125114      selector.GetVariableInfo("Operator").ActualName = "Selector";
    126 
    127       IOperator childCreater = CreateChildCreater();
    128       childCreater.Name = "Create children";
    129       IOperator replacement = CreateReplacement();
    130       replacement.Name = "Replacement";
    131       IOperator solutionStorer = CreateBestSolutionProcessor();
    132       BestAverageWorstQualityCalculator qualityCalculator = new BestAverageWorstQualityCalculator();
    133       BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
    134       validationQualityCalculator.Name = "ValidationQualityCalculator";
    135       validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
    136       validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
    137       validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";
    138       DataCollector collector = new DataCollector();
    139       ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
    140       names.Add(new StringData("BestQuality"));
    141       names.Add(new StringData("AverageQuality"));
    142       names.Add(new StringData("WorstQuality"));
    143       names.Add(new StringData("BestValidationQuality"));
    144       names.Add(new StringData("AverageValidationQuality"));
    145       names.Add(new StringData("WorstValidationQuality"));
    146       LinechartInjector lineChartInjector = new LinechartInjector();
    147       lineChartInjector.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
    148       lineChartInjector.GetVariable("NumberOfLines").GetValue<IntData>().Data = 6;
    149       QualityLogger qualityLogger = new QualityLogger();
    150       QualityLogger validationQualityLogger = new QualityLogger();
    151       validationQualityCalculator.Name = "ValidationQualityLogger";
    152       validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    153       validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";
    154       Counter counter = new Counter();
    155       counter.GetVariableInfo("Value").ActualName = "Generations";
    156       LessThanComparator selPresComparator = new LessThanComparator();
    157       selPresComparator.GetVariableInfo("LeftSide").ActualName = "SelectionPressure";
    158       selPresComparator.GetVariableInfo("RightSide").ActualName = "SelectionPressureLimit";
    159       selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition";
    160       LessThanComparator generationsComparator = new LessThanComparator();
    161       generationsComparator.GetVariableInfo("LeftSide").ActualName = "EvaluatedSolutions";
    162       generationsComparator.GetVariableInfo("RightSide").ActualName = "MaxEvaluatedSolutions";
    163       generationsComparator.GetVariableInfo("Result").ActualName = "EvaluatedSolutionsCondition";
    164       ConditionalBranch selPresCondition = new ConditionalBranch();
    165       selPresCondition.GetVariableInfo("Condition").ActualName = "SelectionPressureCondition";
    166       ConditionalBranch generationsCondition = new ConditionalBranch();
    167       generationsCondition.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition";
    168 
    169       subScopesProc.AddSubOperator(emptyOp);
    170       subScopesProc.AddSubOperator(childCreater);
    171 
     115      SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor();
     116      EmptyOperator emptyOp = new EmptyOperator();
     117      OffspringSelector offspringSelector = new OffspringSelector();
     118      OffspringAnalyzer offspringAnalyzer = new OffspringAnalyzer();
     119      SequentialProcessor selectedProc = new SequentialProcessor();
     120      OperatorExtractor crossover = new OperatorExtractor();
     121      crossover.Name = "Crossover (extr.)";
     122      crossover.GetVariableInfo("Operator").ActualName = "Crossover";
     123      UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor();
     124      SequentialProcessor individualSeqProc = new SequentialProcessor();
     125      StochasticBranch cond = new StochasticBranch();
     126      cond.GetVariableInfo("Probability").ActualName = "MutationRate";
     127      OperatorExtractor manipulator = new OperatorExtractor();
     128      manipulator.Name = "Manipulator (extr.)";
     129      manipulator.GetVariableInfo("Operator").ActualName = "Manipulator";
     130      OperatorExtractor evaluator = new OperatorExtractor();
     131      evaluator.Name = "Evaluator (extr.)";
     132      evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
     133      Counter evalCounter = new Counter();
     134      evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
     135
     136      Sorter sorter = new Sorter();
     137      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
     138      sorter.GetVariableInfo("Value").ActualName = "Quality";
     139
     140      UniformSequentialSubScopesProcessor validationEvaluator = new UniformSequentialSubScopesProcessor();
     141      MeanSquaredErrorEvaluator validationQualityEvaluator = new MeanSquaredErrorEvaluator();
     142      validationQualityEvaluator.Name = "ValidationMeanSquaredErrorEvaluator";
     143      validationQualityEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
     144      validationQualityEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     145      validationQualityEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     146
     147      seqSubScopesProc.AddSubOperator(emptyOp);
     148      seqSubScopesProc.AddSubOperator(offspringAnalyzer);
     149
     150      seq.AddSubOperator(offspringSelectionSeq);
     151      offspringSelectionSeq.AddSubOperator(selector);
     152      offspringSelectionSeq.AddSubOperator(seqSubScopesProc);
     153      offspringSelectionSeq.AddSubOperator(offspringSelector);
    172154      offspringSelector.AddSubOperator(offspringSelectionSeq);
    173155
    174       offspringSelectionSeq.AddSubOperator(selector);
    175       offspringSelectionSeq.AddSubOperator(subScopesProc);
    176       offspringSelectionSeq.AddSubOperator(offspringSelector);
    177 
    178       seq.AddSubOperator(offspringSelectionSeq);
    179       seq.AddSubOperator(replacement);
    180       seq.AddSubOperator(solutionStorer);
    181       seq.AddSubOperator(qualityCalculator);
    182       seq.AddSubOperator(validationQualityCalculator);
    183       seq.AddSubOperator(collector);
    184       seq.AddSubOperator(lineChartInjector);
    185       seq.AddSubOperator(qualityLogger);
    186       seq.AddSubOperator(validationQualityLogger);
    187       seq.AddSubOperator(counter);
    188       seq.AddSubOperator(selPresComparator);
    189       seq.AddSubOperator(generationsComparator);
    190       seq.AddSubOperator(selPresCondition);
    191       selPresCondition.AddSubOperator(generationsCondition);
    192       generationsCondition.AddSubOperator(seq);
    193 
    194       main.OperatorGraph.AddOperator(seq);
    195       main.OperatorGraph.InitialOperator = seq;
    196       return main;
     156      offspringAnalyzer.AddSubOperator(selectedProc);
     157      selectedProc.AddSubOperator(crossover);
     158      selectedProc.AddSubOperator(individualProc);
     159      individualProc.AddSubOperator(individualSeqProc);
     160      individualSeqProc.AddSubOperator(cond);
     161      cond.AddSubOperator(manipulator);
     162      individualSeqProc.AddSubOperator(evaluator);
     163      individualSeqProc.AddSubOperator(evalCounter);
     164
     165      SequentialSubScopesProcessor seqSubScopesProc2 = new SequentialSubScopesProcessor();
     166      seq.AddSubOperator(seqSubScopesProc2);
     167      seqSubScopesProc2.AddSubOperator(emptyOp);
     168
     169      SequentialProcessor newGenProc = new SequentialProcessor();
     170      newGenProc.AddSubOperator(sorter);
     171      newGenProc.AddSubOperator(validationEvaluator);
     172      seqSubScopesProc2.AddSubOperator(newGenProc);
     173
     174      validationEvaluator.AddSubOperator(validationQualityEvaluator);
     175
     176      childCreater.OperatorGraph.AddOperator(seq);
     177      childCreater.OperatorGraph.InitialOperator = seq;
     178      return childCreater;
    197179    }
    198180
     
    223205      // VariableInjector
    224206      VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];
    225       maxEvaluatedSolutions = vi.GetVariable("MaxEvaluatedSolutions").GetValue<IntData>();
    226207      selectionPressureLimit = vi.GetVariable("SelectionPressureLimit").GetValue<DoubleData>();
    227208      successRatioLimit = vi.GetVariable("SuccessRatioLimit").GetValue<DoubleData>();
Note: See TracChangeset for help on using the changeset viewer.