Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/11 06:17:50 (13 years ago)
Author:
swagner
Message:

Adapted EAs to enable parallel solution evaluation (#1333)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SolutionsCreator.cs

    r4722 r5208  
    2929namespace HeuristicLab.Optimization.Operators {
    3030  /// <summary>
    31   /// An operator which creates new solutions.
     31  /// An operator which creates new solutions. Evaluation of the new solutions is executed in parallel, if an engine is used which supports parallelization.
    3232  /// </summary>
    33   [Item("SolutionsCreator", "An operator which creates new solutions.")]
     33  [Item("SolutionsCreator", "An operator which creates new solutions. Evaluation of the new solutions is executed in parallel, if an engine is used which supports parallelization.")]
    3434  [StorableClass]
    3535  public sealed class SolutionsCreator : SingleSuccessorOperator {
     
    6161      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfSolutions", "The number of solutions that should be created."));
    6262      Parameters.Add(new ValueLookupParameter<IOperator>("SolutionCreator", "The operator which is used to create new solutions."));
    63       Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions."));
     63      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
    6464      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new solutions are added as sub-scopes."));
    6565    }
     
    7878        CurrentScope.SubScopes.Add(new Scope((current + i).ToString()));
    7979
     80      OperationCollection creation = new OperationCollection();
     81      OperationCollection evaluation = new OperationCollection() { Parallel = true };
     82      for (int i = 0; i < count; i++) {
     83        if (creator != null) creation.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i]));
     84        if (evaluator != null) evaluation.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[current + i]));
     85      }
    8086      OperationCollection next = new OperationCollection();
    81       for (int i = 0; i < count; i++) {
    82         if (creator != null) next.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i]));
    83         if (evaluator != null) next.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[current + i]));
    84       }
     87      next.Add(creation);
     88      next.Add(evaluation);
    8589      next.Add(base.Apply());
    8690      return next;
Note: See TracChangeset for help on using the changeset viewer.