Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2129


Ignore:
Timestamp:
07/02/09 12:25:32 (15 years ago)
Author:
dtraxing
Message:

Algorithm continuation bug fixed. (ticket #580)

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

Legend:

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

    r2120 r2129  
    180180      Execute(mr, scope);
    181181      Execute(sorter, scope);
     182
    182183    } // DoReplacement
    183184 
  • trunk/sources/HeuristicLab.FixedOperators/3.2/FixedOSGAMain.cs

    r2120 r2129  
    6666      IScope s;
    6767      IScope s2;
     68      bool loopSkipped = true;
     69      bool running = false;
    6870
    6971      DoubleData selectionPressure = null;
     
    105107              Execute(wofc, s2);
    106108              Execute(sr, s2);
     109              loopSkipped = false;
     110            } // foreach
    107111
    108             } // foreach
    109             subscopeNr.Data = 0;
     112            // if for loop skipped, we had to add skiped operations
     113            // to execution pointer.
     114            if (loopSkipped)
     115              executionPointer += 5;
    110116
    111117            Execute(sorter, s);
    112118            ////// END Create Children //////
    113 
    114 
    115           } while (os.Execute(scope) != null);
     119           
     120            running = ExecuteFirstOperator(os, scope);
     121            if (running) subscopeNr.Data = 0;
     122          } while (running);
    116123
    117124          DoReplacement(scope);
     
    129136            break;
    130137
     138          subscopeNr.Data = 0;
    131139          ResetExecutionPointer();
    132140        } // for i generations
  • trunk/sources/HeuristicLab.FixedOperators/3.2/FixedOperatorBase.cs

    r2120 r2129  
    7070    } // SetRegion
    7171
     72    /// <summary>
     73    /// Executes only the operator op, suboperator are wont be executed.
     74    /// </summary>
     75    /// <param name="op">Operator to execute.</param>
     76    /// <param name="scope">Scope on which operator is executed.</param>
     77    /// <returns>True, if operator has suboperators after execution. </returns>
     78    protected virtual bool ExecuteFirstOperator(IOperator op, IScope scope){
     79      bool suboperatorsExist = false;
     80     
     81      if (!IsExecuted()) {
     82        suboperatorsExist = op.Execute(scope) != null;
     83        persistedExecutionPointer.Data++;
     84      } // if not executed
     85      executionPointer++;
     86
     87      if (Canceled)
     88        throw new CancelException();
     89
     90      return suboperatorsExist;
     91    } // ExecuteFirstOperator
     92
    7293    protected virtual void Execute(IOperator op, IScope scope) {
    7394      if (!IsExecuted()) {
     
    90111        }
    91112      } else {
    92         executionStack = new Stack<IOperation>(persistedOperations); 
     113        executionStack = new Stack<IOperation>(persistedOperations);
     114        persistedOperations.Clear();
    93115      }
    94116
     
    121143
    122144    private void SaveExecutionStack(Stack<IOperation> stack) {
    123       persistedOperations = new ItemList<IOperation>();
     145      persistedOperations.Clear();
    124146      persistedOperations.AddRange(stack.ToArray());
    125147    } // SaveExecutionStack
  • trunk/sources/HeuristicLab.FixedOperators/3.2/FixedSGAMain.cs

    r2120 r2129  
    333333      IScope s;
    334334      IScope s2;
    335 
     335      bool loopSkipped = true;
     336
     337      tempExePointer = new int[10];
     338      tempPersExePointer = new int[10];
     339     
    336340      try {
    337341        for (; nrOfGenerations.Data < maxGenerations.Data; nrOfGenerations.Data++) {
     
    368372            Execute(sr, s2);
    369373            Execute(counter, s2);
     374            loopSkipped = false;
    370375          } // foreach
     376
     377          // if for loop skipped, we had to add skiped operations
     378          // to execution pointer.
     379          if (loopSkipped)
     380            executionPointer += 5;
    371381
    372382          Execute(sorter, s);
     
    394404        return new AtomicOperation(this, scope);
    395405      }
     406      catch (Exception ex) {
     407        ex.ToString();
     408      }
    396409
    397410      return null;
Note: See TracChangeset for help on using the changeset viewer.