Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1550 for trunk/sources


Ignore:
Timestamp:
04/14/09 00:16:08 (16 years ago)
Author:
dtraxing
Message:

added support for exchangeable operators in sga for crossover, mutation and evaluation (ticket #580)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SGA.Hardwired/3.3/CreateChildren.cs

    r1543 r1550  
    3434  class CreateChildren : OperatorBase {
    3535    ChildrenInitializer ci;
    36     OrderCrossover oc;
    37     InversionManipulator im;
    38     RoundedEuclideanPathTSPEvaluator repTSPe;
     36    OperatorBase crossover;
     37    OperatorBase mutator;
     38    OperatorBase evaluator;
    3939    SubScopesRemover sr;
    4040    Counter counter;
     
    5050      : base() {
    5151      ci = new ChildrenInitializer();
    52       oc = new OrderCrossover();
    53       im = new InversionManipulator();
    54       repTSPe = new RoundedEuclideanPathTSPEvaluator();
    5552 
    56       // variables for stochastic branch
     53      // variables infos
    5754      AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In));
    5855      AddVariableInfo(new VariableInfo("MutationRate", "Probability to choose first branch", typeof(DoubleData), VariableKind.In));
    59            
     56      AddVariableInfo(new VariableInfo("Crossover", "Crossover strategy for SGA", typeof(OperatorBase), VariableKind.In));
     57      AddVariableInfo(new VariableInfo("Mutator", "Mutation strategy for SGA", typeof(OperatorBase), VariableKind.In));
     58      AddVariableInfo(new VariableInfo("Evaluator", "Evaluation strategy for SGA", typeof(OperatorBase), VariableKind.In));
     59
    6060      sr = new SubScopesRemover();
    6161      sr.GetVariableInfo("SubScopeIndex").Local = true;
     
    6969    }
    7070
    71     void valueInfo_ActualNameChanged(object sender, EventArgs e) {
    72       throw new NotImplementedException();
    73     } // SGAMain()
     71    public override IOperation Apply(IScope scope) {
    7472
    75     public override IOperation Apply(IScope scope) {
     73      ci = new ChildrenInitializer();
     74      crossover = (OperatorBase)GetVariableValue("Crossover", scope, true);
     75      mutator = (OperatorBase)GetVariableValue("Mutator", scope, true);
     76      evaluator = GetVariableValue<OperatorBase>("Evaluator", scope, true);
    7677
    7778      random = GetVariableValue<IRandom>("Random", scope, true);
     
    8283      // UniformSequentialSubScopesProcessor
    8384      foreach (IScope s in scope.SubScopes) {
    84         oc.Execute(s);
    85        
     85        crossover.Execute(s);
     86        // Stochastic Branch
    8687        if(random.NextDouble() < probability.Data)
    87           im.Execute(s);
    88         repTSPe.Execute(s);
     88          mutator.Execute(s);
     89        evaluator.Execute(s);
    8990        sr.Execute(s);
    9091        counter.Execute(s);
Note: See TracChangeset for help on using the changeset viewer.