Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3023


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

Renamed PopulationCreator to SolutionsCreator (#911)

Location:
trunk/sources
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGA.cs

    r3021 r3023  
    120120      get { return (RandomCreator)OperatorGraph.InitialOperator; }
    121121    }
    122     private PopulationCreator PopulationCreator {
    123       get { return (PopulationCreator)RandomCreator.Successor; }
     122    private SolutionsCreator SolutionsCreator {
     123      get { return (SolutionsCreator)RandomCreator.Successor; }
    124124    }
    125125    private SGAMainLoop SGAMainLoop {
    126       get { return (SGAMainLoop)PopulationCreator.Successor; }
     126      get { return (SGAMainLoop)SolutionsCreator.Successor; }
    127127    }
    128128    private List<ISelector> selectors;
     
    145145
    146146      RandomCreator randomCreator = new RandomCreator();
    147       PopulationCreator populationCreator = new PopulationCreator();
     147      SolutionsCreator solutionsCreator = new SolutionsCreator();
    148148      SGAMainLoop sgaMainLoop = new SGAMainLoop();
    149149      OperatorGraph.InitialOperator = randomCreator;
     
    154154      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
    155155      randomCreator.SetSeedRandomlyParameter.Value = null;
    156       randomCreator.Successor = populationCreator;
    157 
    158       populationCreator.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
    159       populationCreator.Successor = sgaMainLoop;
     156      randomCreator.Successor = solutionsCreator;
     157
     158      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
     159      solutionsCreator.Successor = sgaMainLoop;
    160160
    161161      sgaMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
     
    184184      ParameterizeStochasticOperator(Problem.Evaluator);
    185185      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
    186       ParameterizePopulationCreator();
     186      ParameterizeSolutionsCreator();
    187187      ParameterizeSGAMainLoop();
    188188      ParameterizeSelectors();
     
    194194    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
    195195      ParameterizeStochasticOperator(Problem.SolutionCreator);
    196       ParameterizePopulationCreator();
     196      ParameterizeSolutionsCreator();
    197197      base.Problem_SolutionCreatorChanged(sender, e);
    198198    }
    199199    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
    200200      ParameterizeStochasticOperator(Problem.Evaluator);
    201       ParameterizePopulationCreator();
     201      ParameterizeSolutionsCreator();
    202202      ParameterizeSGAMainLoop();
    203203      ParameterizeSelectors();
     
    244244    }
    245245
    246     private void ParameterizePopulationCreator() {
    247       PopulationCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    248       PopulationCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     246    private void ParameterizeSolutionsCreator() {
     247      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     248      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    249249    }
    250250    private void ParameterizeSGAMainLoop() {
  • 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.