- Timestamp:
- 01/13/17 18:18:37 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/BinaryMemPR.cs
r14557 r14563 45 45 foreach (var trainer in ApplicationManager.Manager.GetInstances<ISolutionModelTrainer<BinaryMemPRPopulationContext>>()) 46 46 SolutionModelTrainerParameter.ValidValues.Add(trainer); 47 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 48 53 foreach (var localSearch in ApplicationManager.Manager.GetInstances<ILocalSearch<BinaryMemPRSolutionContext>>()) { 49 54 LocalSearchParameter.ValidValues.Add(localSearch); … … 156 161 cache.Add(p2.Solution); 157 162 158 var cacheHits = 0;163 var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 }, { 2, 0 } }; 159 164 ISingleObjectiveSolutionScope<BinaryVector> offspring = null; 165 160 166 while (evaluations < N) { 161 167 BinaryVector c = null; 162 var xochoice = Context.Random.Next(3);168 var xochoice = cacheHits.SampleRandom(Context.Random).Key; 163 169 switch (xochoice) { 164 170 case 0: c = NPointCrossover.Apply(Context.Random, p1.Solution, p2.Solution, new IntValue(1)); break; … … 167 173 } 168 174 if (cache.Contains(c)) { 169 cacheHits++; 170 if (cacheHits > 50) break; 175 cacheHits[xochoice]++; 176 if (cacheHits[xochoice] > 10) { 177 cacheHits.Remove(xochoice); 178 if (cacheHits.Count == 0) break; 179 } 171 180 continue; 172 181 } -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/BiasedModelTrainer.cs
r14552 r14563 36 36 where TContext : IPopulationBasedHeuristicAlgorithmContext<ISingleObjectiveHeuristicOptimizationProblem, BinaryVector>, ISolutionModelContext<BinaryVector> { 37 37 38 public bool Bias { get { return true; } } 39 38 40 [Storable] 39 41 private IValueParameter<EnumValue<ModelBiasOptions>> modelBiasParameter; -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnbiasedModelTrainer.cs
r14552 r14563 33 33 public class UniasedModelTrainer<TContext> : NamedItem, ISolutionModelTrainer<TContext> 34 34 where TContext : IPopulationBasedHeuristicAlgorithmContext<ISingleObjectiveHeuristicOptimizationProblem, BinaryVector>, ISolutionModelContext<BinaryVector> { 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.