- Timestamp:
- 12/03/16 00:32:09 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate
- Files:
-
- 1 added
- 2 deleted
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/BiasedModelTrainer.cs
r14420 r14450 21 21 22 22 using System.Linq; 23 using HeuristicLab.Algorithms.MemPR.Interfaces; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 25 27 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 28 using HeuristicLab.Optimization; 27 using HeuristicLab. Optimization.SolutionModel;29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 31 30 namespace HeuristicLab. Encodings.Binary.SolutionModel.Univariate {31 [Item("Biased Univariate Model Trainer (binary)", "" )]32 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate { 33 [Item("Biased Univariate Model Trainer (binary)", "", ExcludeGenericTypeInfo = true)] 32 34 [StorableClass] 33 public class BiasedModelTrainer<TContext> : BiasedModelTrainerOperator, IBinarySolutionModelTrainer<TContext>, IBinaryVectorOperator34 where TContext : I SingleObjectivePopulationContext<BinaryVector>, ISolutionModelContext<BinaryVector>, IStochasticContext, IMaximizationContext{35 public class BiasedModelTrainer<TContext> : ParameterizedNamedItem, ISolutionModelTrainer<TContext> 36 where TContext : IPopulationBasedHeuristicAlgorithmContext<SingleObjectiveBasicProblem<BinaryVectorEncoding>, BinaryVector>, ISolutionModelContext<BinaryVector> { 35 37 38 [Storable] 39 private IValueParameter<EnumValue<ModelBiasOptions>> modelBiasParameter; 40 public ModelBiasOptions ModelBias { 41 get { return modelBiasParameter.Value.Value; } 42 set { modelBiasParameter.Value.Value = value; } 43 } 44 36 45 [StorableConstructor] 37 46 protected BiasedModelTrainer(bool deserializing) : base(deserializing) { } 38 protected BiasedModelTrainer(BiasedModelTrainer<TContext> original, Cloner cloner) : base(original, cloner) { } 39 public BiasedModelTrainer() { } 47 protected BiasedModelTrainer(BiasedModelTrainer<TContext> original, Cloner cloner) 48 : base(original, cloner) { 49 modelBiasParameter = cloner.Clone(original.modelBiasParameter); 50 } 51 public BiasedModelTrainer() { 52 Parameters.Add(modelBiasParameter = new ValueParameter<EnumValue<ModelBiasOptions>>("Model Bias", "What kind of bias towards better individuals is chosen.")); 53 } 40 54 41 55 public override IDeepCloneable Clone(Cloner cloner) { … … 44 58 45 59 public void TrainModel(TContext context) { 46 context.Model = Trainer.TrainBiased(ModelBias, context.Random, context. Maximization, context.Population.Select(x => x.Solution), context.Population.Select(x => x.Fitness));60 context.Model = Trainer.TrainBiased(ModelBias, context.Random, context.Problem.Maximization, context.Population.Select(x => x.Solution), context.Population.Select(x => x.Fitness)); 47 61 } 48 62 } -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/StaticAPI/Trainer.cs
r14449 r14450 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Algorithms.MemPR.Interfaces; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 using HeuristicLab.Optimization.SolutionModel;27 27 28 namespace HeuristicLab. Encodings.Binary.SolutionModel.Univariate {28 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate { 29 29 public enum ModelBiasOptions { Rank, Fitness } 30 30 -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnbiasedModelTrainer.cs
r14420 r14450 21 21 22 22 using System.Linq; 23 using HeuristicLab.Algorithms.MemPR.Interfaces; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 27 using HeuristicLab.Optimization; 27 using HeuristicLab.Optimization.SolutionModel;28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 namespace HeuristicLab. Encodings.Binary.SolutionModel.Univariate {31 [Item("Un iased Univariate Model Trainer (binary)", "")]30 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate { 31 [Item("Unbiased Univariate Model Trainer (binary)", "", ExcludeGenericTypeInfo = true)] 32 32 [StorableClass] 33 public class Un biasedModelTrainer<TContext> : UnbiasedModelTrainerOperator, IBinarySolutionModelTrainer<TContext>34 where TContext : I SolutionModelContext<BinaryVector>, IPopulationContext<BinaryVector>, IStochasticContext{33 public class UniasedModelTrainer<TContext> : NamedItem, ISolutionModelTrainer<TContext> 34 where TContext : IPopulationBasedHeuristicAlgorithmContext<SingleObjectiveBasicProblem<BinaryVectorEncoding>, BinaryVector>, ISolutionModelContext<BinaryVector> { 35 35 36 36 [StorableConstructor] 37 protected UnbiasedModelTrainer(bool deserializing) : base(deserializing) { } 38 protected UnbiasedModelTrainer(UnbiasedModelTrainer<TContext> original, Cloner cloner) : base(original, cloner) { } 39 public UnbiasedModelTrainer() { } 37 protected UniasedModelTrainer(bool deserializing) : base(deserializing) { } 38 protected UniasedModelTrainer(UniasedModelTrainer<TContext> original, Cloner cloner) : base(original, cloner) { } 39 public UniasedModelTrainer() { 40 Name = ItemName; 41 Description = ItemDescription; 42 } 40 43 41 44 public override IDeepCloneable Clone(Cloner cloner) { 42 return new Un biasedModelTrainer<TContext>(this, cloner);45 return new UniasedModelTrainer<TContext>(this, cloner); 43 46 } 44 47 45 48 public void TrainModel(TContext context) { 46 context.Model = UnivariateModel.CreateWithoutBias(context.Random, context.Population.Select(x => x.Solution));49 context.Model = Trainer.TrainUnbiased(context.Random, context.Population.Select(x => x.Solution)); 47 50 } 48 51 } -
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnivariateSolutionModel.cs
r14420 r14450 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Algorithms.MemPR.Interfaces; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Encodings.BinaryVectorEncoding; 29 using HeuristicLab.Optimization.SolutionModel;30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 31 using HeuristicLab.Random; 32 32 33 namespace HeuristicLab. Encodings.Binary.SolutionModel.Univariate {33 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate { 34 34 [Item("Univariate solution model (binary)", "")] 35 35 [StorableClass]
Note: See TracChangeset
for help on using the changeset viewer.