Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6430 for trunk


Ignore:
Timestamp:
06/16/11 14:12:42 (13 years ago)
Author:
cneumuel
Message:

#1558 added Parallel parameter for solutions creator

File:
1 edited

Legend:

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

    r5445 r6430  
    4343      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
    4444    }
     45    public ValueLookupParameter<BoolValue> ParallelParameter {
     46      get { return (ValueLookupParameter<BoolValue>)Parameters["Parallel"]; }
     47    }
    4548    private ScopeParameter CurrentScopeParameter {
    4649      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     
    6265      Parameters.Add(new ValueLookupParameter<IOperator>("SolutionCreator", "The operator which is used to create new solutions."));
    6366      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."));
    64       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new solutions are added as sub-scopes."));
     67      Parameters.Add(new ValueLookupParameter<BoolValue>("Parallel", "True if the operator should be applied in parallel on all sub-scopes, otherwise false.", new BoolValue(true)));
     68      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new solutions are added as sub-scopes."));     
     69    }
     70    [StorableHook(HookType.AfterDeserialization)]
     71    private void AfterDeserialization() {
     72      if (!Parameters.ContainsKey("Parallel")) Parameters.Add(new ValueLookupParameter<BoolValue>("Parallel", "True if the operator should be applied in parallel on all sub-scopes, otherwise false.", new BoolValue(true))); // backwards compatibility
    6573    }
    6674
     
    7381      IOperator creator = SolutionCreatorParameter.ActualValue;
    7482      IOperator evaluator = EvaluatorParameter.ActualValue;
     83      bool parallel = ParallelParameter.ActualValue.Value;
    7584
    7685      int current = CurrentScope.SubScopes.Count;
     
    7988
    8089      OperationCollection creation = new OperationCollection();
    81       OperationCollection evaluation = new OperationCollection() { Parallel = true };
     90      OperationCollection evaluation = new OperationCollection() { Parallel = parallel };
    8291      for (int i = 0; i < count; i++) {
    8392        if (creator != null) creation.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i]));
Note: See TracChangeset for help on using the changeset viewer.