Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/03/16 00:32:09 (8 years ago)
Author:
abeham
Message:

#2701: working on MemPR implementation

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  
    2121
    2222using System.Linq;
     23using HeuristicLab.Algorithms.MemPR.Interfaces;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    25 using HeuristicLab.Encodings.BinaryVectorEncoding;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Optimization;
    27 using HeuristicLab.Optimization.SolutionModel;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Encodings.Binary.SolutionModel.Univariate {
    31   [Item("Uniased Univariate Model Trainer (binary)", "")]
     30namespace HeuristicLab.Algorithms.MemPR.Permutation.SolutionModel.Univariate {
     31  [Item("Unbiased Univariate Model Trainer (Permutation)", "", ExcludeGenericTypeInfo = true)]
    3232  [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> {
    3536   
    3637    [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    }
    4044
    4145    public override IDeepCloneable Clone(Cloner cloner) {
    42       return new UnbiasedModelTrainer<TContext>(this, cloner);
     46      return new UniasedModelTrainer<TContext>(this, cloner);
    4347    }
    4448
    4549    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);
    4751    }
    4852  }
Note: See TracChangeset for help on using the changeset viewer.