Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1235


Ignore:
Timestamp:
03/02/09 09:38:53 (16 years ago)
Author:
gkronber
Message:

Worked on hard-coded OffspringSelectionGP. #224 (Simple frontend for GP for non-expert users (similar to HeurisicLab.SGA))

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

Legend:

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

    r1202 r1235  
    3737
    3838namespace HeuristicLab.GP.StructureIdentification {
    39   public class OffspringSelectionGP : ItemBase, IEditable {
    40     private IntData maxGenerations = new IntData();
    41     public int MaxGenerations {
    42       get { return maxGenerations.Data; }
    43       set { maxGenerations.Data = value; }
    44     }
    45 
    46     private DoubleData mutationRate = new DoubleData();
    47     public double MutationRate {
    48       get { return mutationRate.Data; }
    49       set { mutationRate.Data = value; }
    50     }
    51 
    52     private IntData parents = new IntData();
    53     private IntData populationSize = new IntData();
    54     public int PopulationSize {
    55       get { return populationSize.Data; }
    56       set {
    57         populationSize.Data = value;
    58       }
    59     }
    60 
    61     private BoolData setSeedRandomly = new BoolData();
    62     public bool SetSeedRandomly {
    63       get { return setSeedRandomly.Data; }
    64       set { setSeedRandomly.Data = value; }
    65     }
    66 
    67     private IntData seed = new IntData();
    68     public int Seed {
    69       get { return seed.Data; }
    70       set { seed.Data = value; }
    71     }
    72 
    73     public IOperator ProblemInjector {
    74       get { return algorithm.SubOperators[0]; }
    75       set {
    76         value.Name = "ProblemInjector";
    77         algorithm.RemoveSubOperator(0);
    78         algorithm.AddSubOperator(value, 0);
    79       }
    80     }
    81 
    82     private IntData elites = new IntData();
    83     public int Elites {
    84       get { return elites.Data; }
    85       set { elites.Data = value; }
    86     }
    87 
    88     private IntData maxTreeSize = new IntData();
    89     public int MaxTreeSize {
    90       get { return maxTreeSize.Data; }
    91       set { maxTreeSize.Data = value; }
    92     }
    93 
    94     private IntData maxTreeHeight = new IntData();
    95     public int MaxTreeHeight {
    96       get { return maxTreeHeight.Data; }
    97       set { maxTreeHeight.Data = value; }
     39  public class OffspringSelectionGP : StandardGP {
     40
     41    private IntData maxEvaluatedSolutions = new IntData();
     42    public int MaxEvaluatedSolutions {
     43      get { return maxEvaluatedSolutions.Data; }
     44      set { maxEvaluatedSolutions.Data = value; }
    9845    }
    9946
     
    11663    }
    11764
    118     private double punishmentFactor = 10.0;
    119     private bool useEstimatedTargetValue = false;
    120     private double fullTreeShakingFactor = 0.1;
    121     private double onepointShakingFactor = 1.0;
    122     private IOperator algorithm;
    123 
    124     private SequentialEngine.SequentialEngine engine;
    125     public IEngine Engine {
    126       get { return engine; }
    127     }
    128 
    129     public OffspringSelectionGP() {
     65    public OffspringSelectionGP() : base() {
    13066      PopulationSize = 1000;
    131       parents.Data = 20;
    132       MaxGenerations = 100;
    133       MutationRate = 0.15;
    134       Elites = 1;
     67      Parents = 20;
     68      MaxEvaluatedSolutions = 1000000;
    13569      SelectionPressureLimit = 300;
    13670      ComparisonFactor = 1.0;
    13771      SuccessRatioLimit = 1.0;
    138       MaxTreeHeight = 10;
    139       MaxTreeSize = 100;
    140       engine = new SequentialEngine.SequentialEngine();
    141       CombinedOperator algo = CreateAlgorithm();
    142       engine.OperatorGraph.AddOperator(algo);
    143       engine.OperatorGraph.InitialOperator = algo;
    144     }
    145 
    146     private CombinedOperator CreateAlgorithm() {
    147       CombinedOperator algo = new CombinedOperator();
    148       algo.Name = "OffspringSelectionGP";
    149       SequentialProcessor seq = new SequentialProcessor();
    150       EmptyOperator problemInjectorPlaceholder = new EmptyOperator();
    151       RandomInjector randomInjector = new RandomInjector();
    152       randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly;
    153       randomInjector.GetVariable("Seed").Value = seed;
    154       randomInjector.Name = "Random Injector";
    155       VariableInjector globalInjector = CreateGlobalInjector();
    156       CombinedOperator initialization = CreateInitialization();
    157       initialization.Name = "Initialization";
    158       FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector();
    159       CombinedOperator mainLoop = CreateMainLoop();
    160       mainLoop.Name = "Main loop";
    161 
    162       ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();
    163       treeCreator.Name = "Tree generator";
    164       treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    165       treeCreator.GetVariableInfo("MinTreeSize").Local = true;
    166       treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(3)));
    167       MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
    168       evaluator.GetVariableInfo("MSE").ActualName = "Quality";
    169       evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    170       evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
    171       evaluator.Name = "Evaluator";
    172       StandardCrossOver crossover = new StandardCrossOver();
    173       crossover.Name = "Crossover";
    174       crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    175       CombinedOperator manipulator = CreateManipulator();
    176       manipulator.Name = "Manipulator";
    177       CombinedOperator selector = CreateSelector();
    178       selector.Name = "Selector";
    179       LeftReducer cleanUp = new LeftReducer();
    180 
    181       seq.AddSubOperator(problemInjectorPlaceholder);
    182       seq.AddSubOperator(randomInjector);
    183       seq.AddSubOperator(globalInjector);
    184       seq.AddSubOperator(funLibInjector);
    185       seq.AddSubOperator(initialization);
    186       seq.AddSubOperator(mainLoop);
    187       seq.AddSubOperator(cleanUp);
    188 
    189       initialization.AddSubOperator(treeCreator);
    190       initialization.AddSubOperator(evaluator);
    191 
    192       mainLoop.AddSubOperator(selector);
    193       mainLoop.AddSubOperator(crossover);
    194       mainLoop.AddSubOperator(manipulator);
    195       mainLoop.AddSubOperator(evaluator);
    196       algo.OperatorGraph.AddOperator(seq);
    197       algo.OperatorGraph.InitialOperator = seq;
    198       this.algorithm = seq;
    199       return algo;
    200     }
    201 
    202     private VariableInjector CreateGlobalInjector() {
    203       VariableInjector injector = new VariableInjector();
    204       injector.Name = "Global Injector";
     72    }
     73
     74    internal override IOperator CreateGlobalInjector() {
     75      VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
     76      injector.RemoveVariable("TournamentSize");
     77      injector.RemoveVariable("MaxGenerations");
     78      injector.AddVariable(new HeuristicLab.Core.Variable("MaxEvaluatedSolutions", maxEvaluatedSolutions));
    20579      injector.AddVariable(new HeuristicLab.Core.Variable("ComparisonFactor", comparisonFactor));
    206       injector.AddVariable(new HeuristicLab.Core.Variable("Elites", elites));
    207       injector.AddVariable(new HeuristicLab.Core.Variable("EvaluatedSolutions", new IntData(0)));
    208       injector.AddVariable(new HeuristicLab.Core.Variable("Generations", new IntData(0)));
    209       injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false)));
    210       injector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", maxGenerations));
    211       injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", maxTreeHeight));
    212       injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeSize", maxTreeSize));
    213       injector.AddVariable(new HeuristicLab.Core.Variable("MutationRate", mutationRate));
    214       injector.AddVariable(new HeuristicLab.Core.Variable("Parents", parents));
    215       injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", populationSize));
    216       injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(punishmentFactor)));
    21780      injector.AddVariable(new HeuristicLab.Core.Variable("SelectionPressureLimit", selectionPressureLimit));
    21881      injector.AddVariable(new HeuristicLab.Core.Variable("SuccessRatioLimit", successRatioLimit));
    219       injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0)));
    220       injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData(useEstimatedTargetValue)));
    22182      return injector;
    22283    }
    22384
    224     private CombinedOperator CreateManipulator() {
    225       CombinedOperator manipulator = new CombinedOperator();
    226       StochasticMultiBranch multibranch = new StochasticMultiBranch();
    227       FullTreeShaker fullTreeShaker = new FullTreeShaker();
    228       fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    229       fullTreeShaker.GetVariableInfo("ShakingFactor").Local = true;
    230       fullTreeShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", new DoubleData(fullTreeShakingFactor)));
    231 
    232       OnePointShaker onepointShaker = new OnePointShaker();
    233       onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    234       onepointShaker.GetVariableInfo("ShakingFactor").Local = true;
    235       onepointShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", new DoubleData(onepointShakingFactor)));
    236       ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();
    237       changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    238       CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation();
    239       cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    240       DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation();
    241       deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    242       SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation();
    243       substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    244 
    245       IOperator[] manipulators = new IOperator[] {
    246         onepointShaker, fullTreeShaker,
    247         changeNodeTypeManipulation,
    248         cutOutNodeManipulation,
    249         deleteSubTreeManipulation,
    250         substituteSubTreeManipulation};
    251 
    252       DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]);
    253       for (int i = 0; i < manipulators.Length; i++) {
    254         probabilities.Data[i] = 1.0;
    255         multibranch.AddSubOperator(manipulators[i]);
    256       }
    257       multibranch.GetVariableInfo("Probabilities").Local = true;
    258       multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities));
    259 
    260       manipulator.OperatorGraph.AddOperator(multibranch);
    261       manipulator.OperatorGraph.InitialOperator = multibranch;
    262       return manipulator;
    263     }
    264 
    265     private CombinedOperator CreateInitialization() {
    266       CombinedOperator init = new CombinedOperator();
    267       SequentialProcessor seq = new SequentialProcessor();
    268       SubScopesCreater subScopesCreater = new SubScopesCreater();
    269       subScopesCreater.GetVariableInfo("SubScopes").ActualName = "PopulationSize";
    270       UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
    271       SequentialProcessor individualSeq = new SequentialProcessor();
    272       OperatorExtractor treeCreater = new OperatorExtractor();
    273       treeCreater.Name = "Tree generator (extr.)";
    274       treeCreater.GetVariableInfo("Operator").ActualName = "Tree generator";
    275       OperatorExtractor evaluator = new OperatorExtractor();
    276       evaluator.Name = "Evaluator (extr.)";
    277       evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
    278       MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
    279       validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
    280       validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    281       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    282       Counter evalCounter = new Counter();
    283       evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
    284       Sorter sorter = new Sorter();
    285       sorter.GetVariableInfo("Descending").ActualName = "Maximization";
    286       sorter.GetVariableInfo("Value").ActualName = "Quality";
    287       seq.AddSubOperator(subScopesCreater);
    288       seq.AddSubOperator(subScopesProc);
    289       seq.AddSubOperator(sorter);
    290       subScopesProc.AddSubOperator(individualSeq);
    291       individualSeq.AddSubOperator(treeCreater);
    292       individualSeq.AddSubOperator(evaluator);
    293       individualSeq.AddSubOperator(validationEvaluator);
    294       individualSeq.AddSubOperator(evalCounter);
    295 
    296       init.OperatorGraph.AddOperator(seq);
    297       init.OperatorGraph.InitialOperator = seq;
    298       return init;
    299     }
    300 
    301     private CombinedOperator CreateSelector() {
     85    internal override IOperator CreateSelector() {
    30286      CombinedOperator selector = new CombinedOperator();
     87      selector.Name = "Selector";
    30388      SequentialProcessor seq = new SequentialProcessor();
    30489      seq.Name = "Selector";
     
    328113    }
    329114
    330     private CombinedOperator CreateMainLoop() {
     115    internal override IOperator CreateMainLoop() {
    331116      CombinedOperator main = new CombinedOperator();
    332117      SequentialProcessor seq = new SequentialProcessor();
     
    340125      selector.GetVariableInfo("Operator").ActualName = "Selector";
    341126
    342       CombinedOperator childCreater = CreateChildCreater();
     127      IOperator childCreater = CreateChildCreater();
    343128      childCreater.Name = "Create children";
    344       CombinedOperator replacement = CreateReplacement();
     129      IOperator replacement = CreateReplacement();
    345130      replacement.Name = "Replacement";
    346       BestSolutionStorer solutionStorer = CreateBestSolutionStorer();
     131      IOperator solutionStorer = CreateBestSolutionProcessor();
    347132      BestAverageWorstQualityCalculator qualityCalculator = new BestAverageWorstQualityCalculator();
    348133      BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
     
    374159      selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition";
    375160      LessThanComparator generationsComparator = new LessThanComparator();
    376       generationsComparator.GetVariableInfo("LeftSide").ActualName = "Generations";
    377       generationsComparator.GetVariableInfo("RightSide").ActualName = "MaxGenerations";
    378       generationsComparator.GetVariableInfo("Result").ActualName = "GenerationsCondition";
     161      generationsComparator.GetVariableInfo("LeftSide").ActualName = "EvaluatedSolutions";
     162      generationsComparator.GetVariableInfo("RightSide").ActualName = "MaxEvaluatedSolutions";
     163      generationsComparator.GetVariableInfo("Result").ActualName = "EvaluatedSolutionsCondition";
    379164      ConditionalBranch selPresCondition = new ConditionalBranch();
    380165      selPresCondition.GetVariableInfo("Condition").ActualName = "SelectionPressureCondition";
    381166      ConditionalBranch generationsCondition = new ConditionalBranch();
    382       generationsCondition.GetVariableInfo("Condition").ActualName = "GenerationsCondition";
     167      generationsCondition.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition";
    383168
    384169      subScopesProc.AddSubOperator(emptyOp);
     
    412197    }
    413198
    414     private BestSolutionStorer CreateBestSolutionStorer() {
    415       BestSolutionStorer solutionStorer = new BestSolutionStorer();
    416       solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    417       solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
    418       SequentialProcessor bestSolutionProcessor = new SequentialProcessor();
    419       MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
    420       trainingMapeEvaluator.Name = "TrainingMapeEvaluator";
    421       trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";
    422       trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    423       trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
    424       MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
    425       validationMapeEvaluator.Name = "ValidationMapeEvaluator";
    426       validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";
    427       validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    428       validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    429       ProgrammableOperator progOperator = new ProgrammableOperator();
    430       progOperator.RemoveVariableInfo("Result");
    431       progOperator.AddVariableInfo(new HeuristicLab.Core.VariableInfo("EvaluatedSolutions", "", typeof(IntData), VariableKind.In));
    432       progOperator.AddVariableInfo(new HeuristicLab.Core.VariableInfo("SelectionPressure", "", typeof(DoubleData), VariableKind.In));
    433       progOperator.Code = @"
    434 int evalSolutions = EvaluatedSolutions.Data;
    435 double selectionPressure = SelectionPressure.Data;
    436 scope.AddVariable(new Variable(""EvaluatedSolutions"", new IntData(evalSolutions)));
    437 scope.AddVariable(new Variable(""SelectionPressure"", new DoubleData(selectionPressure)));
    438 ";
    439       solutionStorer.AddSubOperator(bestSolutionProcessor);
    440       bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator);
    441       bestSolutionProcessor.AddSubOperator(validationMapeEvaluator);
    442       bestSolutionProcessor.AddSubOperator(progOperator);
    443       return solutionStorer;
    444     }
    445 
    446     private CombinedOperator CreateReplacement() {
    447       CombinedOperator replacement = new CombinedOperator();
    448       SequentialProcessor seq = new SequentialProcessor();
    449       SequentialSubScopesProcessor seqScopeProc = new SequentialSubScopesProcessor();
    450       SequentialProcessor selectedProc = new SequentialProcessor();
    451       LeftSelector leftSelector = new LeftSelector();
    452       leftSelector.GetVariableInfo("Selected").ActualName = "Elites";
    453       RightReducer rightReducer = new RightReducer();
    454 
    455       SequentialProcessor remainingProc = new SequentialProcessor();
    456       RightSelector rightSelector = new RightSelector();
    457       rightSelector.GetVariableInfo("Selected").ActualName = "Elites";
    458       LeftReducer leftReducer = new LeftReducer();
    459       MergingReducer mergingReducer = new MergingReducer();
    460       Sorter sorter = new Sorter();
    461       sorter.GetVariableInfo("Descending").ActualName = "Maximization";
    462       sorter.GetVariableInfo("Value").ActualName = "Quality";
    463 
    464       seq.AddSubOperator(seqScopeProc);
    465       seqScopeProc.AddSubOperator(selectedProc);
    466       selectedProc.AddSubOperator(leftSelector);
    467       selectedProc.AddSubOperator(rightReducer);
    468 
    469       seqScopeProc.AddSubOperator(remainingProc);
    470       remainingProc.AddSubOperator(rightSelector);
    471       remainingProc.AddSubOperator(leftReducer);
    472       seq.AddSubOperator(mergingReducer);
    473       seq.AddSubOperator(sorter);
    474       replacement.OperatorGraph.AddOperator(seq);
    475       replacement.OperatorGraph.InitialOperator = seq;
    476       return replacement;
    477     }
    478 
    479     private CombinedOperator CreateChildCreater() {
    480       CombinedOperator childCreater = new CombinedOperator();
    481       SequentialProcessor seq = new SequentialProcessor();
    482       OffspringAnalyzer analyzer = new OffspringAnalyzer();
    483       analyzer.GetVariableInfo("ComparisonFactor").Local = false;
    484       analyzer.RemoveVariable("ComparisonFactor");
    485       SequentialProcessor selectedProc = new SequentialProcessor();
    486       OperatorExtractor crossover = new OperatorExtractor();
    487       crossover.Name = "Crossover (extr.)";
    488       crossover.GetVariableInfo("Operator").ActualName = "Crossover";
    489       UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor();
    490       SequentialProcessor individualSeqProc = new SequentialProcessor();
    491       StochasticBranch cond = new StochasticBranch();
    492       cond.GetVariableInfo("Probability").ActualName = "MutationRate";
    493       OperatorExtractor manipulator = new OperatorExtractor();
    494       manipulator.Name = "Manipulator (extr.)";
    495       manipulator.GetVariableInfo("Operator").ActualName = "Manipulator";
    496       OperatorExtractor evaluator = new OperatorExtractor();
    497       evaluator.Name = "Evaluator (extr.)";
    498       evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
    499       MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
    500       validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
    501       validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    502       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    503       Counter evalCounter = new Counter();
    504       evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
    505 
    506       Sorter sorter = new Sorter();
    507       sorter.GetVariableInfo("Descending").ActualName = "Maximization";
    508       sorter.GetVariableInfo("Value").ActualName = "Quality";
    509       seq.AddSubOperator(analyzer);
    510       analyzer.AddSubOperator(selectedProc);
    511       selectedProc.AddSubOperator(crossover);
    512       selectedProc.AddSubOperator(individualProc);
    513       individualProc.AddSubOperator(individualSeqProc);
    514       individualSeqProc.AddSubOperator(cond);
    515       cond.AddSubOperator(manipulator);
    516       individualSeqProc.AddSubOperator(evaluator);
    517       individualSeqProc.AddSubOperator(validationEvaluator);
    518       individualSeqProc.AddSubOperator(evalCounter);
    519       seq.AddSubOperator(sorter);
    520 
    521       childCreater.OperatorGraph.AddOperator(seq);
    522       childCreater.OperatorGraph.InitialOperator = seq;
    523       return childCreater;
    524     }
    525 
    526     public IEditor CreateEditor() {
     199    public override IEditor CreateEditor() {
    527200      return new OffspringSelectionGpEditor(this);
    528201    }
     
    533206
    534207    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    535       OffspringSelectionGP clone = new OffspringSelectionGP();
    536       clonedObjects.Add(Guid, clone);
    537       clone.engine = (SequentialEngine.SequentialEngine)Auxiliary.Clone(Engine, clonedObjects);
     208      OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects);
     209      clone.SelectionPressureLimit = SelectionPressureLimit;
     210      clone.SuccessRatioLimit = SuccessRatioLimit;
     211      clone.ComparisonFactor = ComparisonFactor;
    538212      return clone;
    539213    }
     214
    540215    #region SetReferences Method
    541216    private void SetReferences() {
     
    543218      CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    544219      // SequentialProcessor in SGA
    545       algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
     220      SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    546221      // RandomInjector
    547222      RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];
    548       setSeedRandomly = ri.GetVariable("SetSeedRandomly").GetValue<BoolData>();
    549       seed = ri.GetVariable("Seed").GetValue<IntData>();
    550223      // VariableInjector
    551224      VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];
    552       populationSize = vi.GetVariable("PopulationSize").GetValue<IntData>();
    553       parents = vi.GetVariable("Parents").GetValue<IntData>();
    554       maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();
    555       mutationRate = vi.GetVariable("MutationRate").GetValue<DoubleData>();
    556       elites = vi.GetVariable("Elites").GetValue<IntData>();
    557       maxTreeSize = vi.GetVariable("MaxTreeSize").GetValue<IntData>();
    558       maxTreeHeight = vi.GetVariable("MaxTreeHeight").GetValue<IntData>();
     225      maxEvaluatedSolutions = vi.GetVariable("MaxEvaluatedSolutions").GetValue<IntData>();
     226      selectionPressureLimit = vi.GetVariable("SelectionPressureLimit").GetValue<DoubleData>();
     227      successRatioLimit = vi.GetVariable("SuccessRatioLimit").GetValue<DoubleData>();
     228      comparisonFactor = vi.GetVariable("ComparisonFactor").GetValue<DoubleData>();
    559229    }
    560230    #endregion
     
    563233    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    564234      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    565       node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));
    566235      return node;
    567236    }
    568237    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    569238      base.Populate(node, restoredObjects);
    570       engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);
    571239      SetReferences();
    572240    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs

    r1231 r1235  
    194194    }
    195195
    196     public IEditor CreateEditor() {
     196    public virtual IEditor CreateEditor() {
    197197      return new StandardGpEditor(this);
    198198    }
     
    208208      return clone;
    209209    }
     210
    210211    #region SetReferences Method
    211212    private void SetReferences() {
Note: See TracChangeset for help on using the changeset viewer.