Changeset 3601 for trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm
- Timestamp:
- 05/04/10 01:26:04 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
r3429 r3601 76 76 get { return (ConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; } 77 77 } 78 private ConstrainedValueParameter<I Selector> ImmigrationSelectorParameter {79 get { return (ConstrainedValueParameter<I Selector>)Parameters["ImmigrationSelector"]; }78 private ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter { 79 get { return (ConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; } 80 80 } 81 81 private ValueParameter<IntValue> PopulationSizeParameter { … … 134 134 set { EmigrantsSelectorParameter.Value = value; } 135 135 } 136 public I Selector ImmigrationSelector {137 get { return Immigration SelectorParameter.Value; }138 set { Immigration SelectorParameter.Value = value; }136 public IReplacer ImmigrationReplacer { 137 get { return ImmigrationReplacerParameter.Value; } 138 set { ImmigrationReplacerParameter.Value = value; } 139 139 } 140 140 public IntValue PopulationSize { … … 175 175 } 176 176 private List<ISelector> emigrantsSelectors; 177 private List<I Selector> immigrationSelectors;177 private List<IReplacer> immigrationReplacers; 178 178 private List<IMigrator> migrators; 179 179 private RandomCreator RandomCreator { … … 202 202 Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy.")); 203 203 Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); 204 Parameters.Add(new ConstrainedValueParameter<I Selector>("ImmigrationSelector", "Selects the population from the unification of the original population and the immigrants."));204 Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants.")); 205 205 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100))); 206 206 Parameters.Add(new ValueParameter<IntValue>("MaximumMigrations", "The maximum number of migrations that should occur.", new IntValue(100))); … … 238 238 239 239 mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name; 240 mainLoop.Immigration SelectorParameter.ActualName = ImmigrationSelectorParameter.Name;240 mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name; 241 241 mainLoop.MaximumMigrationsParameter.ActualName = MaximumMigrationsParameter.Name; 242 242 mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name; … … 380 380 emigrantsSelectors = new List<ISelector>(); 381 381 emigrantsSelectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)); 382 immigration Selectors = new List<ISelector>();383 immigration Selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name));382 immigrationReplacers = new List<IReplacer>(); 383 immigrationReplacers.AddRange(ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)); 384 384 ParameterizeSelectors(); 385 385 } … … 400 400 ParameterizeStochasticOperator(selector); 401 401 } 402 foreach (ISelector selector in immigrationSelectors) { 403 selector.CopySelected = new BoolValue(false); 404 selector.NumberOfSelectedSubScopesParameter.Value = PopulationSize; 405 ParameterizeStochasticOperator(selector); 402 foreach (IReplacer replacer in immigrationReplacers) { 403 ParameterizeStochasticOperator(replacer); 406 404 } 407 405 if (Problem != null) { … … 414 412 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 415 413 } 416 foreach (ISingleObjective Selector selector in immigrationSelectors.OfType<ISingleObjectiveSelector>()) {414 foreach (ISingleObjectiveReplacer selector in immigrationReplacers.OfType<ISingleObjectiveReplacer>()) { 417 415 selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 418 416 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; … … 443 441 } 444 442 445 oldSelector = ImmigrationSelectorParameter.Value;446 Immigration SelectorParameter.ValidValues.Clear();447 foreach (I Selector selector in immigrationSelectors)448 Immigration SelectorParameter.ValidValues.Add(selector);449 if (old Selector != null) {450 I Selector selector = ImmigrationSelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType());451 if ( selector != null) ImmigrationSelectorParameter.Value = selector;443 IReplacer oldReplacer = ImmigrationReplacerParameter.Value; 444 ImmigrationReplacerParameter.ValidValues.Clear(); 445 foreach (IReplacer replacer in immigrationReplacers) 446 ImmigrationReplacerParameter.ValidValues.Add(replacer); 447 if (oldReplacer != null) { 448 IReplacer replacer = ImmigrationReplacerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType()); 449 if (replacer != null) ImmigrationReplacerParameter.Value = replacer; 452 450 } 453 451 } -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs
r3376 r3601 70 70 get { return (ValueLookupParameter<IOperator>)Parameters["EmigrantsSelector"]; } 71 71 } 72 public ValueLookupParameter<IOperator> Immigration SelectorParameter {73 get { return (ValueLookupParameter<IOperator>)Parameters["Immigration Selector"]; }72 public ValueLookupParameter<IOperator> ImmigrationReplacerParameter { 73 get { return (ValueLookupParameter<IOperator>)Parameters["ImmigrationReplacer"]; } 74 74 } 75 75 public ValueLookupParameter<IntValue> PopulationSizeParameter { … … 107 107 } 108 108 #endregion 109 110 /*#region Properties111 private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {112 get { return (GeneticAlgorithmMainLoop)((UniformSubScopesProcessor)OperatorGraph.InitialOperator).Operator; }113 }114 #endregion*/115 109 116 110 [StorableConstructor] … … 128 122 Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy.")); 129 123 Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated.")); 130 Parameters.Add(new ValueLookupParameter<IOperator>("Immigration Selector", "Selects the population from the unification of the original population andthe immigrants."));124 Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces some of the original population with the immigrants.")); 131 125 Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions.")); 132 126 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumMigrations", "The maximum number of migrations after which the operator should terminate.")); … … 158 152 Placeholder migrator = new Placeholder(); 159 153 UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor(); 160 MergingReducer mergingReducer = new MergingReducer(); 161 Placeholder immigrationSelector = new Placeholder(); 162 RightReducer rightReducer = new RightReducer(); 154 Placeholder immigrationReplacer = new Placeholder(); 163 155 IntCounter migrationsCounter = new IntCounter(); 164 156 Comparator maxMigrationsComparator = new Comparator(); … … 238 230 migrator.OperatorParameter.ActualName = MigratorParameter.Name; 239 231 240 immigration Selector.Name = "Immigration Selector (placeholder)";241 immigration Selector.OperatorParameter.ActualName = ImmigrationSelectorParameter.Name;232 immigrationReplacer.Name = "Immigration Replacer (placeholder)"; 233 immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name; 242 234 243 235 migrationsCounter.Name = "Migrations + 1"; … … 293 285 emigrantsSelector.Successor = null; 294 286 migrator.Successor = ussp2; 295 ussp2.Operator = mergingReducer;287 ussp2.Operator = immigrationReplacer; 296 288 ussp2.Successor = migrationsCounter; 297 mergingReducer.Successor = immigrationSelector; 298 immigrationSelector.Successor = rightReducer; 299 rightReducer.Successor = null; 289 immigrationReplacer.Successor = null; 300 290 migrationsCounter.Successor = maxMigrationsComparator; 301 291 maxMigrationsComparator.Successor = bestQualityMemorizer3;
Note: See TracChangeset
for help on using the changeset viewer.