Changeset 7740 for branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/PopulationRebuildMethod.cs
- Timestamp:
- 04/18/12 19:01:21 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/PopulationRebuildMethod.cs
r7724 r7740 30 30 namespace HeuristicLab.Algorithms.ScatterSearch { 31 31 /// <summary> 32 /// An operator that updates apopulation.32 /// An operator that updates the reference set and rebuilds the population. 33 33 /// </summary> 34 [Item("PopulationRebuildMethod", "An operator that rebuilds the population.")]34 [Item("PopulationRebuildMethod", "An operator that updates the reference set and rebuilds the population.")] 35 35 [StorableClass] 36 36 public sealed class PopulationRebuildMethod : SingleSuccessorOperator { 37 37 #region Parameter properties 38 p rivateScopeParameter CurrentScopeParameter {38 public ScopeParameter CurrentScopeParameter { 39 39 get { return (ScopeParameter)Parameters["CurrentScope"]; } 40 40 } 41 p rivateValueLookupParameter<IntValue> NumberOfHighQualitySolutionsParameter {42 get { return ( ValueLookupParameter<IntValue>)Parameters["NumberOfHighQualitySolutions"]; }41 public IValueLookupParameter<IntValue> NumberOfHighQualitySolutionsParameter { 42 get { return (IValueLookupParameter<IntValue>)Parameters["NumberOfHighQualitySolutions"]; } 43 43 } 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"]; } 46 49 } 47 50 #endregion … … 59 62 set { ReferenceSetSizeParameter.ActualValue = value; } 60 63 } 64 private IItem Quality { 65 get { return QualityParameter.ActualValue; } 66 } 61 67 #endregion 62 68 … … 72 78 private void Initialize() { 73 79 #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")); 83 84 #endregion 84 85 } 85 86 86 87 public override IOperation Apply() { 87 IScopepopulation = CurrentScope.SubScopes[0];88 IScoperefSet = 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) 90 91 .Take(NumberOfHighQualitySolutions.Value).ToList()); 91 92 population.SubScopes.Clear();
Note: See TracChangeset
for help on using the changeset viewer.