- Timestamp:
- 01/13/17 18:18:37 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs
r14556 r14563 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 33 using HeuristicLab.PluginInfrastructure; 34 using HeuristicLab.Random; 34 35 35 36 namespace HeuristicLab.Algorithms.MemPR.Grouping { … … 44 45 foreach (var trainer in ApplicationManager.Manager.GetInstances<ISolutionModelTrainer<LinearLinkageMemPRPopulationContext>>()) 45 46 SolutionModelTrainerParameter.ValidValues.Add(trainer); 46 47 48 if (SolutionModelTrainerParameter.ValidValues.Count > 0) { 49 var unbiased = SolutionModelTrainerParameter.ValidValues.FirstOrDefault(x => !x.Bias); 50 if (unbiased != null) SolutionModelTrainerParameter.Value = unbiased; 51 } 52 47 53 foreach (var localSearch in ApplicationManager.Manager.GetInstances<ILocalSearch<LinearLinkageMemPRSolutionContext>>()) { 48 54 LocalSearchParameter.ValidValues.Add(localSearch); … … 245 251 cache.Add(p2.Solution); 246 252 247 var cache hits = 0;253 var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 } }; 248 254 var evaluations = 0; 249 255 var probe = Context.ToScope((LinearLinkage)p1.Solution.Clone()); … … 251 257 while (evaluations < p1.Solution.Length) { 252 258 LinearLinkage c = null; 253 if (Context.Random.NextDouble() < 0.8) 254 c = GroupCrossover.Apply(Context.Random, p1.Solution, p2.Solution); 255 else c = SinglePointCrossover.Apply(Context.Random, p1.Solution, p2.Solution); 256 259 var xochoice = cacheHits.SampleRandom(Context.Random).Key; 260 switch (xochoice) { 261 case 0: c = GroupCrossover.Apply(Context.Random, p1.Solution, p2.Solution); break; 262 case 1: c = SinglePointCrossover.Apply(Context.Random, p1.Solution, p2.Solution); break; 263 } 257 264 if (cache.Contains(c)) { 258 cachehits++; 259 if (cachehits > 10) break; 265 cacheHits[xochoice]++; 266 if (cacheHits[xochoice] > 10) { 267 cacheHits.Remove(xochoice); 268 if (cacheHits.Count == 0) break; 269 } 260 270 continue; 261 271 } -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/SolutionModel/Univariate/UnbiasedModelTrainer.cs
r14552 r14563 33 33 public class UniasedModelTrainer<TContext> : NamedItem, ISolutionModelTrainer<TContext> 34 34 where TContext : IPopulationBasedHeuristicAlgorithmContext<ISingleObjectiveHeuristicOptimizationProblem, LinearLinkage>, ISolutionModelContext<LinearLinkage> { 35 35 36 public bool Bias { get { return false; } } 37 36 38 [StorableConstructor] 37 39 protected UniasedModelTrainer(bool deserializing) : base(deserializing) { }
Note: See TracChangeset
for help on using the changeset viewer.