Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/12 19:01:21 (12 years ago)
Author:
jkarder
Message:

#1331:

  • added custom crossover operator (NChildCrossover)
  • added parameters and adjusted types
  • replaced SolutionCombinationMethod with a placeholder
  • adjusted event handling
  • changed access levels
  • minor code improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/PopulationRebuildMethod.cs

    r7724 r7740  
    3030namespace HeuristicLab.Algorithms.ScatterSearch {
    3131  /// <summary>
    32   /// An operator that updates a population.
     32  /// An operator that updates the reference set and rebuilds the population.
    3333  /// </summary>
    34   [Item("PopulationRebuildMethod", "An operator that rebuilds the population.")]
     34  [Item("PopulationRebuildMethod", "An operator that updates the reference set and rebuilds the population.")]
    3535  [StorableClass]
    3636  public sealed class PopulationRebuildMethod : SingleSuccessorOperator {
    3737    #region Parameter properties
    38     private ScopeParameter CurrentScopeParameter {
     38    public ScopeParameter CurrentScopeParameter {
    3939      get { return (ScopeParameter)Parameters["CurrentScope"]; }
    4040    }
    41     private ValueLookupParameter<IntValue> NumberOfHighQualitySolutionsParameter {
    42       get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfHighQualitySolutions"]; }
     41    public IValueLookupParameter<IntValue> NumberOfHighQualitySolutionsParameter {
     42      get { return (IValueLookupParameter<IntValue>)Parameters["NumberOfHighQualitySolutions"]; }
    4343    }
    44     private ValueLookupParameter<IntValue> ReferenceSetSizeParameter {
    45       get { return (ValueLookupParameter<IntValue>)Parameters["ReferenceSetSize"]; }
     44    public IValueLookupParameter<IntValue> ReferenceSetSizeParameter {
     45      get { return (IValueLookupParameter<IntValue>)Parameters["ReferenceSetSize"]; }
     46    }
     47    public IValueLookupParameter<IItem> QualityParameter {
     48      get { return (IValueLookupParameter<IItem>)Parameters["Quality"]; }
    4649    }
    4750    #endregion
     
    5962      set { ReferenceSetSizeParameter.ActualValue = value; }
    6063    }
     64    private IItem Quality {
     65      get { return QualityParameter.ActualValue; }
     66    }
    6167    #endregion
    6268
     
    7278    private void Initialize() {
    7379      #region Create parameters
    74       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new solutions are added as sub-scopes."));
    75       Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions that should be added to the reference set."));
    76       Parameters.Add(new ValueLookupParameter<IntValue>("ReferenceSetSize", "The size of the reference set."));
    77       #endregion
    78 
    79       #region Create operators
    80       #endregion
    81 
    82       #region Create operator graph
     80      Parameters.Add(new ScopeParameter("CurrentScope"));
     81      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfHighQualitySolutions"));
     82      Parameters.Add(new ValueLookupParameter<IntValue>("ReferenceSetSize"));
     83      Parameters.Add(new ValueLookupParameter<IItem>("Quality"));
    8384      #endregion
    8485    }
    8586
    8687    public override IOperation Apply() {
    87       IScope population = CurrentScope.SubScopes[0];
    88       IScope refSet = CurrentScope.SubScopes[1];
    89       refSet.SubScopes.Replace(refSet.SubScopes.OrderByDescending(r => r.Variables["Quality"].Value)
     88      var population = CurrentScope.SubScopes[0];
     89      var refSet = CurrentScope.SubScopes[1];
     90      refSet.SubScopes.Replace(refSet.SubScopes.OrderByDescending(r => r.Variables[QualityParameter.ActualName].Value)
    9091                                               .Take(NumberOfHighQualitySolutions.Value).ToList());
    9192      population.SubScopes.Clear();
Note: See TracChangeset for help on using the changeset viewer.