Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1900


Ignore:
Timestamp:
05/26/09 23:09:19 (16 years ago)
Author:
dtraxing
Message:

new implementation for fixed sga main (ticket #580)

Location:
trunk/sources/HeuristicLab.FixedOperators/3.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.FixedOperators/3.2/FixedOperatorBase.cs

    r1875 r1900  
    6565        ExecuteOperation(op, scope);
    6666        persistedExecutionPointer.Data++;
     67        //Console.WriteLine("Execute: {0}", executionPointer);
    6768      } // if not executed
     69      //else
     70        //Console.WriteLine("Skip Execute: {0}", executionPointer);
    6871      executionPointer++;
    6972
  • trunk/sources/HeuristicLab.FixedOperators/3.2/FixedSGAMain.cs

    r1875 r1900  
    143143      IntData maxGenerations = GetVariableValue<IntData>("MaximumGenerations", scope, true);
    144144      IntData nrOfGenerations = GetVariableValue<IntData>("Generations", scope, true);
    145       nrOfGenerations.Data = 0;
    146 
    147       IntData subscopeNr = new IntData(0);
     145      //nrOfGenerations.Data = 0;
     146
     147      IntData subscopeNr;
     148      try {
     149        subscopeNr = scope.GetVariableValue<IntData>("SubScopeNr", false);
     150      }
     151      catch (Exception) {
     152        subscopeNr = new IntData(0);
     153        scope.AddVariable(new Variable("SubScopeNr", subscopeNr));
     154      }
     155
     156      EmptyOperator empty = new EmptyOperator();
    148157
    149158      IScope s;
    150159      IScope s2;
    151       int tempExePointer;
    152       int tempPersExePointer;
     160      int tempExePointer = 0;
     161      int tempPersExePointer = 0;
    153162      // fetch variables from scope for create children
    154163      InitializeExecuteCreateChildren(scope);
    155164      try {
    156165        for (int i = nrOfGenerations.Data; i < maxGenerations.Data; i++) {
     166          if (executionPointer == persistedExecutionPointer.Data)
     167            persistedExecutionPointer.Data = 0;
     168          executionPointer = 0;
     169         
    157170          Execute(selector, scope);
    158171
     
    161174          s = scope.SubScopes[1];
    162175          Execute(ci, s);
     176         
    163177          tempExePointer = executionPointer;
    164178          tempPersExePointer = persistedExecutionPointer.Data;
    165179          // UniformSequentialSubScopesProcessor
    166180          for (int j = subscopeNr.Data; j < s.SubScopes.Count; j++ ) {
     181            if (executionPointer == persistedExecutionPointer.Data)
     182              persistedExecutionPointer.Data = tempExePointer;
    167183            executionPointer = tempExePointer;
    168             persistedExecutionPointer.Data = tempPersExePointer;
     184           
    169185            s2 = s.SubScopes[j];
    170186            Execute(crossover, s2);
     
    172188            if (random.NextDouble() < probability.Data)
    173189              Execute(mutator, s2);
     190            else
     191              Execute(empty, s2);
    174192            Execute(evaluator, s2);
    175193            Execute(sr, s2);
    176194            Execute(counter, s2);
     195            subscopeNr.Data++;
    177196          } // foreach
     197         
    178198
    179199          Execute(sorter, s);
     
    185205          Execute(dc, scope);
    186206          Execute(lci, scope);
     207          subscopeNr.Data = 0;
    187208          nrOfGenerations.Data++;
    188209        } // for i
Note: See TracChangeset for help on using the changeset viewer.