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/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  
    2121
    2222using System.Linq;
     23using HeuristicLab.Algorithms.MemPR.Interfaces;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2527using HeuristicLab.Encodings.BinaryVectorEncoding;
    2628using HeuristicLab.Optimization;
    27 using HeuristicLab.Optimization.SolutionModel;
     29using HeuristicLab.Parameters;
    2830using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2931
    30 namespace HeuristicLab.Encodings.Binary.SolutionModel.Univariate {
    31   [Item("Biased Univariate Model Trainer (binary)", "")]
     32namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
     33  [Item("Biased Univariate Model Trainer (binary)", "", ExcludeGenericTypeInfo = true)]
    3234  [StorableClass]
    33   public class BiasedModelTrainer<TContext> : BiasedModelTrainerOperator, IBinarySolutionModelTrainer<TContext>, IBinaryVectorOperator
    34     where TContext : ISingleObjectivePopulationContext<BinaryVector>, ISolutionModelContext<BinaryVector>, IStochasticContext, IMaximizationContext {
     35  public class BiasedModelTrainer<TContext> : ParameterizedNamedItem, ISolutionModelTrainer<TContext>
     36    where TContext : IPopulationBasedHeuristicAlgorithmContext<SingleObjectiveBasicProblem<BinaryVectorEncoding>, BinaryVector>, ISolutionModelContext<BinaryVector> {
    3537   
     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
    3645    [StorableConstructor]
    3746    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    }
    4054
    4155    public override IDeepCloneable Clone(Cloner cloner) {
     
    4458
    4559    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));
    4761    }
    4862  }
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/StaticAPI/Trainer.cs

    r14449 r14450  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Algorithms.MemPR.Interfaces;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.BinaryVectorEncoding;
    26 using HeuristicLab.Optimization.SolutionModel;
    2727
    28 namespace HeuristicLab.Encodings.Binary.SolutionModel.Univariate {
     28namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
    2929  public enum ModelBiasOptions { Rank, Fitness }
    3030
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnbiasedModelTrainer.cs

    r14420 r14450  
    2121
    2222using System.Linq;
     23using HeuristicLab.Algorithms.MemPR.Interfaces;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.BinaryVectorEncoding;
    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.Binary.SolutionModel.Univariate {
     31  [Item("Unbiased Univariate Model Trainer (binary)", "", 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<BinaryVectorEncoding>, BinaryVector>, ISolutionModelContext<BinaryVector> {
    3535   
    3636    [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    }
    4043
    4144    public override IDeepCloneable Clone(Cloner cloner) {
    42       return new UnbiasedModelTrainer<TContext>(this, cloner);
     45      return new UniasedModelTrainer<TContext>(this, cloner);
    4346    }
    4447
    4548    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));
    4750    }
    4851  }
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnivariateSolutionModel.cs

    r14420 r14450  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Algorithms.MemPR.Interfaces;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
    2829using HeuristicLab.Encodings.BinaryVectorEncoding;
    29 using HeuristicLab.Optimization.SolutionModel;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3131using HeuristicLab.Random;
    3232
    33 namespace HeuristicLab.Encodings.Binary.SolutionModel.Univariate {
     33namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
    3434  [Item("Univariate solution model (binary)", "")]
    3535  [StorableClass]
Note: See TracChangeset for help on using the changeset viewer.