Changeset 11582


Ignore:
Timestamp:
11/25/14 13:05:14 (8 years ago)
Author:
mkommend
Message:

#2174: Configured solution creator in single encodings.

Location:
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/BinaryEncoding.cs

    r11575 r11582  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Encodings.BinaryVectorEncoding;
    29 using HeuristicLab.Optimization;
    3029using HeuristicLab.Parameters;
    3130using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    7473      : base(name) {
    7574      lengthParameter = new FixedValueParameter<IntValue>(Name + "Length", new IntValue(length));
     75      RegisterParameterEvents();
     76      DiscoverOperators();
     77      SolutionCreator = Operators.OfType<RandomBinaryVectorCreator>().Single();
    7678    }
    7779
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs

    r11559 r11582  
    4949
    5050
    51     ISolutionCreator IEncoding.DefaultSolutionCreator { get { return DefaultSolutionCreator; } }
    52     public virtual T DefaultSolutionCreator {
    53       get { return null; }
    54     }
    55 
    56 
    5751    ISolutionCreator IEncoding.SolutionCreator {
    5852      get { return SolutionCreator; }
     
    6559    public T SolutionCreator {
    6660      get {
    67         if (solutionCreator == null) return DefaultSolutionCreator;
    6861        return solutionCreator;
    6962      }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs

    r11561 r11582  
    8787      boundsParameter = cloner.Clone(original.boundsParameter);
    8888      RegisterParameterEvents();
    89       DiscoverOperators();
    9089    }
    9190    public override IDeepCloneable Clone(Cloner cloner) { return new IntegerEncoding(this, cloner); }
     
    102101      RegisterParameterEvents();
    103102      DiscoverOperators();
     103      SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single();
    104104    }
    105105    public IntegerEncoding(string name, int length, IList<int> min, IList<int> max, IList<int> step = null)
     
    118118      RegisterParameterEvents();
    119119      DiscoverOperators();
     120      SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single();
    120121    }
    121122
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/PermutationEncoding.cs

    r11575 r11582  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Encodings.PermutationEncoding;
    29 using HeuristicLab.Encodings.RealVectorEncoding;
    3029using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.PluginInfrastructure;
     
    9695      RegisterParameterEvents();
    9796      DiscoverOperators();
     97      SolutionCreator = Operators.OfType<RandomPermutationCreator>().Single();
    9898    }
    9999
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/RealEncoding.cs

    r11561 r11582  
    103103      RegisterParameterEvents();
    104104      DiscoverOperators();
     105      SolutionCreator = Operators.OfType<UniformRandomRealVectorCreator>().Single();
    105106    }
    106107
     
    120121      RegisterParameterEvents();
    121122      DiscoverOperators();
     123      SolutionCreator = Operators.OfType<UniformRandomRealVectorCreator>().Single();
    122124    }
    123125
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IEncoding.cs

    r11559 r11582  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.Dynamic;
    25 using System.Linq;
    26 using System.Text;
    2723using HeuristicLab.Core;
    2824using HeuristicLab.Optimization;
    2925
    3026namespace HeuristicLab.Problems.Programmable {
    31   public interface IEncoding : INamedItem
    32   {
    33    
    34     ISolutionCreator DefaultSolutionCreator { get; }
     27  public interface IEncoding : INamedItem {
    3528    ISolutionCreator SolutionCreator { get; set; }
    36 
    3729
    3830    IEnumerable<IValueParameter> Parameters { get; }
     
    4133
    4234    void ConfigureOperator(IOperator @operator);
    43     void ConfigureOperators(IEnumerable<IOperator> operators);   
     35    void ConfigureOperators(IEnumerable<IOperator> operators);
    4436  }
    4537}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r11575 r11582  
    176176
    177177    protected virtual ISolutionCreator ConfigureCreator(IEncoding encoding) {
    178       #region Configure RealVector Creator
    179       var realEnc = encoding as RealEncoding;
    180       if (realEnc != null) {
    181         DynamicEncodingParameters.AddRange(realEnc.Parameters);
    182         return realEnc.DefaultSolutionCreator;
    183       }
    184       #endregion
    185       #region Configure BinaryVector Creator
    186       var binEnc = encoding as BinaryEncoding;
    187       if (binEnc != null) {
    188         DynamicEncodingParameters.AddRange(binEnc.Parameters);
    189         return binEnc.DefaultSolutionCreator;
    190       }
    191       #endregion
    192       #region Configure IntegerVector Creator
    193       var intEnc = encoding as IntegerEncoding;
    194       if (intEnc != null) {
    195         DynamicEncodingParameters.AddRange(intEnc.Parameters);
    196         return intEnc.DefaultSolutionCreator;
    197       }
    198       #endregion
    199178      #region Configure MultiEncoding Creator
    200179      var multiEncoding = encoding as MultiEncoding;
     
    208187      }
    209188      #endregion
     189      #region Configure RealVector Creator
     190      var realEnc = encoding as RealEncoding;
     191      if (realEnc != null) {
     192        DynamicEncodingParameters.AddRange(realEnc.Parameters);
     193        return realEnc.SolutionCreator;
     194      }
     195      #endregion
     196      #region Configure BinaryVector Creator
     197      var binEnc = encoding as BinaryEncoding;
     198      if (binEnc != null) {
     199        DynamicEncodingParameters.AddRange(binEnc.Parameters);
     200        return binEnc.SolutionCreator;
     201      }
     202      #endregion
     203      #region Configure IntegerVector Creator
     204      var intEnc = encoding as IntegerEncoding;
     205      if (intEnc != null) {
     206        DynamicEncodingParameters.AddRange(intEnc.Parameters);
     207        return intEnc.SolutionCreator;
     208      }
     209      #endregion
    210210      #region Configure Permutation Creator
    211211      var permEnc = encoding as PermutationEncoding;
    212212      if (permEnc != null) {
    213         var l = new ValueParameter<IntValue>(permEnc.Name + "Length", new IntValue(permEnc.Length));
    214         DynamicEncodingParameters.Add(l);
    215 
    216         var creator = new RandomPermutationCreator();
    217         creator.PermutationParameter.ActualName = permEnc.Name;
    218         creator.LengthParameter.ActualName = l.Name;
    219         creator.PermutationTypeParameter.Value = new PermutationType(permEnc.Type);
    220         return creator;
     213        DynamicEncodingParameters.AddRange(permEnc.Parameters);
     214        return permEnc.SolutionCreator;
    221215      }
    222216      #endregion
     217
     218
    223219      throw new ArgumentException(string.Format("Encoding {0} is unknown.", encoding != null ? encoding.GetType().FullName : "(null)"));
    224220    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r11575 r11582  
    3535using HeuristicLab.Parameters;
    3636using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    37 using HeuristicLab.PluginInfrastructure;
    3837
    3938namespace HeuristicLab.Problems.Programmable {
     
    187186
    188187    protected virtual ISolutionCreator ConfigureCreator(IEncoding encoding) {
    189       #region Configure RealVector Creator
    190       var realEnc = encoding as RealEncoding;
    191       if (realEnc != null) {
    192         DynamicEncodingParameters.AddRange(realEnc.Parameters);
    193         return realEnc.DefaultSolutionCreator;
    194       }
    195       #endregion
    196       #region Configure BinaryVector Creator
    197       var binEnc = encoding as BinaryEncoding;
    198       if (binEnc != null) {
    199         DynamicEncodingParameters.AddRange(binEnc.Parameters);
    200         return binEnc.DefaultSolutionCreator;
    201       }
    202       #endregion
    203       #region Configure IntegerVector Creator
    204       var intEnc = encoding as IntegerEncoding;
    205       if (intEnc != null) {
    206         DynamicEncodingParameters.AddRange(intEnc.Parameters);
    207         return intEnc.SolutionCreator;
    208       }
    209       #endregion
    210       #region Configure Permutation Creator
    211       var permEnc = encoding as PermutationEncoding;
    212       if (permEnc != null) {
    213         DynamicEncodingParameters.AddRange(permEnc.Parameters);
    214         return permEnc.SolutionCreator;
    215       }
    216       #endregion
    217188      #region Configure MultiEncoding Creator
    218189      var multiEncoding = encoding as MultiEncoding;
     
    224195        }
    225196        return creator;
     197      }
     198      #endregion
     199
     200      #region Configure RealVector Creator
     201      var realEnc = encoding as RealEncoding;
     202      if (realEnc != null) {
     203        DynamicEncodingParameters.AddRange(realEnc.Parameters);
     204        return realEnc.SolutionCreator;
     205      }
     206      #endregion
     207      #region Configure BinaryVector Creator
     208      var binEnc = encoding as BinaryEncoding;
     209      if (binEnc != null) {
     210        DynamicEncodingParameters.AddRange(binEnc.Parameters);
     211        return binEnc.SolutionCreator;
     212      }
     213      #endregion
     214      #region Configure IntegerVector Creator
     215      var intEnc = encoding as IntegerEncoding;
     216      if (intEnc != null) {
     217        DynamicEncodingParameters.AddRange(intEnc.Parameters);
     218        return intEnc.SolutionCreator;
     219      }
     220      #endregion
     221      #region Configure Permutation Creator
     222      var permEnc = encoding as PermutationEncoding;
     223      if (permEnc != null) {
     224        DynamicEncodingParameters.AddRange(permEnc.Parameters);
     225        return permEnc.SolutionCreator;
    226226      }
    227227      #endregion
Note: See TracChangeset for help on using the changeset viewer.