Changeset 14557 for branches/MemPRAlgorithm
- Timestamp:
- 01/11/17 02:18:19 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/BinaryMemPR.cs
r14556 r14557 160 160 while (evaluations < N) { 161 161 BinaryVector c = null; 162 var xochoice = Context.Random.Next Double();163 if (xochoice < 0.2)164 c = NPointCrossover.Apply(Context.Random, p1.Solution, p2.Solution, new IntValue(1));165 else if (xochoice < 0.5)166 c = NPointCrossover.Apply(Context.Random, p1.Solution, p2.Solution, new IntValue(2));167 else c = UniformCrossover.Apply(Context.Random, p1.Solution, p2.Solution);162 var xochoice = Context.Random.Next(3); 163 switch (xochoice) { 164 case 0: c = NPointCrossover.Apply(Context.Random, p1.Solution, p2.Solution, new IntValue(1)); break; 165 case 1: c = NPointCrossover.Apply(Context.Random, p1.Solution, p2.Solution, new IntValue(2)); break; 166 case 2: c = UniformCrossover.Apply(Context.Random, p1.Solution, p2.Solution); break; 167 } 168 168 if (cache.Contains(c)) { 169 169 cacheHits++; 170 if (cacheHits > 20) break;170 if (cacheHits > 50) break; 171 171 continue; 172 172 } -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/MemPRAlgorithm.cs
r14556 r14557 254 254 offspring = Breed(token); 255 255 if (offspring != null) { 256 if (Context.PopulationCount < MaximumPopulationSize)257 AdaptiveClimb(offspring, Context.LocalSearchEvaluations, token);258 256 var replNew = Replace(offspring, token); 259 257 if (replNew) { … … 265 263 offspring = Relink(token); 266 264 if (offspring != null) { 267 if (Context.PopulationCount < MaximumPopulationSize)268 AdaptiveClimb(offspring, Context.LocalSearchEvaluations, token);269 265 if (Replace(offspring, token)) { 270 266 replaced = true; … … 275 271 offspring = Delink(token); 276 272 if (offspring != null) { 277 if (Context.PopulationCount < MaximumPopulationSize)278 AdaptiveClimb(offspring, Context.LocalSearchEvaluations, token);279 273 if (Replace(offspring, token)) { 280 274 replaced = true; … … 285 279 offspring = Sample(token); 286 280 if (offspring != null) { 287 if (Context.PopulationCount < MaximumPopulationSize)288 AdaptiveClimb(offspring, Context.LocalSearchEvaluations, token);289 281 if (Replace(offspring, token)) { 290 282 replaced = true; … … 295 287 if (!replaced && offspring != null) { 296 288 if (Context.HillclimbingSuited(offspring)) { 297 AdaptiveClimb(offspring, Context.LocalSearchEvaluations, token);289 HillClimb(offspring, token, CalculateSubspace(Context.Population.Select(x => x.Solution))); 298 290 if (Replace(offspring, token)) { 299 291 Context.ByHillclimbing++;
Note: See TracChangeset
for help on using the changeset viewer.