Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/14/10 23:32:27 (14 years ago)
Author:
swagner
Message:

Renamed PopulationCreator to SolutionsCreator (#911)

Location:
trunk/sources/HeuristicLab.Optimization.Operators/3.3
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj

    r3021 r3023  
    8282  <ItemGroup>
    8383    <Compile Include="HeuristicLabOptimizationOperatorsPlugin.cs" />
    84     <Compile Include="PopulationCreator.cs" />
    8584    <Compile Include="Properties\AssemblyInfo.cs" />
    8685    <Compile Include="ChildrenCreator.cs" />
     86    <Compile Include="SolutionsCreator.cs" />
    8787  </ItemGroup>
    8888  <ItemGroup>
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SolutionsCreator.cs

    r3021 r3023  
    2929namespace HeuristicLab.Optimization.Operators {
    3030  /// <summary>
    31   /// An operator which creates a new population of solutions.
     31  /// An operator which creates new solutions.
    3232  /// </summary>
    33   [Item("PopulationCreator", "An operator which creates a new population of solutions.")]
     33  [Item("SolutionsCreator", "An operator which creates new solutions.")]
    3434  [StorableClass]
    3535  [Creatable("Test")]
    36   public sealed class PopulationCreator : SingleSuccessorOperator {
    37     public ValueLookupParameter<IntData> PopulationSizeParameter {
    38       get { return (ValueLookupParameter<IntData>)Parameters["PopulationSize"]; }
     36  public sealed class SolutionsCreator : SingleSuccessorOperator {
     37    public ValueLookupParameter<IntData> NumberOfSolutionsParameter {
     38      get { return (ValueLookupParameter<IntData>)Parameters["NumberOfSolutions"]; }
    3939    }
    4040    public ValueLookupParameter<IOperator> SolutionCreatorParameter {
     
    5151    }
    5252
    53     public PopulationCreator()
     53    public SolutionsCreator()
    5454      : base() {
    55       Parameters.Add(new ValueLookupParameter<IntData>("PopulationSize", "The number of individuals that should be created."));
     55      Parameters.Add(new ValueLookupParameter<IntData>("NumberOfSolutions", "The number of solutions that should be created."));
    5656      Parameters.Add(new ValueLookupParameter<IOperator>("SolutionCreator", "The operator which is used to create new solutions."));
    5757      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions."));
    58       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents the population."));
     58      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new solutions are added as sub-scopes."));
    5959    }
    6060
    6161    public override IOperation Apply() {
    62       int size = PopulationSizeParameter.ActualValue.Value;
     62      int count = NumberOfSolutionsParameter.ActualValue.Value;
    6363      IOperator creator = SolutionCreatorParameter.ActualValue;
    6464      IOperator evaluator = EvaluatorParameter.ActualValue;
    6565
    66       if (CurrentScope.SubScopes.Count > 0) throw new InvalidOperationException("Population is not empty. PopulationCreator cannot be applied on scopes which already contain sub-scopes.");
    67 
    68       for (int i = 0; i < size; i++)
    69         CurrentScope.SubScopes.Add(new Scope(i.ToString()));
     66      int current = CurrentScope.SubScopes.Count;
     67      for (int i = 0; i < count; i++)
     68        CurrentScope.SubScopes.Add(new Scope((current + i).ToString()));
    7069
    7170      OperationCollection next = new OperationCollection();
    72       for (int i = 0; i < CurrentScope.SubScopes.Count; i++) {
    73         if (creator != null) next.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[i]));
    74         if (evaluator != null) next.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[i]));
     71      for (int i = 0; i < count; i++) {
     72        if (creator != null) next.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i]));
     73        if (evaluator != null) next.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[current + i]));
    7574      }
    7675      next.Add(base.Apply());
Note: See TracChangeset for help on using the changeset viewer.