Changeset 14450 for branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Permutation/SolutionModel
- Timestamp:
- 12/03/16 00:32:09 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Permutation
- Files:
-
- 7 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Permutation/SolutionModel/Univariate/UnbiasedModelTrainer.cs
r14429 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 using HeuristicLab.Encodings. BinaryVectorEncoding;26 using HeuristicLab.Encodings.PermutationEncoding; 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.Permutation.SolutionModel.Univariate { 31 [Item("Unbiased Univariate Model Trainer (Permutation)", "", ExcludeGenericTypeInfo = true)] 32 32 [StorableClass] 33 public class UnbiasedModelTrainer<TContext> : UnbiasedModelTrainerOperator, IBinarySolutionModelTrainer<TContext> 34 where TContext : ISolutionModelContext<BinaryVector>, IPopulationContext<BinaryVector>, IStochasticContext { 33 public class UniasedModelTrainer<TContext> : NamedItem, ISolutionModelTrainer<TContext> 34 where TContext : IPopulationBasedHeuristicAlgorithmContext<SingleObjectiveBasicProblem<PermutationEncoding>, Encodings.PermutationEncoding.Permutation>, 35 ISolutionModelContext<Encodings.PermutationEncoding.Permutation> { 35 36 36 37 [StorableConstructor] 37 protected UnbiasedModelTrainer(bool deserializing) : base(deserializing) { } 38 protected UnbiasedModelTrainer(UnbiasedModelTrainer<TContext> original, Cloner cloner) : base(original, cloner) { } 39 public UnbiasedModelTrainer() { } 38 protected UniasedModelTrainer(bool deserializing) : base(deserializing) { } 39 protected UniasedModelTrainer(UniasedModelTrainer<TContext> original, Cloner cloner) : base(original, cloner) { } 40 public UniasedModelTrainer() { 41 Name = ItemName; 42 Description = ItemDescription; 43 } 40 44 41 45 public override IDeepCloneable Clone(Cloner cloner) { 42 return new Un biasedModelTrainer<TContext>(this, cloner);46 return new UniasedModelTrainer<TContext>(this, cloner); 43 47 } 44 48 45 49 public void TrainModel(TContext context) { 46 context.Model = UnivariateModel.CreateWithoutBias(context.Random, context.Population.Select(x => x.Solution));50 context.Model = Trainer.Train(context.Random, context.Population.Select(x => x.Solution).ToList(), context.Problem.Encoding.Length); 47 51 } 48 52 }
Note: See TracChangeset
for help on using the changeset viewer.