Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1051


Ignore:
Timestamp:
12/22/08 09:37:50 (15 years ago)
Author:
gkronber
Message:

fixed missing project file.
fixed operator graph of standard GP engine.
#224 (Simple frontend for GP for non-expert users (similar to HeurisicLab.SGA))

Location:
branches/CEDMA-Refactoring-Ticket419
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj

    r852 r1051  
    7070    <Compile Include="GPClassificationEvaluatorBase.cs" />
    7171    <Compile Include="CrossValidation.cs" />
    72     <Compile Include="FunctionLibraryInjector.cs">
    73       <SubType>Code</SubType>
    74     </Compile>
    7572    <Compile Include="HeuristicLabGPClassificationPlugin.cs" />
    7673    <Compile Include="MulticlassModeller.cs" />
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/HeuristicLab.GP.StructureIdentification.csproj

    r1050 r1051  
    7272    <Compile Include="Constant.cs" />
    7373    <Compile Include="FunctionLibraryInjector.cs" />
     74    <Compile Include="StandardGpEditor.cs">
     75      <SubType>UserControl</SubType>
     76    </Compile>
     77    <Compile Include="StandardGpEditor.Designer.cs">
     78      <DependentUpon>StandardGpEditor.cs</DependentUpon>
     79    </Compile>
    7480    <Compile Include="StandardGP.cs" />
    7581    <Compile Include="Cosinus.cs" />
     
    161167  </ItemGroup>
    162168  <ItemGroup>
     169    <EmbeddedResource Include="StandardGpEditor.resx">
     170      <DependentUpon>StandardGpEditor.cs</DependentUpon>
     171      <SubType>Designer</SubType>
     172    </EmbeddedResource>
    163173    <EmbeddedResource Include="StructIdProblemInjectorView.resx">
    164174      <DependentUpon>StructIdProblemInjectorView.cs</DependentUpon>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs

    r1050 r1051  
    3535
    3636namespace HeuristicLab.GP.StructureIdentification {
    37   public class StandardGP {
     37  public class StandardGP : ItemBase, IEditable {
    3838    private IntData maxGenerations = new IntData();
    3939    public int MaxGenerations {
     
    4141      set { maxGenerations.Data = value; }
    4242    }
    43      
     43
    4444    private IntData tournamentSize = new IntData();
    4545    public int TournamentSize {
     
    6262    }
    6363
     64    private BoolData setSeedRandomly = new BoolData();
     65    public bool SetSeedRandomly {
     66      get { return setSeedRandomly.Data; }
     67      set { setSeedRandomly.Data = value; }
     68    }
     69
     70    private IntData seed = new IntData();
     71    public int Seed {
     72      get { return seed.Data; }
     73      set { seed.Data = value; }
     74    }
     75
     76    public IOperator ProblemInjector {
     77      get { return algorithm.SubOperators[0]; }
     78      set {
     79        value.Name = "ProblemInjector";
     80        algorithm.RemoveSubOperator(0);
     81        algorithm.AddSubOperator(value, 0);
     82      }
     83    }
     84
     85    private IntData elites = new IntData();
     86    public int Elites {
     87      get { return elites.Data; }
     88      set { elites.Data = value; }
     89    }
     90
    6491    private int maxTreeSize = 50;
    6592    private int maxTreeHeight = 8;
     
    6895    private double fullTreeShakingFactor = 0.1;
    6996    private double onepointShakingFactor = 1.0;
    70 
     97    private IOperator algorithm;
    7198    private SequentialEngine.SequentialEngine engine;
    7299
     100    public IEngine Engine {
     101      get { return engine; }
     102    }
     103
    73104    public StandardGP() {
    74       PopulationSize = 10000;
     105      PopulationSize = 100;
    75106      MaxGenerations = 100;
    76107      TournamentSize = 7;
    77108      MutationRate = 0.15;
    78109      engine = new SequentialEngine.SequentialEngine();
    79       CreateAlgorithm();
    80     }
    81 
    82     public void Reset() {
    83       engine.Reset();
    84     }                                           
    85 
    86     private void Run() {
    87       Reset();
    88     }
    89 
    90     private void CreateAlgorithm() {
    91       SequentialProcessor seq = new SequentialProcessor();
     110      CombinedOperator algo = CreateAlgorithm();
     111      engine.OperatorGraph.AddOperator(algo);
     112      engine.OperatorGraph.InitialOperator = algo;
     113    }
     114
     115    private CombinedOperator CreateAlgorithm() {
     116      CombinedOperator algo = new CombinedOperator();
     117      algo.Name = "StandardGP";
     118      SequentialProcessor seq = new SequentialProcessor();
     119      EmptyOperator problemInjectorPlaceholder = new EmptyOperator();
    92120      RandomInjector randomInjector = new RandomInjector();
     121      randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly;
     122      randomInjector.GetVariable("Seed").Value = seed;
    93123      randomInjector.Name = "Random Injector";
    94124      VariableInjector globalInjector = CreateGlobalInjector();
     
    104134      treeCreator.Name = "Tree generator";
    105135      treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
     136      treeCreator.GetVariableInfo("MinTreeSize").Local = true;
     137      treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(3)));
    106138      MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
    107139      evaluator.GetVariableInfo("MSE").ActualName = "Quality";
     
    121153      selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize";
    122154
     155      seq.AddSubOperator(problemInjectorPlaceholder);
    123156      seq.AddSubOperator(randomInjector);
    124157      seq.AddSubOperator(globalInjector);
     
    135168      mainLoop.AddSubOperator(manipulator);
    136169      mainLoop.AddSubOperator(evaluator);
    137       engine.OperatorGraph.AddOperator(seq);
    138       engine.OperatorGraph.InitialOperator = seq;
     170      algo.OperatorGraph.AddOperator(seq);
     171      algo.OperatorGraph.InitialOperator = seq;
     172      this.algorithm = seq;
     173      return algo;
    139174    }
    140175
     
    147182      injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", populationSize));
    148183      injector.AddVariable(new HeuristicLab.Core.Variable("Parents", parents));
    149       injector.AddVariable(new HeuristicLab.Core.Variable("Elites", new IntData(1)));
     184      injector.AddVariable(new HeuristicLab.Core.Variable("Elites", elites));
     185      injector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize));
    150186      injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false)));
    151187      injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData(maxTreeHeight)));
     
    160196      CombinedOperator manipulator = new CombinedOperator();
    161197      StochasticMultiBranch multibranch = new StochasticMultiBranch();
    162 
    163198      FullTreeShaker fullTreeShaker = new FullTreeShaker();
    164199      fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
     
    179214      substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
    180215
    181       multibranch.AddSubOperator(fullTreeShaker);
    182       multibranch.AddSubOperator(onepointShaker);
    183       multibranch.AddSubOperator(changeNodeTypeManipulation);
    184       multibranch.AddSubOperator(cutOutNodeManipulation);
    185       multibranch.AddSubOperator(deleteSubTreeManipulation);
    186       multibranch.AddSubOperator(substituteSubTreeManipulation);
     216      IOperator[] manipulators = new IOperator[] {
     217        onepointShaker, fullTreeShaker,
     218        changeNodeTypeManipulation,
     219        cutOutNodeManipulation,
     220        deleteSubTreeManipulation,
     221        substituteSubTreeManipulation};
     222
     223      DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]);
     224      for(int i=0;i<manipulators.Length;i++) {
     225        probabilities.Data[i] = 1.0;
     226        multibranch.AddSubOperator(manipulators[i]);
     227      }
     228      multibranch.GetVariableInfo("Probabilities").Local = true;
     229      multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities));
     230
    187231      manipulator.OperatorGraph.AddOperator(multibranch);
    188232      manipulator.OperatorGraph.InitialOperator = multibranch;
     
    194238      SequentialProcessor seq = new SequentialProcessor();
    195239      SubScopesCreater subScopesCreater = new SubScopesCreater();
     240      subScopesCreater.GetVariableInfo("SubScopes").ActualName = "PopulationSize";
    196241      UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
    197242      SequentialProcessor individualSeq = new SequentialProcessor();
     
    202247      evaluator.Name = "Evaluator (extr.)";
    203248      evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
    204      
     249
    205250      seq.AddSubOperator(subScopesCreater);
    206251      seq.AddSubOperator(subScopesProc);
     
    237282      comparator.GetVariableInfo("RightSide").ActualName = "MaxGenerations";
    238283      comparator.GetVariableInfo("Result").ActualName = "GenerationsCondition";
    239 
    240284      ConditionalBranch cond = new ConditionalBranch();
    241285      cond.GetVariableInfo("Condition").ActualName = "GenerationsCondition";
     286
     287      seq.AddSubOperator(childCreater);
     288      seq.AddSubOperator(replacement);
     289      seq.AddSubOperator(qualityCalculator);
     290      seq.AddSubOperator(collector);
     291      seq.AddSubOperator(lineChartInjector);
     292      seq.AddSubOperator(qualityLogger);
     293      seq.AddSubOperator(counter);
     294      seq.AddSubOperator(comparator);
     295      seq.AddSubOperator(cond);
     296      cond.AddSubOperator(seq);
     297
    242298      main.OperatorGraph.AddOperator(seq);
    243299      main.OperatorGraph.InitialOperator = seq;
     
    253309      leftSelector.GetVariableInfo("Selected").ActualName = "Elites";
    254310      RightReducer rightReducer = new RightReducer();
    255      
     311
    256312      SequentialProcessor remainingProc = new SequentialProcessor();
    257313      RightSelector rightSelector = new RightSelector();
     
    303359      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
    304360      sorter.GetVariableInfo("Value").ActualName = "Quality";
    305  
     361
    306362
    307363      seq.AddSubOperator(selector);
     
    321377      return childCreater;
    322378    }
     379
     380    public IEditor CreateEditor() {
     381      return new StandardGpEditor(this);
     382    }
     383
     384    public IView CreateView() {
     385      return new StandardGpEditor(this);
     386    }
    323387  }
    324388}
Note: See TracChangeset for help on using the changeset viewer.