Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11484 for branches


Ignore:
Timestamp:
10/21/14 18:49:05 (10 years ago)
Author:
abeham
Message:

#2174: Major refactoring

  • Removed ProblemDefinitionHosts
  • Renamed ParameterVector to Individual
  • Renamed Configuration to Encoding
  • Changed handling of existing operators that they will not be removed and recreated, but only rewired
Location:
branches/ProgrammableProblem
Files:
20 added
14 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable.Views/3.3/ProblemDefinitionScriptView.cs

    r11397 r11484  
    2525namespace HeuristicLab.Problems.Programmable.Views {
    2626  [View("ProblemDefinitionScriptView")]
    27   [Content(typeof(ProblemDefinitionScript), IsDefaultView = true)]
     27  [Content(typeof(ProblemScript), IsDefaultView = true)]
    2828  public partial class ProblemDefinitionScriptView : ScriptView {
    2929
    30     public new ProblemDefinitionScript Content {
    31       get { return (ProblemDefinitionScript)base.Content; }
     30    public new ProblemScript Content {
     31      get { return (ProblemScript)base.Content; }
    3232      set { base.Content = value; }
    3333    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Helper.cs

    r11405 r11484  
    3030namespace HeuristicLab.Problems.Programmable {
    3131  internal static class Helper {
    32     internal static ParameterVector Extract(IScope scope, Configuration config) {
    33       var binDict = new Dictionary<string, BinaryVector>();
    34       var intDict = new Dictionary<string, IntegerVector>();
    35       var realDict = new Dictionary<string, RealVector>();
    36       var permDict = new Dictionary<string, Permutation>();
    37       foreach (var param in config.Parameters) {
    38         var binConfig = param.Value as BinaryParameterConfiguration;
    39         if (binConfig != null) {
    40           binDict.Add(param.Key, (BinaryVector)scope.Variables[param.Key].Value);
    41           continue;
     32    internal static Individual Extract(IScope scope, Encoding encoding) {
     33      Dictionary<string, BinaryVector> binDict = null;
     34      Dictionary<string, IntegerVector> intDict = null;
     35      Dictionary<string, RealVector> realDict = null;
     36      Dictionary<string, Permutation> permDict = null;
     37      var multiEncoding = encoding as MultiEncoding;
     38      if (multiEncoding != null) {
     39        foreach (var enc in multiEncoding.Encodings) {
     40          var binConfig = enc as BinaryEncoding;
     41          if (binConfig != null) {
     42            if (binDict == null) binDict = new Dictionary<string, BinaryVector>();
     43            binDict.Add(enc.Name, (BinaryVector)scope.Variables[enc.Name].Value);
     44            continue;
     45          }
     46          var intConfig = enc as IntegerEncoding;
     47          if (intConfig != null) {
     48            if (intDict == null) intDict = new Dictionary<string, IntegerVector>();
     49            intDict.Add(enc.Name, (IntegerVector)scope.Variables[enc.Name].Value);
     50            continue;
     51          }
     52          var realConfig = enc as RealEncoding;
     53          if (realConfig != null) {
     54            if (realDict == null) realDict = new Dictionary<string, RealVector>();
     55            realDict.Add(enc.Name, (RealVector)scope.Variables[enc.Name].Value);
     56            continue;
     57          }
     58          var permConfig = enc as PermutationEncoding;
     59          if (permConfig != null) {
     60            if (permDict == null) permDict = new Dictionary<string, Permutation>();
     61            permDict.Add(enc.Name, (Permutation)scope.Variables[enc.Name].Value);
     62            continue;
     63          }
     64          throw new InvalidOperationException("Encoding for variable " + enc.Name + " not recognized.");
    4265        }
    43         var intConfig = param.Value as IntegerParameterConfiguration;
    44         if (intConfig != null) {
    45           intDict.Add(param.Key, (IntegerVector)scope.Variables[param.Key].Value);
    46           continue;
    47         }
    48         var realConfig = param.Value as RealParameterConfiguration;
    49         if (realConfig != null) {
    50           realDict.Add(param.Key, (RealVector)scope.Variables[param.Key].Value);
    51           continue;
    52         }
    53         var permConfig = param.Value as PermutationParameterConfiguration;
    54         if (permConfig != null) {
    55           permDict.Add(param.Key, (Permutation)scope.Variables[param.Key].Value);
    56           continue;
    57         }
    58         throw new InvalidOperationException("Parameter " + param.Key + " not found.");
     66      } else {
     67        var binaryEncoding = encoding as BinaryEncoding;
     68        var handled = binaryEncoding != null;
     69        if (binaryEncoding != null) binDict = new Dictionary<string, BinaryVector>(capacity: 1) {
     70            {binaryEncoding.Name, (BinaryVector)scope.Variables[binaryEncoding.Name].Value}
     71          };
     72        var integerEncoding = encoding as IntegerEncoding;
     73        handled = handled || integerEncoding != null;
     74        if (integerEncoding != null) intDict = new Dictionary<string, IntegerVector>(capacity: 1) {
     75            {integerEncoding.Name, (IntegerVector)scope.Variables[integerEncoding.Name].Value}
     76          };
     77        var realEncoding = encoding as RealEncoding;
     78        handled = handled || realEncoding != null;
     79        if (realEncoding != null) realDict = new Dictionary<string, RealVector>(capacity: 1) {
     80            {realEncoding.Name, (RealVector)scope.Variables[realEncoding.Name].Value}
     81          };
     82        var permEncoding = encoding as PermutationEncoding;
     83        handled = handled || permEncoding != null;
     84        if (permEncoding != null) permDict = new Dictionary<string, Permutation>(capacity: 1) {
     85            {permEncoding.ItemName, (Permutation)scope.Variables[permEncoding.ItemName].Value}
     86          };
     87        if (!handled) throw new InvalidOperationException("Encoding for variable " + encoding.Name + " not recognized.");
    5988      }
    60       return new ParameterVector(
    61         binaryVectors: binDict.Count > 0 ? binDict : null,
    62         integerVectors: intDict.Count > 0 ? intDict : null,
    63         realVectors: realDict.Count > 0 ? realDict : null,
    64         permutations: permDict.Count > 0 ? permDict : null);
     89      return new Individual(binDict, intDict, realDict, permDict);
    6590    }
    6691
    67     internal static void Write(IScope scope, ParameterVector vector) {
     92    internal static void Write(IScope scope, Individual vector) {
    6893      foreach (var param in vector.BinaryNames) {
    6994        if (scope.Variables.ContainsKey(param))
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj

    r11405 r11484  
    131131  </ItemGroup>
    132132  <ItemGroup>
    133     <Compile Include="Datastructures\PermutationParameterConfiguration.cs" />
    134     <Compile Include="Datastructures\RealParameterConfiguration.cs" />
    135     <Compile Include="Datastructures\IntegerParameterConfiguration.cs" />
    136     <Compile Include="Datastructures\BinaryParameterConfiguration.cs" />
    137     <Compile Include="Datastructures\Configuration.cs" />
    138     <Compile Include="Datastructures\ParameterConfiguration.cs" />
    139     <Compile Include="Datastructures\ParameterVector.cs" />
     133    <Compile Include="Encodings\PermutationEncoding.cs" />
     134    <Compile Include="Encodings\RealEncoding.cs" />
     135    <Compile Include="Encodings\IntegerEncoding.cs" />
     136    <Compile Include="Encodings\BinaryEncoding.cs" />
     137    <Compile Include="Encodings\MultiEncoding.cs" />
     138    <Compile Include="Encodings\Encoding.cs" />
     139    <Compile Include="Encodings\Individual.cs" />
    140140    <Compile Include="Helper.cs" />
    141     <Compile Include="Interfaces\IParameterVectorMoveOperator.cs" />
    142     <Compile Include="Interfaces\IMultiObjectiveProblemDefinitionHost.cs" />
     141    <Compile Include="Interfaces\ISingleObjectiveMoveOperator.cs" />
    143142    <Compile Include="Interfaces\IMultiObjectiveProblemDefinition.cs" />
    144     <Compile Include="Interfaces\ISingleObjectiveProblemDefinitionHost.cs" />
    145143    <Compile Include="Interfaces\IMultiObjectiveProgrammableProblemAnalyzer.cs" />
    146144    <Compile Include="Interfaces\ISingleObjectiveProgrammableProblemAnalyzer.cs" />
    147145    <Compile Include="Interfaces\IMultiObjectiveProgrammableProblemEvaluator.cs" />
    148146    <Compile Include="Interfaces\ISingleObjectiveProgrammableProblemEvaluator.cs" />
    149     <Compile Include="Operators\ParameterVectorManipulator.cs" />
    150     <Compile Include="Operators\ParameterVectorCrossover.cs" />
    151     <Compile Include="Operators\ParameterVectorMoveEvaluator.cs" />
    152     <Compile Include="Operators\ParameterVectorMoveGenerator.cs" />
    153     <Compile Include="Operators\ParameterVectorMoveMaker.cs" />
     147    <Compile Include="Operators\MultiEncodingManipulator.cs" />
     148    <Compile Include="Operators\MultiEncodingCrossover.cs" />
     149    <Compile Include="Operators\SingleObjectiveMoveEvaluator.cs" />
     150    <Compile Include="Operators\SingleObjectiveMoveGenerator.cs" />
     151    <Compile Include="Operators\SingleObjectiveMoveMaker.cs" />
    154152    <Compile Include="Operators\MultiObjectiveAnalyzer.cs" />
    155153    <Compile Include="Operators\SingleObjectiveAnalyzer.cs" />
    156154    <Compile Include="Operators\MultiObjectiveEvaluator.cs" />
    157155    <Compile Include="Operators\SingleObjectiveEvaluator.cs" />
    158     <Compile Include="Operators\ParameterVectorCreater.cs" />
     156    <Compile Include="Operators\MultiEncodingCreator.cs" />
    159157    <Compile Include="Interfaces\IProblemDefinition.cs" />
    160158    <Compile Include="Interfaces\ISingleObjectiveProblemDefinition.cs" />
    161     <Compile Include="Operators\SingleObjectiveParameterVectorImprover.cs" />
     159    <Compile Include="Operators\SingleObjectiveImprover.cs" />
    162160    <Compile Include="ProblemDefinition.cs" />
    163     <Compile Include="ProblemDefinitionScript.cs" />
     161    <Compile Include="ProblemScriptBase.cs" />
     162    <Compile Include="ProblemScript.cs" />
    164163    <Compile Include="MultiObjectiveProblemDefinition.cs" />
    165164    <Compile Include="SingleObjectiveProblemDefinition.cs" />
    166     <Compile Include="MultiObjectiveProblemDefinitionScript.cs" />
    167     <Compile Include="SingleObjectiveProblemDefinitionScript.cs" />
     165    <Compile Include="MultiObjectiveProblemScript.cs" />
     166    <Compile Include="SingleObjectiveProblemScript.cs" />
    168167    <Compile Include="MultiObjectiveProgrammableProblem.cs" />
    169168    <Compile Include="SingleObjectiveProgrammableProblem.cs" />
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IMultiObjectiveProblemDefinition.cs

    r11400 r11484  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Optimization;
     
    2726  public interface IMultiObjectiveProblemDefinition : IProblemDefinition {
    2827    bool[] Maximization { get; }
    29     double[] Evaluate(IRandom random, ParameterVector vector);
    30     void Analyze(ParameterVector[] vectors, double[][] qualities, ResultCollection results);
    31     IEnumerable<ParameterVector> GetNeighbors(IRandom random, ParameterVector vector);
     28    double[] Evaluate(IRandom random, Individual individual);
     29    void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results);
    3230  }
    3331}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IMultiObjectiveProgrammableProblemAnalyzer.cs

    r11400 r11484  
    2626namespace HeuristicLab.Problems.Programmable {
    2727  public interface IMultiObjectiveProgrammableProblemAnalyzer : IAnalyzer {
    28     ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter { get; }
    29     ILookupParameter<Configuration> ConfigurationParameter { get; }
     28    ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter { get; }
     29    ILookupParameter<Encoding> EncodingParameter { get; }
    3030    IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { get; }
    3131    ILookupParameter<ResultCollection> ResultsParameter { get; }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IMultiObjectiveProgrammableProblemEvaluator.cs

    r11400 r11484  
    2525namespace HeuristicLab.Problems.Programmable {
    2626  public interface IMultiObjectiveProgrammableProblemEvaluator : IMultiObjectiveEvaluator {
    27     ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter { get; }
    28     ILookupParameter<Configuration> ConfigurationParameter { get; }
     27    ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter { get; }
     28    ILookupParameter<Encoding> EncodingParameter { get; }
    2929  }
    3030}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IProblemDefinition.cs

    r11402 r11484  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using HeuristicLab.Core;
    2225
    2326namespace HeuristicLab.Problems.Programmable {
    24   public interface IProblemDefinition {
    25     Configuration GetConfiguration();
     27  public interface IProblemDefinition : INamedItem {
     28    Encoding Encoding { get; }
     29    IEnumerable<Individual> GetNeighbors(IRandom random, Individual individual);
     30
     31    event EventHandler ProblemDefinitionChanged;
    2632  }
    2733}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/ISingleObjectiveProblemDefinition.cs

    r11393 r11484  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Optimization;
     
    2726  public interface ISingleObjectiveProblemDefinition : IProblemDefinition {
    2827    bool IsMaximizationProblem { get; }
    29     double Evaluate(IRandom random, ParameterVector vector);
    30     void Analyze(ParameterVector[] vectors, double[] qualities, ResultCollection results);
    31     IEnumerable<ParameterVector> GetNeighbors(IRandom random, ParameterVector vector);
     28    double Evaluate(IRandom random, Individual individual);
     29    void Analyze(Individual[] individuals, double[] qualities, ResultCollection results);
    3230  }
    3331}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/ISingleObjectiveProgrammableProblemAnalyzer.cs

    r11396 r11484  
    2626namespace HeuristicLab.Problems.Programmable {
    2727  public interface ISingleObjectiveProgrammableProblemAnalyzer : IAnalyzer {
    28     ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter { get; }
    29     ILookupParameter<Configuration> ConfigurationParameter { get; }
     28    ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter { get; }
     29    ILookupParameter<Encoding> EncodingParameter { get; }
    3030    IScopeTreeLookupParameter<DoubleValue> QualityParameter { get; }
    3131    ILookupParameter<ResultCollection> ResultsParameter { get; }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/ISingleObjectiveProgrammableProblemEvaluator.cs

    r11396 r11484  
    2525namespace HeuristicLab.Problems.Programmable {
    2626  public interface ISingleObjectiveProgrammableProblemEvaluator : ISingleObjectiveEvaluator {
    27     ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter { get; }
    28     ILookupParameter<Configuration> ConfigurationParameter { get; }
     27    ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter { get; }
     28    ILookupParameter<Encoding> EncodingParameter { get; }
    2929  }
    3030}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinition.cs

    r11402 r11484  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Drawing;
     22using System.Linq;
    2523using HeuristicLab.Common;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Optimization;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    2928namespace HeuristicLab.Problems.Programmable {
    30   [Item("Multi-objective Problem Definition", "This definition can be dynamically created through code and assigned to the problem.")]
    31   public class MultiObjectiveProblemDefinition : IMultiObjectiveProblemDefinitionHost, IMultiObjectiveProblemDefinition {
     29  [Item("Multi-objective Problem Definition", "Base class for custom multi-objective problem definitions.")]
     30  public abstract class MultiObjectiveProblemDefinition : ProblemDefinition, IMultiObjectiveProblemDefinition {
     31    [Storable(Name = "Storable")]
    3232    private bool[] maximization;
    3333    public bool[] Maximization {
    3434      get { return maximization; }
    3535      set {
     36        if (maximization.SequenceEqual(value)) return;
    3637        maximization = value;
    37         OnInstanceChanged();
     38        OnProblemDefinitionChanged();
    3839      }
    3940    }
    4041
    41     private Func<Configuration> configuration;
    42     public Func<Configuration> Configuration {
    43       get { return configuration; }
    44       set {
    45         configuration = value;
    46         OnInstanceChanged();
    47       }
     42    public abstract double[] Evaluate(IRandom random, Individual vector);
     43
     44    public abstract void Analyze(Individual[] vectors, double[][] qualities, ResultCollection results);
     45
     46    [StorableConstructor]
     47    protected MultiObjectiveProblemDefinition(bool deserializing) : base(deserializing) { }
     48    protected MultiObjectiveProblemDefinition(MultiObjectiveProblemDefinition original, Cloner cloner)
     49      : base(original, cloner) {
     50      this.maximization = (bool[])original.maximization.Clone();
    4851    }
    49 
    50     private Func<IRandom, ParameterVector, double[]> evaluate;
    51     public Func<IRandom, ParameterVector, double[]> Evaluate {
    52       get { return evaluate; }
    53       set {
    54         evaluate = value;
    55         OnInstanceChanged();
    56       }
    57     }
    58 
    59     private Action<ParameterVector[], double[][], ResultCollection> analyze;
    60     public Action<ParameterVector[], double[][], ResultCollection> Analyze {
    61       get { return analyze; }
    62       set {
    63         analyze = value;
    64         OnInstanceChanged();
    65       }
    66     }
    67 
    68     private Func<IRandom, ParameterVector, IEnumerable<ParameterVector>> neighbors;
    69     public Func<IRandom, ParameterVector, IEnumerable<ParameterVector>> Neighbors {
    70       get { return neighbors; }
    71       set {
    72         neighbors = value;
    73         OnInstanceChanged();
    74       }
    75     }
    76 
    77     protected MultiObjectiveProblemDefinition(MultiObjectiveProblemDefinition original, Cloner cloner) {
    78       cloner.RegisterClonedObject(original, this);
    79       name = original.name;
    80       description = original.description;
    81       maximization = original.maximization;
    82       configuration = original.configuration;
    83       evaluate = original.evaluate;
    84       analyze = original.analyze;
    85       neighbors = original.neighbors;
    86     }
    87 
    88     public MultiObjectiveProblemDefinition() : this((string)null, null) { }
    89     public MultiObjectiveProblemDefinition(string name) : this(name, null) { }
    90     public MultiObjectiveProblemDefinition(string name, string description) {
    91       this.name = name ?? ItemName;
    92       this.description = description ?? ItemDescription;
    93       configuration = () => new Configuration();
    94       evaluate = (random, vector) => new[] { 0.0, 0.0 };
    95       analyze = (vectors, doubles, results) => { };
    96       neighbors = (random, vector) => new[] { (ParameterVector)vector.Clone() };
    97     }
    98 
    99 
    100     public IDeepCloneable Clone(Cloner cloner) {
    101       return new MultiObjectiveProblemDefinition(this, cloner);
    102     }
    103 
    104     public IMultiObjectiveProblemDefinition Instance {
    105       get { return this; }
    106     }
    107 
    108     public event EventHandler InstanceChanged;
    109     protected void OnInstanceChanged() {
    110       var handler = InstanceChanged;
    111       if (handler != null) handler(this, EventArgs.Empty);
    112     }
    113 
    114     #region Problem definition explicit interface implementations
    115     Configuration IProblemDefinition.GetConfiguration() {
    116       return Configuration();
    117     }
    118 
    119     bool[] IMultiObjectiveProblemDefinition.Maximization {
    120       get { return Maximization; }
    121     }
    122 
    123     double[] IMultiObjectiveProblemDefinition.Evaluate(IRandom random, ParameterVector vector) {
    124       return Evaluate(random, vector);
    125     }
    126 
    127     void IMultiObjectiveProblemDefinition.Analyze(ParameterVector[] vectors, double[][] qualities, ResultCollection results) {
    128       Analyze(vectors, qualities, results);
    129     }
    130 
    131     IEnumerable<ParameterVector> IMultiObjectiveProblemDefinition.GetNeighbors(IRandom random, ParameterVector vector) {
    132       return Neighbors(random, vector);
    133     }
    134     #endregion
    135 
    136     #region INamedItem
    137     protected string name;
    138     /// <inheritdoc/>
    139     /// <remarks>Calls <see cref="OnNameChanging"/> and also <see cref="OnNameChanged"/>
    140     /// eventually in the setter.</remarks>
    141     public string Name {
    142       get { return name; }
    143       set {
    144         if (!CanChangeName) throw new NotSupportedException("Name cannot be changed.");
    145         if (!(name.Equals(value) || (value == null) && (name == string.Empty))) {
    146           CancelEventArgs<string> e = value == null ? new CancelEventArgs<string>(string.Empty) : new CancelEventArgs<string>(value);
    147           OnNameChanging(e);
    148           if (!e.Cancel) {
    149             name = value == null ? string.Empty : value;
    150             OnNameChanged();
    151           }
    152         }
    153       }
    154     }
    155     public virtual bool CanChangeName {
    156       get { return true; }
    157     }
    158     protected string description;
    159     public string Description {
    160       get { return description; }
    161       set {
    162         if (!CanChangeDescription) throw new NotSupportedException("Description cannot be changed.");
    163         if (!(description.Equals(value) || (value == null) && (description == string.Empty))) {
    164           description = value == null ? string.Empty : value;
    165           OnDescriptionChanged();
    166         }
    167       }
    168     }
    169     public virtual bool CanChangeDescription {
    170       get { return true; }
    171     }
    172 
    173     /// <summary>
    174     /// Gets the string representation of the current instance in the format: <c>Name: [null|Value]</c>.
    175     /// </summary>
    176     /// <returns>The current instance as a string.</returns>
    177     public override string ToString() {
    178       return Name;
    179     }
    180 
    181     /// <inheritdoc/>
    182     public event EventHandler<CancelEventArgs<string>> NameChanging;
    183     /// <summary>
    184     /// Fires a new <c>NameChanging</c> event.
    185     /// </summary>
    186     /// <param name="e">The event arguments of the changing.</param>
    187     protected virtual void OnNameChanging(CancelEventArgs<string> e) {
    188       var handler = NameChanging;
    189       if (handler != null) handler(this, e);
    190     }
    191     /// <inheritdoc/>
    192     public event EventHandler NameChanged;
    193     /// <summary>
    194     /// Fires a new <c>NameChanged</c> event.
    195     /// </summary>
    196     /// <remarks>Calls <see cref="ItemBase.OnChanged"/>.</remarks>
    197     protected virtual void OnNameChanged() {
    198       var handler = NameChanged;
    199       if (handler != null) handler(this, EventArgs.Empty);
    200       OnToStringChanged();
    201     }
    202     /// <inheritdoc/>
    203     public event EventHandler DescriptionChanged;
    204     /// <summary>
    205     /// Fires a new <c>DescriptionChanged</c> event.
    206     /// </summary>
    207     /// <remarks>Calls <see cref="ItemBase.OnChanged"/>.</remarks>
    208     protected virtual void OnDescriptionChanged() {
    209       var handler = DescriptionChanged;
    210       if (handler != null) handler(this, EventArgs.Empty);
    211     }
    212     #endregion
    213     #region IItem
    214     public virtual string ItemName {
    215       get { return ItemAttribute.GetName(this.GetType()); }
    216     }
    217     public virtual string ItemDescription {
    218       get { return ItemAttribute.GetDescription(this.GetType()); }
    219     }
    220     public Version ItemVersion {
    221       get { return ItemAttribute.GetVersion(this.GetType()); }
    222     }
    223     public static Image StaticItemImage {
    224       get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; }
    225     }
    226     public virtual Image ItemImage {
    227       get { return ItemAttribute.GetImage(this.GetType()); }
    228     }
    229     public object Clone() {
    230       return Clone(new Cloner());
    231     }
    232 
    233     public event EventHandler ItemImageChanged;
    234     protected virtual void OnItemImageChanged() {
    235       var handler = ItemImageChanged;
    236       if (handler != null) handler(this, EventArgs.Empty);
    237     }
    238     public event EventHandler ToStringChanged;
    239     protected virtual void OnToStringChanged() {
    240       var handler = ToStringChanged;
    241       if (handler != null) handler(this, EventArgs.Empty);
    242     }
    243     #endregion
     52    protected MultiObjectiveProblemDefinition(Encoding encoding) : this(encoding, "MultiObjectiveProblemDefinition", null) { }
     53    protected MultiObjectiveProblemDefinition(Encoding encoding, string name) : this(encoding, name, null) { }
     54    protected MultiObjectiveProblemDefinition(Encoding encoding, string name, string description)
     55      : base(encoding) { }
    24456  }
    24557}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r11400 r11484  
    5454    }
    5555
    56     public IValueParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    57       get { return (IValueParameter<IMultiObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
    58     }
    59 
    60     protected IValueParameter<Configuration> ConfigurationParameter {
    61       get { return (IValueParameter<Configuration>)Parameters["Configuration"]; }
    62     }
    63 
    64     public IMultiObjectiveProblemDefinitionHost ProblemDefinition {
     56    public IValueParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter {
     57      get { return (IValueParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
     58    }
     59
     60    protected IValueParameter<Encoding> EncodingParameter {
     61      get { return (IValueParameter<Encoding>)Parameters["Encoding"]; }
     62    }
     63
     64    public IMultiObjectiveProblemDefinition ProblemDefinition {
    6565      get { return ProblemDefinitionParameter.Value; }
    6666      set { ProblemDefinitionParameter.Value = value; }
     
    6868
    6969    [Storable]
    70     protected List<IParameter> DynamicConfigurationParameters;
     70    protected List<IParameter> DynamicEncodingParameters;
    7171
    7272    [StorableConstructor]
     
    7474    protected MultiObjectiveProgrammableProblem(MultiObjectiveProgrammableProblem original, Cloner cloner)
    7575      : base(original, cloner) {
    76       DynamicConfigurationParameters = original.DynamicConfigurationParameters.Select(cloner.Clone).ToList();
     76      DynamicEncodingParameters = original.DynamicEncodingParameters.Select(cloner.Clone).ToList();
    7777      RegisterEventHandlers();
    7878    }
    7979    public MultiObjectiveProgrammableProblem()
    80       : base(new MultiObjectiveEvaluator(), new ParameterVectorCreater()) {
    81       Parameters.Add(new ValueParameter<IMultiObjectiveProblemDefinitionHost>("ProblemDefinition", "Defines the problem.", new MultiObjectiveProblemDefinitionScript() { Name = Name }));
    82       Parameters.Add(new ValueParameter<Configuration>("Configuration", "Describes which parameters exist, what they're called, what type they are and their bounds if any."));
    83 
    84       DynamicConfigurationParameters = new List<IParameter>();
     80      : base(new MultiObjectiveEvaluator(), new MultiEncodingCreator()) {
     81      Parameters.Add(new ValueParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "Defines the problem.", new MultiObjectiveProblemScript() { Name = Name }));
     82      Parameters.Add(new ValueParameter<Encoding>("Encoding", "Describes which parameters exist, what they're called, what type they are and their bounds if any."));
     83
     84      DynamicEncodingParameters = new List<IParameter>();
    8585
    8686      Operators.Add(new MultiObjectiveAnalyzer());
     
    113113
    114114    private void RegisterHostInstanceChanges() {
    115       ProblemDefinitionParameter.Value.InstanceChanged += ProblemDefinitionHostOnInstanceChanged;
     115      ProblemDefinitionParameter.Value.ProblemDefinitionChanged += ProblemDefinitionChanged;
    116116      ProblemDefinitionParameter.Value.NameChanged += ProblemDefinitionHostOnNameChanged;
    117117    }
     
    132132    }
    133133
    134     protected virtual void ProblemDefinitionHostOnInstanceChanged(object sender, EventArgs eventArgs) {
     134    protected virtual void ProblemDefinitionChanged(object sender, EventArgs eventArgs) {
    135135      Parameterize();
    136136    }
    137137
    138138    protected virtual void Parameterize() {
    139       var instance = ProblemDefinitionParameter.Value.Instance;
    140       if (instance == null) return;
    141 
    142       Configuration configuration;
     139      var definition = ProblemDefinitionParameter.Value;
     140      if (definition == null) return;
     141
     142      Encoding encoding;
    143143      try {
    144         configuration = instance.GetConfiguration();
     144        encoding = definition.Encoding;
    145145      } catch { return; }
    146       ConfigurationParameter.Value = configuration;
    147       Maximization = new BoolArray(instance.Maximization);
    148 
    149       Evaluator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     146      EncodingParameter.Value = encoding;
     147      Maximization = new BoolArray(definition.Maximization);
     148
     149      Evaluator.EncodingParameter.ActualName = EncodingParameter.Name;
    150150      Evaluator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    151151      foreach (var evalOp in Operators.OfType<IMultiObjectiveProgrammableProblemEvaluator>()) {
    152         evalOp.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     152        evalOp.EncodingParameter.ActualName = EncodingParameter.Name;
    153153        evalOp.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    154154      }
    155155      foreach (var analyzeOp in Operators.OfType<IMultiObjectiveProgrammableProblemAnalyzer>()) {
    156         analyzeOp.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     156        analyzeOp.EncodingParameter.ActualName = EncodingParameter.Name;
    157157        analyzeOp.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    158158        analyzeOp.QualitiesParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
    159159      }
    160160
    161       var solutionCreators = UpdateDynamicConfigurationParameters(configuration);
    162 
    163       if (solutionCreators.Count == 1) {
    164         Operators.RemoveAll(x => x is ParameterVectorCrossover
    165                               || x is ParameterVectorManipulator);
    166         UpdateSingleVectorEncodingOperators(solutionCreators, configuration);
    167       } else {
    168         UpdateMultiVectorEncodingOperators(solutionCreators, configuration);
    169       }
    170       UpdateMoveOperators();
    171     }
    172 
    173     protected virtual List<ISolutionCreator> UpdateDynamicConfigurationParameters(Configuration configuration) {
    174       foreach (var param in DynamicConfigurationParameters)
     161      foreach (var param in DynamicEncodingParameters)
    175162        if (Parameters.Contains(param)) Parameters.Remove(param);
    176       DynamicConfigurationParameters.Clear();
    177 
    178       var solutionCreators = new List<ISolutionCreator>();
    179       foreach (var param in configuration.Parameters) {
    180         #region Configure BinaryVector Creator
    181         var binConfig = param.Value as BinaryParameterConfiguration;
    182         if (binConfig != null) {
    183           var p = new ValueParameter<IntValue>(param.Key + "Length", binConfig.Length);
    184           DynamicConfigurationParameters.Add(p);
    185 
    186           var creator = new RandomBinaryVectorCreator();
    187           creator.BinaryVectorParameter.ActualName = param.Key;
    188           creator.LengthParameter.ActualName = p.Name;
    189           solutionCreators.Add(creator);
    190         }
    191         #endregion
    192         #region Configure IntegerVector Creator
    193         var intConfig = param.Value as IntegerParameterConfiguration;
    194         if (intConfig != null) {
    195           var l = new ValueParameter<IntValue>(param.Key + "Length", intConfig.Length);
    196           var b = new ValueParameter<IntMatrix>(param.Key + "Bounds", intConfig.Bounds);
    197           DynamicConfigurationParameters.Add(l);
    198           DynamicConfigurationParameters.Add(b);
    199 
    200           var creator = new UniformRandomIntegerVectorCreator();
    201           creator.IntegerVectorParameter.ActualName = param.Key;
    202           creator.LengthParameter.ActualName = l.Name;
    203           creator.BoundsParameter.ActualName = b.Name;
    204           solutionCreators.Add(creator);
    205         }
    206         #endregion
    207         #region Configure RealVector Creator
    208         var realConfig = param.Value as RealParameterConfiguration;
    209         if (realConfig != null) {
    210           var l = new ValueParameter<IntValue>(param.Key + "Length", realConfig.Length);
    211           var b = new ValueParameter<DoubleMatrix>(param.Key + "Bounds", realConfig.Bounds);
    212           DynamicConfigurationParameters.Add(l);
    213           DynamicConfigurationParameters.Add(b);
    214 
    215           var creator = new UniformRandomRealVectorCreator();
    216           creator.RealVectorParameter.ActualName = param.Key;
    217           creator.LengthParameter.ActualName = l.Name;
    218           creator.BoundsParameter.ActualName = b.Name;
    219           solutionCreators.Add(creator);
    220         }
    221         #endregion
    222         #region Configure Permutation Creator
    223         var permConfig = param.Value as PermutationParameterConfiguration;
    224         if (permConfig != null) {
    225           var l = new ValueParameter<IntValue>(param.Key + "Length", permConfig.Length);
    226           DynamicConfigurationParameters.Add(l);
    227 
    228           var creator = new RandomPermutationCreator();
    229           creator.PermutationParameter.ActualName = param.Key;
    230           creator.LengthParameter.ActualName = l.Name;
    231           creator.PermutationTypeParameter.Value = permConfig.Type;
    232           solutionCreators.Add(creator);
    233         }
    234         #endregion
    235       }
    236 
    237       foreach (var param in DynamicConfigurationParameters) {
     163      DynamicEncodingParameters.Clear();
     164
     165      var creator = ConfigureCreator(encoding);
     166
     167      foreach (var param in DynamicEncodingParameters) {
    238168        param.Hidden = true;
    239169        Parameters.Add(param);
    240170      }
    241       return solutionCreators;
    242     }
    243 
    244     protected virtual void UpdateSingleVectorEncodingOperators(List<ISolutionCreator> solutionCreators, Configuration configuration) {
    245       var newCreator = solutionCreators.Single();
     171
     172      var multiEncoding = encoding as MultiEncoding;
     173      if (multiEncoding != null) {
     174        ConfigureMultiVectorEncodingOperators((MultiEncodingCreator)creator, multiEncoding);
     175      } else {
     176        ConfigureSingleEncodingOperators(creator, encoding);
     177      }
     178    }
     179
     180    protected virtual ISolutionCreator ConfigureCreator(Encoding encoding) {
     181      #region Configure MultiEncoding Creator
     182      var multiEncoding = encoding as MultiEncoding;
     183      if (multiEncoding != null) {
     184        var creator = new MultiEncodingCreator();
     185        foreach (var enc in multiEncoding.Encodings) {
     186          if (enc is MultiEncoding) throw new InvalidOperationException("MultiEncoding within a MultiEncoding is not supported.");
     187          creator.Operators.Add(ConfigureCreator(enc));
     188        }
     189        return creator;
     190      }
     191      #endregion
     192      #region Configure BinaryVector Creator
     193      var binEnc = encoding as BinaryEncoding;
     194      if (binEnc != null) {
     195        var p = new ValueParameter<IntValue>(binEnc.Name + "Length", binEnc.Length);
     196        DynamicEncodingParameters.Add(p);
     197
     198        var creator = new RandomBinaryVectorCreator();
     199        creator.BinaryVectorParameter.ActualName = binEnc.Name;
     200        creator.LengthParameter.ActualName = p.Name;
     201        return creator;
     202      }
     203      #endregion
     204      #region Configure IntegerVector Creator
     205      var intEnc = encoding as IntegerEncoding;
     206      if (intEnc != null) {
     207        var l = new ValueParameter<IntValue>(intEnc.Name + "Length", intEnc.Length);
     208        var b = new ValueParameter<IntMatrix>(intEnc.Name + "Bounds", intEnc.Bounds);
     209        DynamicEncodingParameters.Add(l);
     210        DynamicEncodingParameters.Add(b);
     211
     212        var creator = new UniformRandomIntegerVectorCreator();
     213        creator.IntegerVectorParameter.ActualName = intEnc.Name;
     214        creator.LengthParameter.ActualName = l.Name;
     215        creator.BoundsParameter.ActualName = b.Name;
     216        return creator;
     217      }
     218      #endregion
     219      #region Configure RealVector Creator
     220      var realEnc = encoding as RealEncoding;
     221      if (realEnc != null) {
     222        var l = new ValueParameter<IntValue>(realEnc.Name + "Length", realEnc.Length);
     223        var b = new ValueParameter<DoubleMatrix>(realEnc.Name + "Bounds", realEnc.Bounds);
     224        DynamicEncodingParameters.Add(l);
     225        DynamicEncodingParameters.Add(b);
     226
     227        var creator = new UniformRandomRealVectorCreator();
     228        creator.RealVectorParameter.ActualName = realEnc.Name;
     229        creator.LengthParameter.ActualName = l.Name;
     230        creator.BoundsParameter.ActualName = b.Name;
     231        return creator;
     232      }
     233      #endregion
     234      #region Configure Permutation Creator
     235      var permEnc = encoding as PermutationEncoding;
     236      if (permEnc != null) {
     237        var l = new ValueParameter<IntValue>(permEnc.Name + "Length", permEnc.Length);
     238        DynamicEncodingParameters.Add(l);
     239
     240        var creator = new RandomPermutationCreator();
     241        creator.PermutationParameter.ActualName = permEnc.Name;
     242        creator.LengthParameter.ActualName = l.Name;
     243        creator.PermutationTypeParameter.Value = permEnc.Type;
     244        return creator;
     245      }
     246      #endregion
     247      throw new ArgumentException(string.Format("Encoding {0} is unknown.", encoding != null ? encoding.GetType().FullName : "(null)"));
     248    }
     249
     250    protected virtual void ConfigureSingleEncodingOperators(ISolutionCreator newCreator, Encoding encoding) {
     251      // remove all multiencoding operators
     252      Operators.RemoveAll(x => x is MultiEncodingCrossover
     253                            || x is MultiEncodingManipulator
     254                            || x is MultiEncodingCreator);
     255
    246256      #region Configure Operators for BinaryVectorEncoding
    247257      var binCreator = newCreator as IBinaryVectorCreator;
     
    256266
    257267        #region Wire BinaryVector Crossovers
    258         Operators.RemoveAll(x => x is IBinaryVectorCrossover && ((IBinaryVectorCrossover)x).ChildParameter.ActualName != paramName);
    259         var crossovers = ApplicationManager.Manager.GetInstances<IBinaryVectorCrossover>().ToList();
     268        var crossovers = Operators.OfType<IBinaryVectorCrossover>()
     269          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorCrossover>(), new TypeEqualityComparer<IBinaryVectorCrossover>())
     270          .ToList();
    260271        foreach (var xo in crossovers) {
    261272          xo.ChildParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
     
    264275          xo.ParentsParameter.Hidden = true;
    265276        }
    266         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     277        Operators.AddRange(crossovers.Except(Operators.OfType<IBinaryVectorCrossover>()));
    267278        #endregion
    268279        #region Wire BinaryVector Manipulators
    269         Operators.RemoveAll(x => x is IBinaryVectorManipulator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
    270         var manipulators = ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>().ToList();
     280        var manipulators = Operators.OfType<IBinaryVectorManipulator>()
     281          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>(), new TypeEqualityComparer<IBinaryVectorManipulator>())
     282          .ToList();
    271283        foreach (var m in manipulators) {
    272284          m.BinaryVectorParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
    273285          m.BinaryVectorParameter.Hidden = true;
    274286        }
    275         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     287        Operators.AddRange(manipulators.Except(Operators.OfType<IBinaryVectorManipulator>()));
    276288        #endregion
    277289        #region Wire BinaryVector ShakingOperators
    278         Operators.RemoveAll(x => x is IBinaryVectorMultiNeighborhoodShakingOperator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
    279         var shakingOperators = ApplicationManager.Manager.GetInstances<IBinaryVectorMultiNeighborhoodShakingOperator>().ToList();
     290        var shakingOperators = Operators.OfType<IBinaryVectorMultiNeighborhoodShakingOperator>()
     291          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IBinaryVectorMultiNeighborhoodShakingOperator>())
     292          .ToList();
    280293        foreach (var so in shakingOperators) {
    281294          so.BinaryVectorParameter.ActualName = paramName;
    282295          so.BinaryVectorParameter.Hidden = true;
    283296        }
    284         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     297        Operators.AddRange(shakingOperators.Except(Operators.OfType<IBinaryVectorMultiNeighborhoodShakingOperator>()));
    285298        #endregion
    286299      } else {
     
    303316
    304317        #region Wire IntegerVector Crossovers
    305         Operators.RemoveAll(x => x is IIntegerVectorCrossover && ((IIntegerVectorCrossover)x).ChildParameter.ActualName != paramName);
    306         var crossovers = ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>().ToList();
     318        var crossovers = Operators.OfType<IIntegerVectorCrossover>()
     319          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>(), new TypeEqualityComparer<IIntegerVectorCrossover>())
     320          .ToList();
    307321        foreach (var xo in crossovers) {
    308322          xo.ChildParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     
    316330          }
    317331        }
    318         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     332        Operators.AddRange(crossovers.Except(Operators.OfType<IIntegerVectorCrossover>()));
    319333        #endregion
    320334        #region Wire IntegerVector Manipulators
    321         Operators.RemoveAll(x => x is IIntegerVectorManipulator && ((IIntegerVectorManipulator)x).IntegerVectorParameter.ActualName != paramName);
    322         var manipulators = ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>().ToList();
     335        var manipulators = Operators.OfType<IIntegerVectorManipulator>()
     336          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>(), new TypeEqualityComparer<IIntegerVectorManipulator>())
     337          .ToList();
    323338        foreach (var m in manipulators) {
    324339          m.IntegerVectorParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     
    338353          }
    339354        }
    340         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     355        Operators.AddRange(manipulators.Except(Operators.OfType<IIntegerVectorManipulator>()));
    341356        #region Wire IntegerVector StrategyParameters for SelfAdaptiveManipulators
    342         Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IIntegerVectorStdDevStrategyParameterCreator) || x is IIntegerVectorStdDevStrategyParameterCreator && ((IIntegerVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    343         Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IIntegerVectorStdDevStrategyParameterManipulator) || x is IIntegerVectorStdDevStrategyParameterManipulator && ((IIntegerVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    344         Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IIntegerVectorStdDevStrategyParameterCrossover) || x is IIntegerVectorStdDevStrategyParameterCrossover && ((IIntegerVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    345         var strategyOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorStdDevStrategyParameterOperator>().ToList();
    346         if (!(configuration.Parameters.First().Value is IntegerParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with integervector creator that is not an integer-coded problem.");
    347         var problemSize = ((IntegerParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
    348         var b = ((IntegerParameterConfiguration)configuration.Parameters.First().Value).Bounds;
     357        var strategyOperators = Operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>()
     358          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorStdDevStrategyParameterOperator>(), new TypeEqualityComparer<IIntegerVectorStdDevStrategyParameterOperator>())
     359          .ToList();
     360        var problemSize = ((IntegerEncoding)encoding).Length.Value;
     361        var b = ((IntegerEncoding)encoding).Bounds;
    349362        var bounds = new DoubleMatrix(b.Rows, b.Columns);
    350363        for (var i = 0; i < bounds.Rows; i++) {
     
    376389          }
    377390        }
    378         Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     391        Operators.AddRange(strategyOperators.Except(Operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>()));
    379392        #endregion
    380393        #endregion
    381394        #region Wire IntegerVector ShakingOperators
    382         Operators.RemoveAll(x => x is IIntegerVectorMultiNeighborhoodShakingOperator && ((IIntegerVectorMultiNeighborhoodShakingOperator)x).IntegerVectorParameter.ActualName != paramName);
    383         var shakingOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorMultiNeighborhoodShakingOperator>().ToList();
     395        var shakingOperators = Operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>()
     396          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IIntegerVectorMultiNeighborhoodShakingOperator>())
     397          .ToList();
    384398        foreach (var so in shakingOperators) {
    385399          so.IntegerVectorParameter.ActualName = paramName;
    386400          so.IntegerVectorParameter.Hidden = true;
    387401        }
    388         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     402        Operators.AddRange(shakingOperators.Except(Operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>()));
    389403        #endregion
    390404      } else {
     
    408422
    409423        #region Wire RealVector Crossovers
    410         Operators.RemoveAll(x => x is IRealVectorCrossover && ((IRealVectorCrossover)x).ChildParameter.ActualName != paramName);
    411         var crossovers = ApplicationManager.Manager.GetInstances<IRealVectorCrossover>().ToList();
     424        var crossovers = Operators.OfType<IRealVectorCrossover>()
     425          .Union(ApplicationManager.Manager.GetInstances<IRealVectorCrossover>(), new TypeEqualityComparer<IRealVectorCrossover>())
     426          .ToList();
    412427        foreach (var xo in crossovers) {
    413428          xo.ChildParameter.ActualName = paramName;
     
    418433          xo.BoundsParameter.Hidden = true;
    419434        }
    420         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     435        Operators.AddRange(crossovers.Except(Operators.OfType<IRealVectorCrossover>()));
    421436        #endregion
    422437        #region Wire RealVector Manipulators
    423         Operators.RemoveAll(x => x is IRealVectorManipulator && ((IRealVectorManipulator)x).RealVectorParameter.ActualName != paramName);
    424         var manipulators = ApplicationManager.Manager.GetInstances<IRealVectorManipulator>().ToList();
     438        var manipulators = Operators.OfType<IRealVectorManipulator>()
     439          .Union(ApplicationManager.Manager.GetInstances<IRealVectorManipulator>(), new TypeEqualityComparer<IRealVectorManipulator>())
     440          .ToList();
    425441        foreach (var m in manipulators) {
    426442          m.RealVectorParameter.ActualName = paramName;
     
    437453          }
    438454        }
    439         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     455        Operators.AddRange(manipulators.Except(Operators.OfType<IRealVectorManipulator>()));
    440456        #region Wire RealVector Strategy Parameters for SelfAdaptiveManipulators
    441 
    442         Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IRealVectorStdDevStrategyParameterCreator) || x is IRealVectorStdDevStrategyParameterCreator && ((IRealVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    443         Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IRealVectorStdDevStrategyParameterManipulator) || x is IRealVectorStdDevStrategyParameterManipulator && ((IRealVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    444         Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IRealVectorStdDevStrategyParameterCrossover) || x is IRealVectorStdDevStrategyParameterCrossover && ((IRealVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    445         var strategyOperators = ApplicationManager.Manager.GetInstances<IRealVectorStdDevStrategyParameterOperator>().ToList();
    446         if (!(configuration.Parameters.First().Value is RealParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with realvector creator that is not a real-coded problem.");
    447         var problemSize = ((RealParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
    448         var bounds = (DoubleMatrix)((RealParameterConfiguration)configuration.Parameters.First().Value).Bounds.Clone();
     457        var strategyOperators = Operators.OfType<IRealVectorStdDevStrategyParameterOperator>()
     458          .Union(ApplicationManager.Manager.GetInstances<IRealVectorStdDevStrategyParameterOperator>(), new TypeEqualityComparer<IRealVectorStdDevStrategyParameterOperator>())
     459          .ToList();
     460        var problemSize = ((RealEncoding)encoding).Length.Value;
     461        var bounds = (DoubleMatrix)((RealEncoding)encoding).Bounds.Clone();
    449462        for (var i = 0; i < bounds.Rows; i++) {
    450463          bounds[i, 1] = 0.1 * (bounds[i, 1] - bounds[i, 0]);
     
    474487          }
    475488        }
    476         Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     489        Operators.AddRange(strategyOperators.Except(Operators.OfType<IRealVectorStdDevStrategyParameterOperator>()));
    477490        #endregion
    478491        #endregion
    479492        #region Wire RealVector ParticleCreators
    480         Operators.RemoveAll(x => x is IRealVectorParticleCreator && ((IRealVectorParticleCreator)x).RealVectorParameter.ActualName != paramName);
    481         var particleCreators = ApplicationManager.Manager.GetInstances<IRealVectorParticleCreator>().ToList();
     493        var particleCreators = Operators.OfType<IRealVectorParticleCreator>()
     494          .Union(ApplicationManager.Manager.GetInstances<IRealVectorParticleCreator>(), new TypeEqualityComparer<IRealVectorParticleCreator>())
     495          .ToList();
    482496        foreach (var pc in particleCreators) {
    483497          pc.RealVectorParameter.ActualName = paramName;
     
    488502          pc.ProblemSizeParameter.Hidden = true;
    489503        }
    490         Operators.AddRange(particleCreators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     504        Operators.AddRange(particleCreators.Except(Operators.OfType<IRealVectorParticleCreator>()));
    491505        #endregion
    492506        #region Wire RealVector ParticleUpdaters
    493         Operators.RemoveAll(x => x is IRealVectorParticleUpdater && ((IRealVectorParticleUpdater)x).RealVectorParameter.ActualName != paramName);
    494         var particleUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorParticleUpdater>().ToList();
     507        var particleUpdaters = Operators.OfType<IRealVectorParticleUpdater>()
     508          .Union(ApplicationManager.Manager.GetInstances<IRealVectorParticleUpdater>(), new TypeEqualityComparer<IRealVectorParticleUpdater>())
     509          .ToList();
    495510        foreach (var pu in particleUpdaters) {
    496511          pu.RealVectorParameter.ActualName = paramName;
     
    499514          pu.BoundsParameter.Hidden = true;
    500515        }
    501         Operators.AddRange(particleUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     516        Operators.AddRange(particleUpdaters.Except(Operators.OfType<IRealVectorParticleUpdater>()));
    502517        #endregion
    503518        #region Wire RealVector SwarmUpdaters
    504         Operators.RemoveAll(x => x is IRealVectorSwarmUpdater && ((IRealVectorSwarmUpdater)x).RealVectorParameter.ActualName != paramName);
    505         var swarmUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorSwarmUpdater>().ToList();
     519        var swarmUpdaters = Operators.OfType<IRealVectorSwarmUpdater>()
     520          .Union(ApplicationManager.Manager.GetInstances<IRealVectorSwarmUpdater>(), new TypeEqualityComparer<IRealVectorSwarmUpdater>())
     521          .ToList();
    506522        foreach (var su in swarmUpdaters) {
    507523          su.RealVectorParameter.ActualName = paramName;
     
    510526          su.MaximizationParameter.Hidden = true;
    511527        }
    512         Operators.AddRange(swarmUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     528        Operators.AddRange(swarmUpdaters.Except(Operators.OfType<IRealVectorSwarmUpdater>()));
    513529        #endregion
    514530        #region Wire RealVector ShakingOperators
    515         Operators.RemoveAll(x => x is IRealVectorMultiNeighborhoodShakingOperator && ((IRealVectorMultiNeighborhoodShakingOperator)x).RealVectorParameter.ActualName != paramName);
    516         var shakingOperators = ApplicationManager.Manager.GetInstances<IRealVectorMultiNeighborhoodShakingOperator>().ToList();
     531        var shakingOperators = Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()
     532          .Union(ApplicationManager.Manager.GetInstances<IRealVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IRealVectorMultiNeighborhoodShakingOperator>())
     533          .ToList();
    517534        foreach (var so in shakingOperators) {
    518535          so.RealVectorParameter.ActualName = paramName;
    519536          so.RealVectorParameter.Hidden = true;
    520537        }
    521         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     538        Operators.AddRange(shakingOperators.Except(Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()));
    522539        #endregion
    523540      } else {
     
    544561
    545562        #region Wire Permutation Crossovers
    546         Operators.RemoveAll(x => x is IPermutationCrossover && ((IPermutationCrossover)x).ChildParameter.ActualName != paramName);
    547         var crossovers = ApplicationManager.Manager.GetInstances<IPermutationCrossover>().ToList();
     563        var crossovers = Operators.OfType<IPermutationCrossover>()
     564          .Union(ApplicationManager.Manager.GetInstances<IPermutationCrossover>(), new TypeEqualityComparer<IPermutationCrossover>())
     565          .ToList();
    548566        foreach (var xo in crossovers) {
    549567          xo.ChildParameter.ActualName = permCreator.PermutationParameter.ActualName;
     
    552570          xo.ParentsParameter.Hidden = true;
    553571        }
    554         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     572        Operators.AddRange(crossovers.Except(Operators.OfType<IPermutationCrossover>()));
    555573        #endregion
    556574        #region Wire Permutation Manipulators
    557         Operators.RemoveAll(x => x is IPermutationManipulator && ((IPermutationManipulator)x).PermutationParameter.ActualName != paramName);
    558         var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList();
     575        var manipulators = Operators.OfType<IPermutationManipulator>()
     576          .Union(ApplicationManager.Manager.GetInstances<IPermutationManipulator>(), new TypeEqualityComparer<IPermutationManipulator>())
     577          .ToList();
    559578        foreach (var m in manipulators) {
    560579          m.PermutationParameter.ActualName = permCreator.PermutationParameter.ActualName;
    561580          m.PermutationParameter.Hidden = true;
    562581        }
    563         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    564         #endregion
    565         #region Wire ShakingOperators
    566         Operators.RemoveAll(x => x is IPermutationMultiNeighborhoodShakingOperator && ((IPermutationMultiNeighborhoodShakingOperator)x).PermutationParameter.ActualName != paramName);
    567         var shakingOperators = ApplicationManager.Manager.GetInstances<IPermutationMultiNeighborhoodShakingOperator>().ToList();
     582        Operators.AddRange(manipulators.Except(Operators.OfType<IPermutationManipulator>()));
     583        #endregion
     584        #region Wire Permutation ShakingOperators
     585        var shakingOperators = Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()
     586          .Union(ApplicationManager.Manager.GetInstances<IPermutationMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IPermutationMultiNeighborhoodShakingOperator>())
     587          .ToList();
    568588        foreach (var op in shakingOperators) {
    569589          op.PermutationParameter.ActualName = paramName;
    570590          op.PermutationParameter.Hidden = true;
    571591        }
    572         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     592        Operators.AddRange(shakingOperators.Except(Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()));
    573593        #endregion
    574594      } else {
     
    580600    }
    581601
    582     protected virtual void UpdateMultiVectorEncodingOperators(List<ISolutionCreator> solutionCreators, Configuration configuration) {
    583       var oldCreator = SolutionCreator as ParameterVectorCreater;
    584       var newCreator = new ParameterVectorCreater();
    585 
    586       #region Configure BinaryVector Creator
    587       var newBinParams = new HashSet<string>(solutionCreators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
    588       if (oldCreator != null) {
    589         // we want to reuse the old creator
    590         var oldParams = new HashSet<string>(oldCreator.Operators.OfType<IBinaryVectorCreator>()
    591           .Select(x => x.BinaryVectorParameter.ActualName));
    592         foreach (var toAdd in newBinParams.Except(oldParams)) {
    593           var paramName = toAdd;
    594           oldCreator.Operators.Add(
    595             solutionCreators.OfType<IBinaryVectorCreator>().Single(x => x.BinaryVectorParameter.ActualName == paramName));
    596         }
    597         foreach (var toRemove in oldParams.Except(newBinParams)) {
    598           var paramName = toRemove;
    599           var op =
    600             oldCreator.Operators.OfType<IBinaryVectorCreator>()
    601               .SingleOrDefault(x => x.BinaryVectorParameter.ActualName == paramName);
     602    protected virtual void ConfigureMultiVectorEncodingOperators(MultiEncodingCreator newCreator, MultiEncoding encoding) {
     603      var newBinParams = new HashSet<string>(newCreator.Operators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
     604      var newIntParams = new HashSet<string>(newCreator.Operators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
     605      var newRealParams = new HashSet<string>(newCreator.Operators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
     606      var newPermParams = new HashSet<string>(newCreator.Operators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
     607
     608      var oldCreator = SolutionCreator as MultiEncodingCreator;
     609      if (oldCreator == null) SolutionCreator = newCreator;
     610      else {
     611        #region Configure BinaryVector Creator
     612        var oldBinParams = new HashSet<string>(oldCreator.Operators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
     613        foreach (var toAdd in newBinParams.Except(oldBinParams)) {
     614          oldCreator.Operators.Add(newCreator.Operators.OfType<IBinaryVectorCreator>().Single(x => x.BinaryVectorParameter.ActualName == toAdd));
     615        }
     616        foreach (var toRemove in oldBinParams.Except(newBinParams)) {
     617          var op = oldCreator.Operators.OfType<IBinaryVectorCreator>().SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
    602618          if (op != null) oldCreator.Operators.Remove(op);
    603619        }
    604       } else {
    605         // we will use the new creator
    606         foreach (var binCreator in solutionCreators.OfType<IBinaryVectorCreator>()) {
    607           newCreator.Operators.Add(binCreator);
    608         }
    609       }
    610       #endregion
    611       #region Configure IntegerVector Creator
    612       var newIntParams = new HashSet<string>(solutionCreators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
    613       if (oldCreator != null) {
    614         // we want to reuse the old creator
    615         var oldParams = new HashSet<string>(oldCreator
    616           .Operators.OfType<IIntegerVectorCreator>()
    617           .Select(x => x.IntegerVectorParameter.ActualName));
    618         foreach (var toAdd in newIntParams.Except(oldParams)) {
    619           var paramName = toAdd;
    620           oldCreator.Operators.Add(
    621             solutionCreators.OfType<IIntegerVectorCreator>().Single(x => x.IntegerVectorParameter.ActualName == paramName));
    622         }
    623         foreach (var toRemove in oldParams.Except(newIntParams)) {
    624           var paramName = toRemove;
    625           var op =
    626             oldCreator.Operators.OfType<IIntegerVectorCreator>()
    627               .SingleOrDefault(x => x.IntegerVectorParameter.ActualName == paramName);
     620        #endregion
     621
     622        #region Configure IntegerVector Creator
     623        var oldIntParams = new HashSet<string>(oldCreator.Operators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
     624        foreach (var toAdd in newIntParams.Except(oldIntParams)) {
     625          oldCreator.Operators.Add(newCreator.Operators.OfType<IIntegerVectorCreator>().Single(x => x.IntegerVectorParameter.ActualName == toAdd));
     626        }
     627        foreach (var toRemove in oldIntParams.Except(newIntParams)) {
     628          var op = oldCreator.Operators.OfType<IIntegerVectorCreator>().SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
    628629          if (op != null) oldCreator.Operators.Remove(op);
    629630        }
    630       } else {
    631         // we will use the new creator
    632         foreach (var intCreator in solutionCreators.OfType<IIntegerVectorCreator>()) {
    633           newCreator.Operators.Add(intCreator);
    634         }
    635       }
    636       #endregion
    637       #region Configure RealVector Creator
    638       var newRealParams = new HashSet<string>(solutionCreators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
    639       if (oldCreator != null) {
    640         // we want to reuse the old creator
    641         var oldParams = new HashSet<string>(oldCreator
    642           .Operators.OfType<IRealVectorCreator>()
    643           .Select(x => x.RealVectorParameter.ActualName));
    644         foreach (var toAdd in newRealParams.Except(oldParams)) {
    645           var paramName = toAdd;
    646           oldCreator.Operators.Add(
    647             solutionCreators.OfType<IRealVectorCreator>().Single(x => x.RealVectorParameter.ActualName == paramName));
    648         }
    649         foreach (var toRemove in oldParams.Except(newRealParams)) {
    650           var paramName = toRemove;
    651           var op =
    652             oldCreator.Operators.OfType<IRealVectorCreator>()
    653               .SingleOrDefault(x => x.RealVectorParameter.ActualName == paramName);
     631        #endregion
     632
     633        #region Configure RealVector Creator
     634        var oldRealParams = new HashSet<string>(oldCreator.Operators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
     635        foreach (var toAdd in newRealParams.Except(oldRealParams)) {
     636          oldCreator.Operators.Add(newCreator.Operators.OfType<IRealVectorCreator>().Single(x => x.RealVectorParameter.ActualName == toAdd));
     637        }
     638        foreach (var toRemove in oldRealParams.Except(newRealParams)) {
     639          var op = oldCreator.Operators.OfType<IRealVectorCreator>().SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
    654640          if (op != null) oldCreator.Operators.Remove(op);
    655641        }
    656       } else {
    657         // we will use the new creator
    658         foreach (var realCreator in solutionCreators.OfType<IRealVectorCreator>()) {
    659           newCreator.Operators.Add(realCreator);
    660         }
    661       }
    662       #endregion
    663       #region Configure Permutation Creator
    664       var newPermParams = new HashSet<string>(solutionCreators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
    665       if (oldCreator != null) {
    666         // we want to reuse the old creator
    667         var oldParams = new HashSet<string>(oldCreator
    668           .Operators.OfType<IPermutationCreator>()
    669           .Select(x => x.PermutationParameter.ActualName));
    670         foreach (var toAdd in newPermParams.Except(oldParams)) {
    671           var paramName = toAdd;
    672           oldCreator.Operators.Add(
    673             solutionCreators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == paramName));
    674         }
    675         foreach (var toRemove in oldParams.Except(newPermParams)) {
    676           var paramName = toRemove;
    677           var op =
    678             oldCreator.Operators.OfType<IPermutationCreator>()
    679               .SingleOrDefault(x => x.PermutationParameter.ActualName == paramName);
     642        #endregion
     643
     644        #region Configure Permutation Creator
     645        var oldPermParams = new HashSet<string>(oldCreator.Operators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
     646        foreach (var toAdd in newPermParams.Except(oldPermParams)) {
     647          oldCreator.Operators.Add(newCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == toAdd));
     648        }
     649        foreach (var toRemove in oldPermParams.Except(newPermParams)) {
     650          var op = oldCreator.Operators.OfType<IPermutationCreator>().SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
    680651          if (op != null) oldCreator.Operators.Remove(op);
    681652        }
    682653        // we also have to sync the permutation type (in case this changes, as it is a value parameter)
    683         foreach (var intersect in newPermParams.Intersect(oldParams)) {
    684           var paramName = intersect;
    685           var oldPermCreator = oldCreator.Operators.OfType<IPermutationCreator>()
    686             .Single(x => x.PermutationParameter.ActualName == paramName);
    687           var newPermCreator = solutionCreators.OfType<IPermutationCreator>()
    688             .Single(x => x.PermutationParameter.ActualName == paramName);
     654        foreach (var intersect in newPermParams.Intersect(oldPermParams)) {
     655          var oldPermCreator = oldCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == intersect);
     656          var newPermCreator = newCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == intersect);
    689657          oldPermCreator.PermutationTypeParameter.Value = newPermCreator.PermutationTypeParameter.Value;
    690658        }
    691       } else {
    692         // we will use the new creator
    693         foreach (var permCreator in solutionCreators.OfType<IPermutationCreator>()) {
    694           newCreator.Operators.Add(permCreator);
    695         }
    696       }
    697       #endregion
    698 
    699       if (oldCreator == null) SolutionCreator = newCreator;
     659        #endregion
     660
     661      }
    700662
    701663      // crossover and manipulator for multi-vector encoding
    702664      // the condition checks if a multi-vector encoding is to be updated (there already exists ParameterVectorCrossover and ParameterVectorManipulator)
    703       if (Operators.OfType<ParameterVectorCrossover>().Any() && Operators.OfType<ParameterVectorManipulator>().Any()) {
     665      if (Operators.OfType<MultiEncodingCrossover>().Any() && Operators.OfType<MultiEncodingManipulator>().Any()) {
    704666        #region Update existing multi-vector encoding
    705667        #region Update ParameterVector Crossover ...
    706         foreach (var oldXo in Operators.OfType<ParameterVectorCrossover>()) {
     668        foreach (var oldXo in Operators.OfType<MultiEncodingCrossover>()) {
    707669          #region ... for binary parameters
    708           var oldBinParams = new HashSet<string>(oldXo.Operators.OfType<IBinaryVectorCrossover>()
    709             .Select(x => x.ChildParameter.ActualName));
     670          var oldBinParams = new HashSet<string>(oldXo.Operators.OfType<IBinaryVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    710671          foreach (var toAdd in newBinParams.Except(oldBinParams))
    711             oldXo.Operators.Add(GetDefaultBinaryCrossover(toAdd, configuration));
     672            oldXo.Operators.Add(GetDefaultBinaryCrossover(toAdd, encoding));
    712673          foreach (var toRemove in oldBinParams.Except(newBinParams)) {
    713             var op =
    714               oldXo.Operators.OfType<IBinaryVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     674            var op = oldXo.Operators.OfType<IBinaryVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    715675            if (op != null) oldXo.Operators.Remove(op);
    716676          }
    717677          #endregion
    718678          #region ... for integer parameters
    719           var oldIntParams = new HashSet<string>(oldXo.Operators.OfType<IIntegerVectorCrossover>()
    720             .Select(x => x.ChildParameter.ActualName));
     679          var oldIntParams = new HashSet<string>(oldXo.Operators.OfType<IIntegerVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    721680          foreach (var toAdd in newIntParams.Except(oldIntParams))
    722             oldXo.Operators.Add(GetDefaultIntegerCrossover(toAdd, configuration));
     681            oldXo.Operators.Add(GetDefaultIntegerCrossover(toAdd, encoding));
    723682          foreach (var toRemove in oldIntParams.Except(newIntParams)) {
    724             var op =
    725               oldXo.Operators.OfType<IIntegerVectorCrossover>()
    726                 .SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     683            var op = oldXo.Operators.OfType<IIntegerVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    727684            if (op != null) oldXo.Operators.Remove(op);
    728685          }
    729686          #endregion
    730687          #region ... for real parameters
    731           var oldRealParams = new HashSet<string>(oldXo.Operators.OfType<IRealVectorCrossover>()
    732             .Select(x => x.ChildParameter.ActualName));
     688          var oldRealParams = new HashSet<string>(oldXo.Operators.OfType<IRealVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    733689          foreach (var toAdd in newRealParams.Except(oldRealParams))
    734             oldXo.Operators.Add(GetDefaultRealCrossover(toAdd, configuration));
     690            oldXo.Operators.Add(GetDefaultRealCrossover(toAdd, encoding));
    735691          foreach (var toRemove in oldRealParams.Except(newRealParams)) {
    736             var op =
    737               oldXo.Operators.OfType<IRealVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     692            var op = oldXo.Operators.OfType<IRealVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    738693            if (op != null) oldXo.Operators.Remove(op);
    739694          }
    740695          #endregion
    741696          #region ... for permutation parameters
    742           var oldPermParams = new HashSet<string>(oldXo.Operators.OfType<IPermutationCrossover>()
    743             .Select(x => x.ChildParameter.ActualName));
     697          var oldPermParams = new HashSet<string>(oldXo.Operators.OfType<IPermutationCrossover>().Select(x => x.ChildParameter.ActualName));
    744698          foreach (var toAdd in newPermParams.Except(oldPermParams))
    745             oldXo.Operators.Add(GetDefaultPermutationCrossover(toAdd, configuration));
     699            oldXo.Operators.Add(GetDefaultPermutationCrossover(toAdd, encoding));
    746700          foreach (var toRemove in oldPermParams.Except(newPermParams)) {
    747             var op =
    748               oldXo.Operators.OfType<IPermutationCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     701            var op = oldXo.Operators.OfType<IPermutationCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    749702            if (op != null) oldXo.Operators.Remove(op);
    750703          }
     
    753706        #endregion
    754707        #region Update ParameterVector Manipulator ...
    755         foreach (var oldM in Operators.OfType<ParameterVectorManipulator>()) {
     708        foreach (var oldM in Operators.OfType<MultiEncodingManipulator>()) {
    756709          #region ... for binary parameters
    757           var oldBinParams = new HashSet<string>(oldM.Operators.OfType<IBinaryVectorManipulator>()
    758             .Select(x => x.BinaryVectorParameter.ActualName));
     710          var oldBinParams = new HashSet<string>(oldM.Operators.OfType<IBinaryVectorManipulator>().Select(x => x.BinaryVectorParameter.ActualName));
    759711          foreach (var toAdd in newBinParams.Except(oldBinParams))
    760             oldM.Operators.Add(GetDefaultBinaryManipulator(toAdd, configuration));
     712            oldM.Operators.Add(GetDefaultBinaryManipulator(toAdd, encoding));
    761713          foreach (var toRemove in oldBinParams.Except(newBinParams)) {
    762             var op =
    763               oldM.Operators.OfType<IBinaryVectorManipulator>()
    764                 .SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
     714            var op = oldM.Operators.OfType<IBinaryVectorManipulator>().SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
    765715            if (op != null) oldM.Operators.Remove(op);
    766716          }
    767717          #endregion
    768718          #region ... for integer parameters
    769           var oldIntParams = new HashSet<string>(oldM.Operators.OfType<IIntegerVectorManipulator>()
    770             .Select(x => x.IntegerVectorParameter.ActualName));
     719          var oldIntParams = new HashSet<string>(oldM.Operators.OfType<IIntegerVectorManipulator>().Select(x => x.IntegerVectorParameter.ActualName));
    771720          foreach (var toAdd in newIntParams.Except(oldIntParams))
    772             oldM.Operators.Add(GetDefaultIntegerManipulator(toAdd, configuration));
     721            oldM.Operators.Add(GetDefaultIntegerManipulator(toAdd, encoding));
    773722          foreach (var toRemove in oldIntParams.Except(newIntParams)) {
    774             var op =
    775               oldM.Operators.OfType<IIntegerVectorManipulator>()
    776                 .SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
     723            var op = oldM.Operators.OfType<IIntegerVectorManipulator>().SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
    777724            if (op != null) oldM.Operators.Remove(op);
    778725          }
    779726          #endregion
    780727          #region ... for real parameters
    781           var oldRealParams = new HashSet<string>(oldM.Operators.OfType<IRealVectorManipulator>()
    782             .Select(x => x.RealVectorParameter.ActualName));
     728          var oldRealParams = new HashSet<string>(oldM.Operators.OfType<IRealVectorManipulator>().Select(x => x.RealVectorParameter.ActualName));
    783729          foreach (var toAdd in newRealParams.Except(oldRealParams))
    784             oldM.Operators.Add(GetDefaultRealManipulator(toAdd, configuration));
     730            oldM.Operators.Add(GetDefaultRealManipulator(toAdd, encoding));
    785731          foreach (var toRemove in oldRealParams.Except(newRealParams)) {
    786             var op =
    787               oldM.Operators.OfType<IRealVectorManipulator>()
    788                 .SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
     732            var op = oldM.Operators.OfType<IRealVectorManipulator>().SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
    789733            if (op != null) oldM.Operators.Remove(op);
    790734          }
    791735          #endregion
    792736          #region ... for permutation parameters
    793           var oldPermParams = new HashSet<string>(oldM.Operators.OfType<IPermutationManipulator>()
    794             .Select(x => x.PermutationParameter.ActualName));
     737          var oldPermParams = new HashSet<string>(oldM.Operators.OfType<IPermutationManipulator>().Select(x => x.PermutationParameter.ActualName));
    795738          foreach (var toAdd in newPermParams.Except(oldPermParams))
    796             oldM.Operators.Add(GetDefaultPermutationManipulator(toAdd, configuration));
     739            oldM.Operators.Add(GetDefaultPermutationManipulator(toAdd, encoding));
    797740          foreach (var toRemove in oldPermParams.Except(newPermParams)) {
    798             var op =
    799               oldM.Operators.OfType<IPermutationManipulator>()
    800                 .SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
     741            var op = oldM.Operators.OfType<IPermutationManipulator>().SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
    801742            if (op != null) oldM.Operators.Remove(op);
    802743          }
     
    815756        Operators.RemoveAll(x => x is IMultiNeighborhoodShakingOperator);
    816757
    817         var crossover = new ParameterVectorCrossover();
    818         var manipulator = new ParameterVectorManipulator();
    819         foreach (var param in configuration.Parameters) {
    820           if (param.Value is BinaryParameterConfiguration) {
    821             crossover.Operators.Add(GetDefaultBinaryCrossover(param.Key, configuration));
    822             manipulator.Operators.Add(GetDefaultBinaryManipulator(param.Key, configuration));
     758        var crossover = new MultiEncodingCrossover();
     759        var manipulator = new MultiEncodingManipulator();
     760        foreach (var enc in encoding.Encodings) {
     761          if (enc is BinaryEncoding) {
     762            crossover.Operators.Add(GetDefaultBinaryCrossover(enc.Name, encoding));
     763            manipulator.Operators.Add(GetDefaultBinaryManipulator(enc.Name, encoding));
    823764            continue;
    824765          }
    825           var intConfig = param.Value as IntegerParameterConfiguration;
     766          var intConfig = enc as IntegerEncoding;
    826767          if (intConfig != null) {
    827             crossover.Operators.Add(GetDefaultIntegerCrossover(param.Key, configuration));
    828             manipulator.Operators.Add(GetDefaultIntegerManipulator(param.Key, configuration));
     768            crossover.Operators.Add(GetDefaultIntegerCrossover(enc.Name, encoding));
     769            manipulator.Operators.Add(GetDefaultIntegerManipulator(enc.Name, encoding));
    829770            continue;
    830771          }
    831           var realConfig = param.Value as RealParameterConfiguration;
     772          var realConfig = enc as RealEncoding;
    832773          if (realConfig != null) {
    833             crossover.Operators.Add(GetDefaultRealCrossover(param.Key, configuration));
    834             manipulator.Operators.Add(GetDefaultRealManipulator(param.Key, configuration));
     774            crossover.Operators.Add(GetDefaultRealCrossover(enc.Name, encoding));
     775            manipulator.Operators.Add(GetDefaultRealManipulator(enc.Name, encoding));
    835776            continue;
    836777          }
    837           var permConfig = param.Value as PermutationParameterConfiguration;
     778          var permConfig = enc as PermutationEncoding;
    838779          if (permConfig != null) {
    839             crossover.Operators.Add(GetDefaultPermutationCrossover(param.Key, configuration));
    840             manipulator.Operators.Add(GetDefaultPermutationManipulator(param.Key, configuration));
     780            crossover.Operators.Add(GetDefaultPermutationCrossover(enc.Name, encoding));
     781            manipulator.Operators.Add(GetDefaultPermutationManipulator(enc.Name, encoding));
    841782            continue;
    842783          }
    843           throw new InvalidOperationException("Unknown type for parameter " + param.Key);
     784          throw new InvalidOperationException("Unknown type for parameter " + enc.Name);
    844785        }
    845786        Operators.Add(crossover);
     
    849790    }
    850791
    851     protected virtual void UpdateMoveOperators() {
    852       Operators.RemoveAll(x => x is IParameterVectorMoveOperator);
    853       var generator = new ParameterVectorMoveGenerator();
    854       generator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
    855       generator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    856 
    857       var evaluator = new ParameterVectorMoveEvaluator();
    858       evaluator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
    859       evaluator.QualityParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
    860       evaluator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    861 
    862       var maker = new ParameterVectorMoveMaker();
    863       maker.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
    864       maker.MoveQualityParameter.ActualName = evaluator.MoveQualityParameter.ActualName;
    865       maker.QualityParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
    866 
    867       Operators.AddRange(new IItem[] { generator, evaluator, maker });
    868     }
    869 
    870792    #region GetDefaultOperators for Crossovers and Manipulators
    871793    // ReSharper disable RedundantNameQualifier
    872     protected virtual IBinaryVectorCrossover GetDefaultBinaryCrossover(string paramName, Configuration config) {
    873       var binConfig = (BinaryParameterConfiguration)config.Parameters[paramName];
     794    protected virtual IBinaryVectorCrossover GetDefaultBinaryCrossover(string paramName, MultiEncoding config) {
     795      var binConfig = (BinaryEncoding)config.Encodings[paramName];
    874796      IBinaryVectorCrossover binXo;
    875797      if (binConfig.Length.Value > 3) binXo = new Encodings.BinaryVectorEncoding.SinglePointCrossover();
     
    880802    }
    881803
    882     protected virtual IBinaryVectorManipulator GetDefaultBinaryManipulator(string paramName, Configuration config) {
     804    protected virtual IBinaryVectorManipulator GetDefaultBinaryManipulator(string paramName, MultiEncoding config) {
    883805      var binM = new Encodings.BinaryVectorEncoding.SomePositionsBitflipManipulator();
    884806      binM.BinaryVectorParameter.ActualName = paramName;
     
    887809    }
    888810
    889     protected virtual IIntegerVectorCrossover GetDefaultIntegerCrossover(string paramName, Configuration config) {
     811    protected virtual IIntegerVectorCrossover GetDefaultIntegerCrossover(string paramName, MultiEncoding config) {
    890812      var intXo = new Encodings.IntegerVectorEncoding.RoundedBlendAlphaCrossover();
    891813      intXo.ChildParameter.ActualName = paramName;
     
    895817    }
    896818
    897     protected virtual IIntegerVectorManipulator GetDefaultIntegerManipulator(string paramName, Configuration configuration) {
     819    protected virtual IIntegerVectorManipulator GetDefaultIntegerManipulator(string paramName, MultiEncoding configuration) {
    898820      var intM = new Encodings.IntegerVectorEncoding.UniformSomePositionsManipulator();
    899821      intM.IntegerVectorParameter.ActualName = paramName;
     
    903825    }
    904826
    905     protected virtual IRealVectorCrossover GetDefaultRealCrossover(string paramName, Configuration configuration) {
     827    protected virtual IRealVectorCrossover GetDefaultRealCrossover(string paramName, MultiEncoding configuration) {
    906828      var realXo = new Encodings.RealVectorEncoding.BlendAlphaCrossover();
    907829      realXo.ChildParameter.ActualName = paramName;
     
    911833    }
    912834
    913     protected virtual IRealVectorManipulator GetDefaultRealManipulator(string paramName, Configuration configuration) {
     835    protected virtual IRealVectorManipulator GetDefaultRealManipulator(string paramName, MultiEncoding configuration) {
    914836      var realM = new Encodings.RealVectorEncoding.BreederGeneticAlgorithmManipulator();
    915837      realM.RealVectorParameter.ActualName = paramName;
     
    918840    }
    919841
    920     protected virtual IPermutationCrossover GetDefaultPermutationCrossover(string paramName, Configuration configuration) {
     842    protected virtual IPermutationCrossover GetDefaultPermutationCrossover(string paramName, MultiEncoding configuration) {
    921843      var permXo = new Encodings.PermutationEncoding.PartiallyMatchedCrossover();
    922844      permXo.ChildParameter.ActualName = paramName;
     
    925847    }
    926848
    927     protected virtual IPermutationManipulator GetDefaultPermutationManipulator(string paramName, Configuration configuration) {
     849    protected virtual IPermutationManipulator GetDefaultPermutationManipulator(string paramName, MultiEncoding configuration) {
    928850      var permM = new Encodings.PermutationEncoding.Swap2Manipulator();
    929851      permM.PermutationParameter.ActualName = paramName;
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveAnalyzer.cs

    r11400 r11484  
    1111
    1212namespace HeuristicLab.Problems.Programmable {
    13   [Item("Multi-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")]
     13  [Item("Multi-objective Analyzer", "Calls the Analyze method of the problem definition.")]
    1414  [StorableClass]
    1515  public class MultiObjectiveAnalyzer : SingleSuccessorOperator, IMultiObjectiveProgrammableProblemAnalyzer {
    1616    public bool EnabledByDefault { get { return true; } }
    1717
    18     public ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    19       get { return (ILookupParameter<IMultiObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     18    public ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter {
     19      get { return (ILookupParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    2020    }
    2121
    22     public ILookupParameter<Configuration> ConfigurationParameter {
    23       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     22    public ILookupParameter<Encoding> EncodingParameter {
     23      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    2424    }
    2525
     
    3737    public MultiObjectiveAnalyzer() {
    3838      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    39       Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    40       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     39      Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     40      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    4141      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    4242      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    4848
    4949    public override IOperation Apply() {
    50       var host = ProblemDefinitionParameter.ActualValue;
    51       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
    52       var config = ConfigurationParameter.ActualValue;
     50      var definition = ProblemDefinitionParameter.ActualValue;
     51      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     52      var config = EncodingParameter.ActualValue;
    5353      var results = ResultsParameter.ActualValue;
    5454
     
    5858
    5959      var vectors = scopes.Select(scope => Helper.Extract(scope, config)).ToArray();
    60       host.Instance.Analyze(vectors, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results);
     60      definition.Analyze(vectors, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results);
    6161      return base.Apply();
    6262    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveEvaluator.cs

    r11400 r11484  
    3030
    3131namespace HeuristicLab.Problems.Programmable {
    32   [Item("Multi-objective Evaluator", "Calls the script's Evaluate method to get the quality values of the parameter vector.")]
     32  [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")]
    3333  [StorableClass]
    3434  public class MultiObjectiveEvaluator : SingleSuccessorOperator, IMultiObjectiveProgrammableProblemEvaluator, IStochasticOperator {
     
    3838    }
    3939
    40     public ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    41       get { return (ILookupParameter<IMultiObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     40    public ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter {
     41      get { return (ILookupParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    4242    }
    4343
    44     public ILookupParameter<Configuration> ConfigurationParameter {
    45       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     44    public ILookupParameter<Encoding> EncodingParameter {
     45      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    4646    }
    4747
     
    5555    public MultiObjectiveEvaluator() {
    5656      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    57       Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    58       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     57      Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     58      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    5959      Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    6060    }
     
    6666    public override IOperation Apply() {
    6767      var random = RandomParameter.ActualValue;
    68       var host = ProblemDefinitionParameter.ActualValue;
    69       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
    70       var config = ConfigurationParameter.ActualValue;
     68      var definition = ProblemDefinitionParameter.ActualValue;
     69      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     70      var config = EncodingParameter.ActualValue;
    7171      var vector = Helper.Extract(ExecutionContext.Scope, config);
    72       QualitiesParameter.ActualValue = new DoubleArray(host.Instance.Evaluate(random, vector));
     72      QualitiesParameter.ActualValue = new DoubleArray(definition.Evaluate(random, vector));
    7373      return base.Apply();
    7474    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveAnalyzer.cs

    r11405 r11484  
    1616    public bool EnabledByDefault { get { return true; } }
    1717
    18     public ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    19       get { return (ILookupParameter<ISingleObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     18    public ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter {
     19      get { return (ILookupParameter<ISingleObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    2020    }
    2121
    22     public ILookupParameter<Configuration> ConfigurationParameter {
    23       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     22    public ILookupParameter<Encoding> EncodingParameter {
     23      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    2424    }
    2525
     
    3737    public SingleObjectiveAnalyzer() {
    3838      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    39       Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    40       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     39      Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     40      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    4141      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    4242      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    4848
    4949    public override IOperation Apply() {
    50       var host = ProblemDefinitionParameter.ActualValue;
    51       if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    52       var config = ConfigurationParameter.ActualValue;
     50      var definition = ProblemDefinitionParameter.ActualValue;
     51      if (definition == null) throw new InvalidOperationException("Problem definition is null");
     52      var config = EncodingParameter.ActualValue;
    5353      var results = ResultsParameter.ActualValue;
    5454
     
    5858
    5959      var vectors = scopes.Select(scope => Helper.Extract(scope, config)).ToArray();
    60       host.Instance.Analyze(vectors, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results);
     60      definition.Analyze(vectors, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results);
    6161      return base.Apply();
    6262    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveEvaluator.cs

    r11405 r11484  
    3838    }
    3939
    40     public ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    41       get { return (ILookupParameter<ISingleObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     40    public ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter {
     41      get { return (ILookupParameter<ISingleObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    4242    }
    4343
    44     public ILookupParameter<Configuration> ConfigurationParameter {
    45       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     44    public ILookupParameter<Encoding> EncodingParameter {
     45      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    4646    }
    4747
     
    5555    public SingleObjectiveEvaluator() {
    5656      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    57       Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    58       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     57      Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     58      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    5959      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6060    }
     
    6666    public override IOperation Apply() {
    6767      var random = RandomParameter.ActualValue;
    68       var host = ProblemDefinitionParameter.ActualValue;
    69       if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    70       var config = ConfigurationParameter.ActualValue;
     68      var definition = ProblemDefinitionParameter.ActualValue;
     69      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     70      var config = EncodingParameter.ActualValue;
    7171      var vector = Helper.Extract(ExecutionContext.Scope, config);
    72       QualityParameter.ActualValue = new DoubleValue(host.Instance.Evaluate(random, vector));
     72      QualityParameter.ActualValue = new DoubleValue(definition.Evaluate(random, vector));
    7373      return base.Apply();
    7474    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/ProblemDefinition.cs

    r11402 r11484  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using HeuristicLab.Common;
     25using HeuristicLab.Core;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27
    2228namespace HeuristicLab.Problems.Programmable {
    23   public abstract class ProblemDefinition : IProblemDefinition {
    24     public abstract Configuration GetConfiguration();
     29  [Item("ProblemDefinition", "Base class for problem definitions.")]
     30  [StorableClass]
     31  public abstract class ProblemDefinition : NamedItem, IProblemDefinition {
     32    [Storable(Name = "Encoding")]
     33    private Encoding encoding;
     34    public Encoding Encoding {
     35      get { return encoding; }
     36      protected set {
     37        if (encoding == value) return;
     38        encoding = value;
     39        OnProblemDefinitionChanged();
     40      }
     41    }
    2542
    26     public dynamic vars { get; set; }
    27     public abstract void Initialize();
     43    [StorableConstructor]
     44    protected ProblemDefinition(bool deserializing) : base(deserializing) { }
     45    protected ProblemDefinition(ProblemDefinition original, Cloner cloner)
     46      : base(original, cloner) {
     47      this.encoding = cloner.Clone(original.encoding);
     48    }
     49    protected ProblemDefinition(Encoding encoding) : this(encoding, "ProblemDefinition") { }
     50    protected ProblemDefinition(Encoding encoding, string name) : this(encoding, name, string.Empty) { }
     51    protected ProblemDefinition(Encoding encoding, string name, string description)
     52      : base(name, description) {
     53      Encoding = encoding;
     54    }
     55
     56    public event EventHandler ProblemDefinitionChanged;
     57    protected void OnProblemDefinitionChanged() {
     58      var handler = ProblemDefinitionChanged;
     59      if (handler != null) handler(this, EventArgs.Empty);
     60    }
     61
     62    public abstract IEnumerable<Individual> GetNeighbors(IRandom random, Individual vector);
    2863  }
    2964}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinition.cs

    r11402 r11484  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Drawing;
    2522using HeuristicLab.Common;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Optimization;
     25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826
    2927namespace HeuristicLab.Problems.Programmable {
    30   [Item("Single-objective Problem Definition", "This definition can be dynamically created through code and assigned to the problem.")]
    31   public class SingleObjectiveProblemDefinition : ISingleObjectiveProblemDefinitionHost, ISingleObjectiveProblemDefinition {
     28  [Item("Single-objective Problem Definition", "Base class for custom single-objective problem definitions.")]
     29  [StorableClass]
     30  public abstract class SingleObjectiveProblemDefinition : ProblemDefinition, ISingleObjectiveProblemDefinition {
     31    [Storable(Name = "Storable")]
    3232    private bool isMaximizationProblem;
    3333    public bool IsMaximizationProblem {
    3434      get { return isMaximizationProblem; }
    3535      set {
     36        if (isMaximizationProblem == value) return;
    3637        isMaximizationProblem = value;
    37         OnInstanceChanged();
     38        OnProblemDefinitionChanged();
    3839      }
    3940    }
    4041
    41     private Func<Configuration> configuration;
    42     public Func<Configuration> Configuration {
    43       get { return configuration; }
    44       set {
    45         configuration = value;
    46         OnInstanceChanged();
    47       }
     42    public abstract double Evaluate(IRandom random, Individual vector);
     43
     44    public abstract void Analyze(Individual[] vectors, double[] qualities, ResultCollection results);
     45
     46    [StorableConstructor]
     47    protected SingleObjectiveProblemDefinition(bool deserializing) : base(deserializing) { }
     48    protected SingleObjectiveProblemDefinition(SingleObjectiveProblemDefinition original, Cloner cloner)
     49      : base(original, cloner) {
     50      this.isMaximizationProblem = original.isMaximizationProblem;
    4851    }
    49 
    50     private Func<IRandom, ParameterVector, double> evaluate;
    51     public Func<IRandom, ParameterVector, double> Evaluate {
    52       get { return evaluate; }
    53       set {
    54         evaluate = value;
    55         OnInstanceChanged();
    56       }
    57     }
    58 
    59     private Action<ParameterVector[], double[], ResultCollection> analyze;
    60     public Action<ParameterVector[], double[], ResultCollection> Analyze {
    61       get { return analyze; }
    62       set {
    63         analyze = value;
    64         OnInstanceChanged();
    65       }
    66     }
    67 
    68     private Func<IRandom, ParameterVector, IEnumerable<ParameterVector>> neighbors;
    69     public Func<IRandom, ParameterVector, IEnumerable<ParameterVector>> Neighbors {
    70       get { return neighbors; }
    71       set {
    72         neighbors = value;
    73         OnInstanceChanged();
    74       }
    75     }
    76 
    77     protected SingleObjectiveProblemDefinition(SingleObjectiveProblemDefinition original, Cloner cloner) {
    78       cloner.RegisterClonedObject(original, this);
    79       name = original.name;
    80       description = original.description;
    81       isMaximizationProblem = original.isMaximizationProblem;
    82       configuration = original.configuration;
    83       evaluate = original.evaluate;
    84       analyze = original.analyze;
    85       neighbors = original.neighbors;
    86     }
    87 
    88     public SingleObjectiveProblemDefinition() : this((string)null, null) { }
    89     public SingleObjectiveProblemDefinition(string name) : this(name, null) { }
    90     public SingleObjectiveProblemDefinition(string name, string description) {
    91       this.name = name ?? ItemName;
    92       this.description = description ?? ItemDescription;
    93       configuration = () => new Configuration();
    94       evaluate = (random, vector) => 0;
    95       analyze = (vectors, doubles, results) => { };
    96       neighbors = (random, vector) => new[] { (ParameterVector)vector.Clone() };
    97     }
    98 
    99 
    100     public IDeepCloneable Clone(Cloner cloner) {
    101       return new SingleObjectiveProblemDefinition(this, cloner);
    102     }
    103 
    104     public ISingleObjectiveProblemDefinition Instance {
    105       get { return this; }
    106     }
    107 
    108     public event EventHandler InstanceChanged;
    109     protected void OnInstanceChanged() {
    110       var handler = InstanceChanged;
    111       if (handler != null) handler(this, EventArgs.Empty);
    112     }
    113 
    114     #region Problem definition explicit interface implementations
    115     Configuration IProblemDefinition.GetConfiguration() {
    116       return Configuration();
    117     }
    118 
    119     bool ISingleObjectiveProblemDefinition.IsMaximizationProblem {
    120       get { return IsMaximizationProblem; }
    121     }
    122 
    123     double ISingleObjectiveProblemDefinition.Evaluate(IRandom random, ParameterVector vector) {
    124       return Evaluate(random, vector);
    125     }
    126 
    127     void ISingleObjectiveProblemDefinition.Analyze(ParameterVector[] vectors, double[] qualities, ResultCollection results) {
    128       Analyze(vectors, qualities, results);
    129     }
    130 
    131     IEnumerable<ParameterVector> ISingleObjectiveProblemDefinition.GetNeighbors(IRandom random, ParameterVector vector) {
    132       return Neighbors(random, vector);
    133     }
    134     #endregion
    135 
    136     #region INamedItem
    137     protected string name;
    138     /// <inheritdoc/>
    139     /// <remarks>Calls <see cref="OnNameChanging"/> and also <see cref="OnNameChanged"/>
    140     /// eventually in the setter.</remarks>
    141     public string Name {
    142       get { return name; }
    143       set {
    144         if (!CanChangeName) throw new NotSupportedException("Name cannot be changed.");
    145         if (!(name.Equals(value) || (value == null) && (name == string.Empty))) {
    146           CancelEventArgs<string> e = value == null ? new CancelEventArgs<string>(string.Empty) : new CancelEventArgs<string>(value);
    147           OnNameChanging(e);
    148           if (!e.Cancel) {
    149             name = value == null ? string.Empty : value;
    150             OnNameChanged();
    151           }
    152         }
    153       }
    154     }
    155     public virtual bool CanChangeName {
    156       get { return true; }
    157     }
    158     protected string description;
    159     public string Description {
    160       get { return description; }
    161       set {
    162         if (!CanChangeDescription) throw new NotSupportedException("Description cannot be changed.");
    163         if (!(description.Equals(value) || (value == null) && (description == string.Empty))) {
    164           description = value == null ? string.Empty : value;
    165           OnDescriptionChanged();
    166         }
    167       }
    168     }
    169     public virtual bool CanChangeDescription {
    170       get { return true; }
    171     }
    172 
    173     /// <summary>
    174     /// Gets the string representation of the current instance in the format: <c>Name: [null|Value]</c>.
    175     /// </summary>
    176     /// <returns>The current instance as a string.</returns>
    177     public override string ToString() {
    178       return Name;
    179     }
    180 
    181     /// <inheritdoc/>
    182     public event EventHandler<CancelEventArgs<string>> NameChanging;
    183     /// <summary>
    184     /// Fires a new <c>NameChanging</c> event.
    185     /// </summary>
    186     /// <param name="e">The event arguments of the changing.</param>
    187     protected virtual void OnNameChanging(CancelEventArgs<string> e) {
    188       var handler = NameChanging;
    189       if (handler != null) handler(this, e);
    190     }
    191     /// <inheritdoc/>
    192     public event EventHandler NameChanged;
    193     /// <summary>
    194     /// Fires a new <c>NameChanged</c> event.
    195     /// </summary>
    196     /// <remarks>Calls <see cref="ItemBase.OnChanged"/>.</remarks>
    197     protected virtual void OnNameChanged() {
    198       var handler = NameChanged;
    199       if (handler != null) handler(this, EventArgs.Empty);
    200       OnToStringChanged();
    201     }
    202     /// <inheritdoc/>
    203     public event EventHandler DescriptionChanged;
    204     /// <summary>
    205     /// Fires a new <c>DescriptionChanged</c> event.
    206     /// </summary>
    207     /// <remarks>Calls <see cref="ItemBase.OnChanged"/>.</remarks>
    208     protected virtual void OnDescriptionChanged() {
    209       var handler = DescriptionChanged;
    210       if (handler != null) handler(this, EventArgs.Empty);
    211     }
    212     #endregion
    213     #region IItem
    214     public virtual string ItemName {
    215       get { return ItemAttribute.GetName(this.GetType()); }
    216     }
    217     public virtual string ItemDescription {
    218       get { return ItemAttribute.GetDescription(this.GetType()); }
    219     }
    220     public Version ItemVersion {
    221       get { return ItemAttribute.GetVersion(this.GetType()); }
    222     }
    223     public static Image StaticItemImage {
    224       get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; }
    225     }
    226     public virtual Image ItemImage {
    227       get { return ItemAttribute.GetImage(this.GetType()); }
    228     }
    229     public object Clone() {
    230       return Clone(new Cloner());
    231     }
    232 
    233     public event EventHandler ItemImageChanged;
    234     protected virtual void OnItemImageChanged() {
    235       var handler = ItemImageChanged;
    236       if (handler != null) handler(this, EventArgs.Empty);
    237     }
    238     public event EventHandler ToStringChanged;
    239     protected virtual void OnToStringChanged() {
    240       var handler = ToStringChanged;
    241       if (handler != null) handler(this, EventArgs.Empty);
    242     }
    243     #endregion
     52    protected SingleObjectiveProblemDefinition(Encoding encoding) : this(encoding, "SingleObjectiveProblemDefinition", null) { }
     53    protected SingleObjectiveProblemDefinition(Encoding encoding, string name) : this(encoding, name, null) { }
     54    protected SingleObjectiveProblemDefinition(Encoding encoding, string name, string description)
     55      : base(encoding) { }
    24456  }
    24557}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r11424 r11484  
    5555    }
    5656
    57     public IValueParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    58       get { return (IValueParameter<ISingleObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
    59     }
    60 
    61     protected IValueParameter<Configuration> ConfigurationParameter {
    62       get { return (IValueParameter<Configuration>)Parameters["Configuration"]; }
    63     }
    64 
    65     public ISingleObjectiveProblemDefinitionHost ProblemDefinition {
     57    public IValueParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter {
     58      get { return (IValueParameter<ISingleObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
     59    }
     60
     61    protected IValueParameter<Encoding> EncodingParameter {
     62      get { return (IValueParameter<Encoding>)Parameters["Encoding"]; }
     63    }
     64
     65    public ISingleObjectiveProblemDefinition ProblemDefinition {
    6666      get { return ProblemDefinitionParameter.Value; }
    6767      set { ProblemDefinitionParameter.Value = value; }
     
    6969
    7070    [Storable]
    71     protected List<IParameter> DynamicConfigurationParameters;
     71    protected List<IParameter> DynamicEncodingParameters;
    7272
    7373    [StorableConstructor]
     
    7676    protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem original, Cloner cloner)
    7777      : base(original, cloner) {
    78       DynamicConfigurationParameters = original.DynamicConfigurationParameters.Select(cloner.Clone).ToList();
     78      DynamicEncodingParameters = original.DynamicEncodingParameters.Select(cloner.Clone).ToList();
    7979      RegisterEventHandlers();
    8080    }
    8181    public SingleObjectiveProgrammableProblem()
    82       : base(new SingleObjectiveEvaluator(), new ParameterVectorCreater()) {
    83       Parameters.Add(new ValueParameter<ISingleObjectiveProblemDefinitionHost>("ProblemDefinition", "Defines the problem.", new SingleObjectiveProblemDefinitionScript() { Name = Name }));
    84       Parameters.Add(new ValueParameter<Configuration>("Configuration", "Describes which parameters exist, what they're called, what type they are and their bounds if any."));
    85 
    86       DynamicConfigurationParameters = new List<IParameter>();
     82      : base(new SingleObjectiveEvaluator(), new MultiEncodingCreator()) {
     83      Parameters.Add(new ValueParameter<ISingleObjectiveProblemDefinition>("ProblemDefinition", "Defines the problem.", new SingleObjectiveProblemScript() { Name = Name }));
     84      Parameters.Add(new ValueParameter<Encoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any."));
     85
     86      DynamicEncodingParameters = new List<IParameter>();
    8787
    8888      Operators.Add(new BestScopeSolutionAnalyzer());
     
    116116
    117117    private void RegisterHostInstanceChanges() {
    118       ProblemDefinitionParameter.Value.InstanceChanged += ProblemDefinitionHostOnInstanceChanged;
     118      ProblemDefinitionParameter.Value.ProblemDefinitionChanged += ProblemDefinitionChanged;
    119119      ProblemDefinitionParameter.Value.NameChanged += ProblemDefinitionHostOnNameChanged;
    120120    }
     
    135135    }
    136136
    137     protected virtual void ProblemDefinitionHostOnInstanceChanged(object sender, EventArgs eventArgs) {
     137    protected virtual void ProblemDefinitionChanged(object sender, EventArgs eventArgs) {
    138138      Parameterize();
    139139    }
    140140
    141141    protected virtual void Parameterize() {
    142       var instance = ProblemDefinitionParameter.Value.Instance;
    143       if (instance == null) return;
    144 
    145       Configuration configuration;
     142      var definition = ProblemDefinitionParameter.Value;
     143      if (definition == null) return;
     144
     145      Encoding encoding;
    146146      try {
    147         configuration = instance.GetConfiguration();
     147        encoding = definition.Encoding;
    148148      } catch { return; }
    149       ConfigurationParameter.Value = configuration;
    150       Maximization.Value = instance.IsMaximizationProblem;
    151 
    152       Evaluator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     149      EncodingParameter.Value = encoding;
     150      Maximization.Value = definition.IsMaximizationProblem;
     151
     152      Evaluator.EncodingParameter.ActualName = EncodingParameter.Name;
    153153      Evaluator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    154154      foreach (var evalOp in Operators.OfType<ISingleObjectiveProgrammableProblemEvaluator>()) {
    155         evalOp.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     155        evalOp.EncodingParameter.ActualName = EncodingParameter.Name;
    156156        evalOp.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    157157      }
    158158      foreach (var analyzeOp in Operators.OfType<ISingleObjectiveProgrammableProblemAnalyzer>()) {
    159         analyzeOp.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     159        analyzeOp.EncodingParameter.ActualName = EncodingParameter.Name;
    160160        analyzeOp.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    161161        analyzeOp.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    162162      }
    163163
    164       var solutionCreators = UpdateDynamicConfigurationParameters(configuration);
    165 
    166       if (solutionCreators.Count == 1) {
    167         Operators.RemoveAll(x => x is ParameterVectorCrossover
    168                               || x is ParameterVectorManipulator);
    169         UpdateSingleVectorEncodingOperators(solutionCreators, configuration);
     164      foreach (var param in DynamicEncodingParameters)
     165        if (Parameters.Contains(param)) Parameters.Remove(param);
     166      DynamicEncodingParameters.Clear();
     167
     168      var creator = ConfigureCreator(encoding);
     169
     170      foreach (var param in DynamicEncodingParameters) {
     171        param.Hidden = true;
     172        Parameters.Add(param);
     173      }
     174
     175      var multiEncoding = encoding as MultiEncoding;
     176      if (multiEncoding != null) {
     177        ConfigureMultiVectorEncodingOperators((MultiEncodingCreator)creator, multiEncoding);
    170178      } else {
    171         UpdateMultiVectorEncodingOperators(solutionCreators, configuration);
     179        ConfigureSingleEncodingOperators(creator, encoding);
    172180      }
    173181      UpdateImprovementOperators();
     
    175183    }
    176184
    177     protected virtual List<ISolutionCreator> UpdateDynamicConfigurationParameters(Configuration configuration) {
    178       foreach (var param in DynamicConfigurationParameters)
    179         if (Parameters.Contains(param)) Parameters.Remove(param);
    180       DynamicConfigurationParameters.Clear();
    181 
    182       var solutionCreators = new List<ISolutionCreator>();
    183       foreach (var param in configuration.Parameters) {
    184         #region Configure BinaryVector Creator
    185         var binConfig = param.Value as BinaryParameterConfiguration;
    186         if (binConfig != null) {
    187           var p = new ValueParameter<IntValue>(param.Key + "Length", binConfig.Length);
    188           DynamicConfigurationParameters.Add(p);
    189 
    190           var creator = new RandomBinaryVectorCreator();
    191           creator.BinaryVectorParameter.ActualName = param.Key;
    192           creator.LengthParameter.ActualName = p.Name;
    193           solutionCreators.Add(creator);
    194         }
    195         #endregion
    196         #region Configure IntegerVector Creator
    197         var intConfig = param.Value as IntegerParameterConfiguration;
    198         if (intConfig != null) {
    199           var l = new ValueParameter<IntValue>(param.Key + "Length", intConfig.Length);
    200           var b = new ValueParameter<IntMatrix>(param.Key + "Bounds", intConfig.Bounds);
    201           DynamicConfigurationParameters.Add(l);
    202           DynamicConfigurationParameters.Add(b);
    203 
    204           var creator = new UniformRandomIntegerVectorCreator();
    205           creator.IntegerVectorParameter.ActualName = param.Key;
    206           creator.LengthParameter.ActualName = l.Name;
    207           creator.BoundsParameter.ActualName = b.Name;
    208           solutionCreators.Add(creator);
    209         }
    210         #endregion
    211         #region Configure RealVector Creator
    212         var realConfig = param.Value as RealParameterConfiguration;
    213         if (realConfig != null) {
    214           var l = new ValueParameter<IntValue>(param.Key + "Length", realConfig.Length);
    215           var b = new ValueParameter<DoubleMatrix>(param.Key + "Bounds", realConfig.Bounds);
    216           DynamicConfigurationParameters.Add(l);
    217           DynamicConfigurationParameters.Add(b);
    218 
    219           var creator = new UniformRandomRealVectorCreator();
    220           creator.RealVectorParameter.ActualName = param.Key;
    221           creator.LengthParameter.ActualName = l.Name;
    222           creator.BoundsParameter.ActualName = b.Name;
    223           solutionCreators.Add(creator);
    224         }
    225         #endregion
    226         #region Configure Permutation Creator
    227         var permConfig = param.Value as PermutationParameterConfiguration;
    228         if (permConfig != null) {
    229           var l = new ValueParameter<IntValue>(param.Key + "Length", permConfig.Length);
    230           DynamicConfigurationParameters.Add(l);
    231 
    232           var creator = new RandomPermutationCreator();
    233           creator.PermutationParameter.ActualName = param.Key;
    234           creator.LengthParameter.ActualName = l.Name;
    235           creator.PermutationTypeParameter.Value = permConfig.Type;
    236           solutionCreators.Add(creator);
    237         }
    238         #endregion
    239       }
    240 
    241       foreach (var param in DynamicConfigurationParameters) {
    242         param.Hidden = true;
    243         Parameters.Add(param);
    244       }
    245       return solutionCreators;
    246     }
    247 
    248     protected virtual void UpdateSingleVectorEncodingOperators(List<ISolutionCreator> solutionCreators, Configuration configuration) {
    249       var newCreator = solutionCreators.Single();
     185    protected virtual ISolutionCreator ConfigureCreator(Encoding encoding) {
     186      #region Configure MultiEncoding Creator
     187      var multiEncoding = encoding as MultiEncoding;
     188      if (multiEncoding != null) {
     189        var creator = new MultiEncodingCreator();
     190        foreach (var enc in multiEncoding.Encodings) {
     191          if (enc is MultiEncoding) throw new InvalidOperationException("MultiEncoding within a MultiEncoding is not supported.");
     192          creator.Operators.Add(ConfigureCreator(enc));
     193        }
     194        return creator;
     195      }
     196      #endregion
     197      #region Configure BinaryVector Creator
     198      var binEnc = encoding as BinaryEncoding;
     199      if (binEnc != null) {
     200        var p = new ValueParameter<IntValue>(binEnc.Name + "Length", binEnc.Length);
     201        DynamicEncodingParameters.Add(p);
     202
     203        var creator = new RandomBinaryVectorCreator();
     204        creator.BinaryVectorParameter.ActualName = binEnc.Name;
     205        creator.LengthParameter.ActualName = p.Name;
     206        return creator;
     207      }
     208      #endregion
     209      #region Configure IntegerVector Creator
     210      var intEnc = encoding as IntegerEncoding;
     211      if (intEnc != null) {
     212        var l = new ValueParameter<IntValue>(intEnc.Name + "Length", intEnc.Length);
     213        var b = new ValueParameter<IntMatrix>(intEnc.Name + "Bounds", intEnc.Bounds);
     214        DynamicEncodingParameters.Add(l);
     215        DynamicEncodingParameters.Add(b);
     216
     217        var creator = new UniformRandomIntegerVectorCreator();
     218        creator.IntegerVectorParameter.ActualName = intEnc.Name;
     219        creator.LengthParameter.ActualName = l.Name;
     220        creator.BoundsParameter.ActualName = b.Name;
     221        return creator;
     222      }
     223      #endregion
     224      #region Configure RealVector Creator
     225      var realEnc = encoding as RealEncoding;
     226      if (realEnc != null) {
     227        var l = new ValueParameter<IntValue>(realEnc.Name + "Length", realEnc.Length);
     228        var b = new ValueParameter<DoubleMatrix>(realEnc.Name + "Bounds", realEnc.Bounds);
     229        DynamicEncodingParameters.Add(l);
     230        DynamicEncodingParameters.Add(b);
     231
     232        var creator = new UniformRandomRealVectorCreator();
     233        creator.RealVectorParameter.ActualName = realEnc.Name;
     234        creator.LengthParameter.ActualName = l.Name;
     235        creator.BoundsParameter.ActualName = b.Name;
     236        return creator;
     237      }
     238      #endregion
     239      #region Configure Permutation Creator
     240      var permEnc = encoding as PermutationEncoding;
     241      if (permEnc != null) {
     242        var l = new ValueParameter<IntValue>(permEnc.Name + "Length", permEnc.Length);
     243        DynamicEncodingParameters.Add(l);
     244
     245        var creator = new RandomPermutationCreator();
     246        creator.PermutationParameter.ActualName = permEnc.Name;
     247        creator.LengthParameter.ActualName = l.Name;
     248        creator.PermutationTypeParameter.Value = permEnc.Type;
     249        return creator;
     250      }
     251      #endregion
     252      throw new ArgumentException(string.Format("Encoding {0} is unknown.", encoding != null ? encoding.GetType().FullName : "(null)"));
     253    }
     254
     255    protected virtual void ConfigureSingleEncodingOperators(ISolutionCreator newCreator, Encoding encoding) {
     256      // remove all multiencoding operators
     257      Operators.RemoveAll(x => x is MultiEncodingCrossover
     258                            || x is MultiEncodingManipulator
     259                            || x is MultiEncodingCreator);
     260
    250261      #region Configure Operators for BinaryVectorEncoding
    251262      var binCreator = newCreator as IBinaryVectorCreator;
     
    260271
    261272        #region Wire BinaryVector Crossovers
    262         Operators.RemoveAll(x => x is IBinaryVectorCrossover && ((IBinaryVectorCrossover)x).ChildParameter.ActualName != paramName);
    263         var crossovers = ApplicationManager.Manager.GetInstances<IBinaryVectorCrossover>().ToList();
     273        var crossovers = Operators.OfType<IBinaryVectorCrossover>()
     274          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorCrossover>(), new TypeEqualityComparer<IBinaryVectorCrossover>())
     275          .ToList();
    264276        foreach (var xo in crossovers) {
    265277          xo.ChildParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
     
    268280          xo.ParentsParameter.Hidden = true;
    269281        }
    270         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     282        Operators.AddRange(crossovers.Except(Operators.OfType<IBinaryVectorCrossover>()));
    271283        #endregion
    272284        #region Wire BinaryVector Manipulators
    273         Operators.RemoveAll(x => x is IBinaryVectorManipulator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
    274         var manipulators = ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>().ToList();
     285        var manipulators = Operators.OfType<IBinaryVectorManipulator>()
     286          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>(), new TypeEqualityComparer<IBinaryVectorManipulator>())
     287          .ToList();
    275288        foreach (var m in manipulators) {
    276289          m.BinaryVectorParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
    277290          m.BinaryVectorParameter.Hidden = true;
    278291        }
    279         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     292        Operators.AddRange(manipulators.Except(Operators.OfType<IBinaryVectorManipulator>()));
    280293        #endregion
    281294        #region Wire BinaryVector ShakingOperators
    282         Operators.RemoveAll(x => x is IBinaryVectorMultiNeighborhoodShakingOperator && ((IBinaryVectorMultiNeighborhoodShakingOperator)x).BinaryVectorParameter.ActualName != paramName);
    283         var shakingOperators = ApplicationManager.Manager.GetInstances<IBinaryVectorMultiNeighborhoodShakingOperator>().ToList();
     295        var shakingOperators = Operators.OfType<IBinaryVectorMultiNeighborhoodShakingOperator>()
     296          .Union(ApplicationManager.Manager.GetInstances<IBinaryVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IBinaryVectorMultiNeighborhoodShakingOperator>())
     297          .ToList();
    284298        foreach (var so in shakingOperators) {
    285299          so.BinaryVectorParameter.ActualName = paramName;
    286300          so.BinaryVectorParameter.Hidden = true;
    287301        }
    288         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     302        Operators.AddRange(shakingOperators.Except(Operators.OfType<IBinaryVectorMultiNeighborhoodShakingOperator>()));
    289303        #endregion
    290304      } else {
     
    307321
    308322        #region Wire IntegerVector Crossovers
    309         Operators.RemoveAll(x => x is IIntegerVectorCrossover && ((IIntegerVectorCrossover)x).ChildParameter.ActualName != paramName);
    310         var crossovers = ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>().ToList();
     323        var crossovers = Operators.OfType<IIntegerVectorCrossover>()
     324          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>(), new TypeEqualityComparer<IIntegerVectorCrossover>())
     325          .ToList();
    311326        foreach (var xo in crossovers) {
    312327          xo.ChildParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     
    320335          }
    321336        }
    322         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     337        Operators.AddRange(crossovers.Except(Operators.OfType<IIntegerVectorCrossover>()));
    323338        #endregion
    324339        #region Wire IntegerVector Manipulators
    325         Operators.RemoveAll(x => x is IIntegerVectorManipulator && ((IIntegerVectorManipulator)x).IntegerVectorParameter.ActualName != paramName);
    326         var manipulators = ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>().ToList();
     340        var manipulators = Operators.OfType<IIntegerVectorManipulator>()
     341          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>(), new TypeEqualityComparer<IIntegerVectorManipulator>())
     342          .ToList();
    327343        foreach (var m in manipulators) {
    328344          m.IntegerVectorParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     
    342358          }
    343359        }
    344         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     360        Operators.AddRange(manipulators.Except(Operators.OfType<IIntegerVectorManipulator>()));
    345361        #region Wire IntegerVector StrategyParameters for SelfAdaptiveManipulators
    346         Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IIntegerVectorStdDevStrategyParameterCreator) || x is IIntegerVectorStdDevStrategyParameterCreator && ((IIntegerVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    347         Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IIntegerVectorStdDevStrategyParameterManipulator) || x is IIntegerVectorStdDevStrategyParameterManipulator && ((IIntegerVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    348         Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IIntegerVectorStdDevStrategyParameterCrossover) || x is IIntegerVectorStdDevStrategyParameterCrossover && ((IIntegerVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    349         var strategyOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorStdDevStrategyParameterOperator>().ToList();
    350         if (!(configuration.Parameters.First().Value is IntegerParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with integervector creator that is not an integer-coded problem.");
    351         var problemSize = ((IntegerParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
    352         var b = ((IntegerParameterConfiguration)configuration.Parameters.First().Value).Bounds;
     362        var strategyOperators = Operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>()
     363          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorStdDevStrategyParameterOperator>(), new TypeEqualityComparer<IIntegerVectorStdDevStrategyParameterOperator>())
     364          .ToList();
     365        var problemSize = ((IntegerEncoding)encoding).Length.Value;
     366        var b = ((IntegerEncoding)encoding).Bounds;
    353367        var bounds = new DoubleMatrix(b.Rows, b.Columns);
    354368        for (var i = 0; i < bounds.Rows; i++) {
     
    380394          }
    381395        }
    382         Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     396        Operators.AddRange(strategyOperators.Except(Operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>()));
    383397        #endregion
    384398        #endregion
    385399        #region Wire IntegerVector ShakingOperators
    386         Operators.RemoveAll(x => x is IIntegerVectorMultiNeighborhoodShakingOperator && ((IIntegerVectorMultiNeighborhoodShakingOperator)x).IntegerVectorParameter.ActualName != paramName);
    387         var shakingOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorMultiNeighborhoodShakingOperator>().ToList();
     400        var shakingOperators = Operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>()
     401          .Union(ApplicationManager.Manager.GetInstances<IIntegerVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IIntegerVectorMultiNeighborhoodShakingOperator>())
     402          .ToList();
    388403        foreach (var so in shakingOperators) {
    389404          so.IntegerVectorParameter.ActualName = paramName;
    390405          so.IntegerVectorParameter.Hidden = true;
    391406        }
    392         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     407        Operators.AddRange(shakingOperators.Except(Operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>()));
    393408        #endregion
    394409      } else {
     
    412427
    413428        #region Wire RealVector Crossovers
    414         Operators.RemoveAll(x => x is IRealVectorCrossover && ((IRealVectorCrossover)x).ChildParameter.ActualName != paramName);
    415         var crossovers = ApplicationManager.Manager.GetInstances<IRealVectorCrossover>().ToList();
     429        var crossovers = Operators.OfType<IRealVectorCrossover>()
     430          .Union(ApplicationManager.Manager.GetInstances<IRealVectorCrossover>(), new TypeEqualityComparer<IRealVectorCrossover>())
     431          .ToList();
    416432        foreach (var xo in crossovers) {
    417433          xo.ChildParameter.ActualName = paramName;
     
    422438          xo.BoundsParameter.Hidden = true;
    423439        }
    424         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     440        Operators.AddRange(crossovers.Except(Operators.OfType<IRealVectorCrossover>()));
    425441        #endregion
    426442        #region Wire RealVector Manipulators
    427         Operators.RemoveAll(x => x is IRealVectorManipulator && ((IRealVectorManipulator)x).RealVectorParameter.ActualName != paramName);
    428         var manipulators = ApplicationManager.Manager.GetInstances<IRealVectorManipulator>().ToList();
     443        var manipulators = Operators.OfType<IRealVectorManipulator>()
     444          .Union(ApplicationManager.Manager.GetInstances<IRealVectorManipulator>(), new TypeEqualityComparer<IRealVectorManipulator>())
     445          .ToList();
    429446        foreach (var m in manipulators) {
    430447          m.RealVectorParameter.ActualName = paramName;
     
    441458          }
    442459        }
    443         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     460        Operators.AddRange(manipulators.Except(Operators.OfType<IRealVectorManipulator>()));
    444461        #region Wire RealVector Strategy Parameters for SelfAdaptiveManipulators
    445 
    446         Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IRealVectorStdDevStrategyParameterCreator) || x is IRealVectorStdDevStrategyParameterCreator && ((IRealVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    447         Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IRealVectorStdDevStrategyParameterManipulator) || x is IRealVectorStdDevStrategyParameterManipulator && ((IRealVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    448         Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IRealVectorStdDevStrategyParameterCrossover) || x is IRealVectorStdDevStrategyParameterCrossover && ((IRealVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    449         var strategyOperators = ApplicationManager.Manager.GetInstances<IRealVectorStdDevStrategyParameterOperator>().ToList();
    450         if (!(configuration.Parameters.First().Value is RealParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with realvector creator that is not a real-coded problem.");
    451         var problemSize = ((RealParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
    452         var bounds = (DoubleMatrix)((RealParameterConfiguration)configuration.Parameters.First().Value).Bounds.Clone();
     462        var strategyOperators = Operators.OfType<IRealVectorStdDevStrategyParameterOperator>()
     463          .Union(ApplicationManager.Manager.GetInstances<IRealVectorStdDevStrategyParameterOperator>(), new TypeEqualityComparer<IRealVectorStdDevStrategyParameterOperator>())
     464          .ToList();
     465        var problemSize = ((RealEncoding)encoding).Length.Value;
     466        var bounds = (DoubleMatrix)((RealEncoding)encoding).Bounds.Clone();
    453467        for (var i = 0; i < bounds.Rows; i++) {
    454468          bounds[i, 1] = 0.1 * (bounds[i, 1] - bounds[i, 0]);
     
    478492          }
    479493        }
    480         Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     494        Operators.AddRange(strategyOperators.Except(Operators.OfType<IRealVectorStdDevStrategyParameterOperator>()));
    481495        #endregion
    482496        #endregion
    483497        #region Wire RealVector ParticleCreators
    484         Operators.RemoveAll(x => x is IRealVectorParticleCreator && ((IRealVectorParticleCreator)x).RealVectorParameter.ActualName != paramName);
    485         var particleCreators = ApplicationManager.Manager.GetInstances<IRealVectorParticleCreator>().ToList();
     498        var particleCreators = Operators.OfType<IRealVectorParticleCreator>()
     499          .Union(ApplicationManager.Manager.GetInstances<IRealVectorParticleCreator>(), new TypeEqualityComparer<IRealVectorParticleCreator>())
     500          .ToList();
    486501        foreach (var pc in particleCreators) {
    487502          pc.RealVectorParameter.ActualName = paramName;
     
    492507          pc.ProblemSizeParameter.Hidden = true;
    493508        }
    494         Operators.AddRange(particleCreators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     509        Operators.AddRange(particleCreators.Except(Operators.OfType<IRealVectorParticleCreator>()));
    495510        #endregion
    496511        #region Wire RealVector ParticleUpdaters
    497         Operators.RemoveAll(x => x is IRealVectorParticleUpdater && ((IRealVectorParticleUpdater)x).RealVectorParameter.ActualName != paramName);
    498         var particleUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorParticleUpdater>().ToList();
     512        var particleUpdaters = Operators.OfType<IRealVectorParticleUpdater>()
     513          .Union(ApplicationManager.Manager.GetInstances<IRealVectorParticleUpdater>(), new TypeEqualityComparer<IRealVectorParticleUpdater>())
     514          .ToList();
    499515        foreach (var pu in particleUpdaters) {
    500516          pu.RealVectorParameter.ActualName = paramName;
     
    503519          pu.BoundsParameter.Hidden = true;
    504520        }
    505         Operators.AddRange(particleUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     521        Operators.AddRange(particleUpdaters.Except(Operators.OfType<IRealVectorParticleUpdater>()));
    506522        #endregion
    507523        #region Wire RealVector SwarmUpdaters
    508         Operators.RemoveAll(x => x is IRealVectorSwarmUpdater && ((IRealVectorSwarmUpdater)x).RealVectorParameter.ActualName != paramName);
    509         var swarmUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorSwarmUpdater>().ToList();
     524        var swarmUpdaters = Operators.OfType<IRealVectorSwarmUpdater>()
     525          .Union(ApplicationManager.Manager.GetInstances<IRealVectorSwarmUpdater>(), new TypeEqualityComparer<IRealVectorSwarmUpdater>())
     526          .ToList();
    510527        foreach (var su in swarmUpdaters) {
    511528          su.RealVectorParameter.ActualName = paramName;
     
    514531          su.MaximizationParameter.Hidden = true;
    515532        }
    516         Operators.AddRange(swarmUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     533        Operators.AddRange(swarmUpdaters.Except(Operators.OfType<IRealVectorSwarmUpdater>()));
    517534        #endregion
    518535        #region Wire RealVector ShakingOperators
    519         Operators.RemoveAll(x => x is IRealVectorMultiNeighborhoodShakingOperator && ((IRealVectorMultiNeighborhoodShakingOperator)x).RealVectorParameter.ActualName != paramName);
    520         var shakingOperators = ApplicationManager.Manager.GetInstances<IRealVectorMultiNeighborhoodShakingOperator>().ToList();
     536        var shakingOperators = Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()
     537          .Union(ApplicationManager.Manager.GetInstances<IRealVectorMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IRealVectorMultiNeighborhoodShakingOperator>())
     538          .ToList();
    521539        foreach (var so in shakingOperators) {
    522540          so.RealVectorParameter.ActualName = paramName;
    523541          so.RealVectorParameter.Hidden = true;
    524542        }
    525         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     543        Operators.AddRange(shakingOperators.Except(Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()));
    526544        #endregion
    527545      } else {
     
    548566
    549567        #region Wire Permutation Crossovers
    550         Operators.RemoveAll(x => x is IPermutationCrossover && ((IPermutationCrossover)x).ChildParameter.ActualName != paramName);
    551         var crossovers = ApplicationManager.Manager.GetInstances<IPermutationCrossover>().ToList();
     568        var crossovers = Operators.OfType<IPermutationCrossover>()
     569          .Union(ApplicationManager.Manager.GetInstances<IPermutationCrossover>(), new TypeEqualityComparer<IPermutationCrossover>())
     570          .ToList();
    552571        foreach (var xo in crossovers) {
    553572          xo.ChildParameter.ActualName = permCreator.PermutationParameter.ActualName;
     
    556575          xo.ParentsParameter.Hidden = true;
    557576        }
    558         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     577        Operators.AddRange(crossovers.Except(Operators.OfType<IPermutationCrossover>()));
    559578        #endregion
    560579        #region Wire Permutation Manipulators
    561         Operators.RemoveAll(x => x is IPermutationManipulator && ((IPermutationManipulator)x).PermutationParameter.ActualName != paramName);
    562         var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList();
     580        var manipulators = Operators.OfType<IPermutationManipulator>()
     581          .Union(ApplicationManager.Manager.GetInstances<IPermutationManipulator>(), new TypeEqualityComparer<IPermutationManipulator>())
     582          .ToList();
    563583        foreach (var m in manipulators) {
    564584          m.PermutationParameter.ActualName = permCreator.PermutationParameter.ActualName;
    565585          m.PermutationParameter.Hidden = true;
    566586        }
    567         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    568         #endregion
    569         #region Wire ShakingOperators
    570         Operators.RemoveAll(x => x is IPermutationMultiNeighborhoodShakingOperator && ((IPermutationMultiNeighborhoodShakingOperator)x).PermutationParameter.ActualName != paramName);
    571         var shakingOperators = ApplicationManager.Manager.GetInstances<IPermutationMultiNeighborhoodShakingOperator>().ToList();
     587        Operators.AddRange(manipulators.Except(Operators.OfType<IPermutationManipulator>()));
     588        #endregion
     589        #region Wire Permutation ShakingOperators
     590        var shakingOperators = Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()
     591          .Union(ApplicationManager.Manager.GetInstances<IPermutationMultiNeighborhoodShakingOperator>(), new TypeEqualityComparer<IPermutationMultiNeighborhoodShakingOperator>())
     592          .ToList();
    572593        foreach (var op in shakingOperators) {
    573594          op.PermutationParameter.ActualName = paramName;
    574595          op.PermutationParameter.Hidden = true;
    575596        }
    576         Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     597        Operators.AddRange(shakingOperators.Except(Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>()));
    577598        #endregion
    578599      } else {
     
    584605    }
    585606
    586     protected virtual void UpdateMultiVectorEncodingOperators(List<ISolutionCreator> solutionCreators, Configuration configuration) {
    587       var oldCreator = SolutionCreator as ParameterVectorCreater;
    588       var newCreator = new ParameterVectorCreater();
    589 
    590       #region Configure BinaryVector Creator
    591       var newBinParams = new HashSet<string>(solutionCreators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
    592       if (oldCreator != null) {
    593         // we want to reuse the old creator
    594         var oldParams = new HashSet<string>(oldCreator.Operators.OfType<IBinaryVectorCreator>()
    595           .Select(x => x.BinaryVectorParameter.ActualName));
    596         foreach (var toAdd in newBinParams.Except(oldParams)) {
    597           var paramName = toAdd;
    598           oldCreator.Operators.Add(
    599             solutionCreators.OfType<IBinaryVectorCreator>().Single(x => x.BinaryVectorParameter.ActualName == paramName));
    600         }
    601         foreach (var toRemove in oldParams.Except(newBinParams)) {
    602           var paramName = toRemove;
    603           var op =
    604             oldCreator.Operators.OfType<IBinaryVectorCreator>()
    605               .SingleOrDefault(x => x.BinaryVectorParameter.ActualName == paramName);
     607    protected virtual void ConfigureMultiVectorEncodingOperators(MultiEncodingCreator newCreator, MultiEncoding encoding) {
     608      var newBinParams = new HashSet<string>(newCreator.Operators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
     609      var newIntParams = new HashSet<string>(newCreator.Operators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
     610      var newRealParams = new HashSet<string>(newCreator.Operators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
     611      var newPermParams = new HashSet<string>(newCreator.Operators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
     612
     613      var oldCreator = SolutionCreator as MultiEncodingCreator;
     614      if (oldCreator == null) SolutionCreator = newCreator;
     615      else {
     616        #region Configure BinaryVector Creator
     617        var oldBinParams = new HashSet<string>(oldCreator.Operators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
     618        foreach (var toAdd in newBinParams.Except(oldBinParams)) {
     619          oldCreator.Operators.Add(newCreator.Operators.OfType<IBinaryVectorCreator>().Single(x => x.BinaryVectorParameter.ActualName == toAdd));
     620        }
     621        foreach (var toRemove in oldBinParams.Except(newBinParams)) {
     622          var op = oldCreator.Operators.OfType<IBinaryVectorCreator>().SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
    606623          if (op != null) oldCreator.Operators.Remove(op);
    607624        }
    608       } else {
    609         // we will use the new creator
    610         foreach (var binCreator in solutionCreators.OfType<IBinaryVectorCreator>()) {
    611           newCreator.Operators.Add(binCreator);
    612         }
    613       }
    614       #endregion
    615       #region Configure IntegerVector Creator
    616       var newIntParams = new HashSet<string>(solutionCreators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
    617       if (oldCreator != null) {
    618         // we want to reuse the old creator
    619         var oldParams = new HashSet<string>(oldCreator
    620           .Operators.OfType<IIntegerVectorCreator>()
    621           .Select(x => x.IntegerVectorParameter.ActualName));
    622         foreach (var toAdd in newIntParams.Except(oldParams)) {
    623           var paramName = toAdd;
    624           oldCreator.Operators.Add(
    625             solutionCreators.OfType<IIntegerVectorCreator>().Single(x => x.IntegerVectorParameter.ActualName == paramName));
    626         }
    627         foreach (var toRemove in oldParams.Except(newIntParams)) {
    628           var paramName = toRemove;
    629           var op =
    630             oldCreator.Operators.OfType<IIntegerVectorCreator>()
    631               .SingleOrDefault(x => x.IntegerVectorParameter.ActualName == paramName);
     625        #endregion
     626
     627        #region Configure IntegerVector Creator
     628        var oldIntParams = new HashSet<string>(oldCreator.Operators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
     629        foreach (var toAdd in newIntParams.Except(oldIntParams)) {
     630          oldCreator.Operators.Add(newCreator.Operators.OfType<IIntegerVectorCreator>().Single(x => x.IntegerVectorParameter.ActualName == toAdd));
     631        }
     632        foreach (var toRemove in oldIntParams.Except(newIntParams)) {
     633          var op = oldCreator.Operators.OfType<IIntegerVectorCreator>().SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
    632634          if (op != null) oldCreator.Operators.Remove(op);
    633635        }
    634       } else {
    635         // we will use the new creator
    636         foreach (var intCreator in solutionCreators.OfType<IIntegerVectorCreator>()) {
    637           newCreator.Operators.Add(intCreator);
    638         }
    639       }
    640       #endregion
    641       #region Configure RealVector Creator
    642       var newRealParams = new HashSet<string>(solutionCreators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
    643       if (oldCreator != null) {
    644         // we want to reuse the old creator
    645         var oldParams = new HashSet<string>(oldCreator
    646           .Operators.OfType<IRealVectorCreator>()
    647           .Select(x => x.RealVectorParameter.ActualName));
    648         foreach (var toAdd in newRealParams.Except(oldParams)) {
    649           var paramName = toAdd;
    650           oldCreator.Operators.Add(
    651             solutionCreators.OfType<IRealVectorCreator>().Single(x => x.RealVectorParameter.ActualName == paramName));
    652         }
    653         foreach (var toRemove in oldParams.Except(newRealParams)) {
    654           var paramName = toRemove;
    655           var op =
    656             oldCreator.Operators.OfType<IRealVectorCreator>()
    657               .SingleOrDefault(x => x.RealVectorParameter.ActualName == paramName);
     636        #endregion
     637
     638        #region Configure RealVector Creator
     639        var oldRealParams = new HashSet<string>(oldCreator.Operators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
     640        foreach (var toAdd in newRealParams.Except(oldRealParams)) {
     641          oldCreator.Operators.Add(newCreator.Operators.OfType<IRealVectorCreator>().Single(x => x.RealVectorParameter.ActualName == toAdd));
     642        }
     643        foreach (var toRemove in oldRealParams.Except(newRealParams)) {
     644          var op = oldCreator.Operators.OfType<IRealVectorCreator>().SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
    658645          if (op != null) oldCreator.Operators.Remove(op);
    659646        }
    660       } else {
    661         // we will use the new creator
    662         foreach (var realCreator in solutionCreators.OfType<IRealVectorCreator>()) {
    663           newCreator.Operators.Add(realCreator);
    664         }
    665       }
    666       #endregion
    667       #region Configure Permutation Creator
    668       var newPermParams = new HashSet<string>(solutionCreators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
    669       if (oldCreator != null) {
    670         // we want to reuse the old creator
    671         var oldParams = new HashSet<string>(oldCreator
    672           .Operators.OfType<IPermutationCreator>()
    673           .Select(x => x.PermutationParameter.ActualName));
    674         foreach (var toAdd in newPermParams.Except(oldParams)) {
    675           var paramName = toAdd;
    676           oldCreator.Operators.Add(
    677             solutionCreators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == paramName));
    678         }
    679         foreach (var toRemove in oldParams.Except(newPermParams)) {
    680           var paramName = toRemove;
    681           var op =
    682             oldCreator.Operators.OfType<IPermutationCreator>()
    683               .SingleOrDefault(x => x.PermutationParameter.ActualName == paramName);
     647        #endregion
     648
     649        #region Configure Permutation Creator
     650        var oldPermParams = new HashSet<string>(oldCreator.Operators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
     651        foreach (var toAdd in newPermParams.Except(oldPermParams)) {
     652          oldCreator.Operators.Add(newCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == toAdd));
     653        }
     654        foreach (var toRemove in oldPermParams.Except(newPermParams)) {
     655          var op = oldCreator.Operators.OfType<IPermutationCreator>().SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
    684656          if (op != null) oldCreator.Operators.Remove(op);
    685657        }
    686658        // we also have to sync the permutation type (in case this changes, as it is a value parameter)
    687         foreach (var intersect in newPermParams.Intersect(oldParams)) {
    688           var paramName = intersect;
    689           var oldPermCreator = oldCreator.Operators.OfType<IPermutationCreator>()
    690             .Single(x => x.PermutationParameter.ActualName == paramName);
    691           var newPermCreator = solutionCreators.OfType<IPermutationCreator>()
    692             .Single(x => x.PermutationParameter.ActualName == paramName);
     659        foreach (var intersect in newPermParams.Intersect(oldPermParams)) {
     660          var oldPermCreator = oldCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == intersect);
     661          var newPermCreator = newCreator.Operators.OfType<IPermutationCreator>().Single(x => x.PermutationParameter.ActualName == intersect);
    693662          oldPermCreator.PermutationTypeParameter.Value = newPermCreator.PermutationTypeParameter.Value;
    694663        }
    695       } else {
    696         // we will use the new creator
    697         foreach (var permCreator in solutionCreators.OfType<IPermutationCreator>()) {
    698           newCreator.Operators.Add(permCreator);
    699         }
    700       }
    701       #endregion
    702 
    703       if (oldCreator == null) SolutionCreator = newCreator;
     664        #endregion
     665
     666      }
    704667
    705668      // crossover and manipulator for multi-vector encoding
    706669      // the condition checks if a multi-vector encoding is to be updated (there already exists ParameterVectorCrossover and ParameterVectorManipulator)
    707       if (Operators.OfType<ParameterVectorCrossover>().Any() && Operators.OfType<ParameterVectorManipulator>().Any()) {
     670      if (Operators.OfType<MultiEncodingCrossover>().Any() && Operators.OfType<MultiEncodingManipulator>().Any()) {
    708671        #region Update existing multi-vector encoding
    709672        #region Update ParameterVector Crossover ...
    710         foreach (var oldXo in Operators.OfType<ParameterVectorCrossover>()) {
     673        foreach (var oldXo in Operators.OfType<MultiEncodingCrossover>()) {
    711674          #region ... for binary parameters
    712           var oldBinParams = new HashSet<string>(oldXo.Operators.OfType<IBinaryVectorCrossover>()
    713             .Select(x => x.ChildParameter.ActualName));
     675          var oldBinParams = new HashSet<string>(oldXo.Operators.OfType<IBinaryVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    714676          foreach (var toAdd in newBinParams.Except(oldBinParams))
    715             oldXo.Operators.Add(GetDefaultBinaryCrossover(toAdd, configuration));
     677            oldXo.Operators.Add(GetDefaultBinaryCrossover(toAdd, encoding));
    716678          foreach (var toRemove in oldBinParams.Except(newBinParams)) {
    717             var op =
    718               oldXo.Operators.OfType<IBinaryVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     679            var op = oldXo.Operators.OfType<IBinaryVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    719680            if (op != null) oldXo.Operators.Remove(op);
    720681          }
    721682          #endregion
    722683          #region ... for integer parameters
    723           var oldIntParams = new HashSet<string>(oldXo.Operators.OfType<IIntegerVectorCrossover>()
    724             .Select(x => x.ChildParameter.ActualName));
     684          var oldIntParams = new HashSet<string>(oldXo.Operators.OfType<IIntegerVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    725685          foreach (var toAdd in newIntParams.Except(oldIntParams))
    726             oldXo.Operators.Add(GetDefaultIntegerCrossover(toAdd, configuration));
     686            oldXo.Operators.Add(GetDefaultIntegerCrossover(toAdd, encoding));
    727687          foreach (var toRemove in oldIntParams.Except(newIntParams)) {
    728             var op =
    729               oldXo.Operators.OfType<IIntegerVectorCrossover>()
    730                 .SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     688            var op = oldXo.Operators.OfType<IIntegerVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    731689            if (op != null) oldXo.Operators.Remove(op);
    732690          }
    733691          #endregion
    734692          #region ... for real parameters
    735           var oldRealParams = new HashSet<string>(oldXo.Operators.OfType<IRealVectorCrossover>()
    736             .Select(x => x.ChildParameter.ActualName));
     693          var oldRealParams = new HashSet<string>(oldXo.Operators.OfType<IRealVectorCrossover>().Select(x => x.ChildParameter.ActualName));
    737694          foreach (var toAdd in newRealParams.Except(oldRealParams))
    738             oldXo.Operators.Add(GetDefaultRealCrossover(toAdd, configuration));
     695            oldXo.Operators.Add(GetDefaultRealCrossover(toAdd, encoding));
    739696          foreach (var toRemove in oldRealParams.Except(newRealParams)) {
    740             var op =
    741               oldXo.Operators.OfType<IRealVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     697            var op = oldXo.Operators.OfType<IRealVectorCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    742698            if (op != null) oldXo.Operators.Remove(op);
    743699          }
    744700          #endregion
    745701          #region ... for permutation parameters
    746           var oldPermParams = new HashSet<string>(oldXo.Operators.OfType<IPermutationCrossover>()
    747             .Select(x => x.ChildParameter.ActualName));
     702          var oldPermParams = new HashSet<string>(oldXo.Operators.OfType<IPermutationCrossover>().Select(x => x.ChildParameter.ActualName));
    748703          foreach (var toAdd in newPermParams.Except(oldPermParams))
    749             oldXo.Operators.Add(GetDefaultPermutationCrossover(toAdd, configuration));
     704            oldXo.Operators.Add(GetDefaultPermutationCrossover(toAdd, encoding));
    750705          foreach (var toRemove in oldPermParams.Except(newPermParams)) {
    751             var op =
    752               oldXo.Operators.OfType<IPermutationCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
     706            var op = oldXo.Operators.OfType<IPermutationCrossover>().SingleOrDefault(x => x.ChildParameter.ActualName == toRemove);
    753707            if (op != null) oldXo.Operators.Remove(op);
    754708          }
     
    757711        #endregion
    758712        #region Update ParameterVector Manipulator ...
    759         foreach (var oldM in Operators.OfType<ParameterVectorManipulator>()) {
     713        foreach (var oldM in Operators.OfType<MultiEncodingManipulator>()) {
    760714          #region ... for binary parameters
    761           var oldBinParams = new HashSet<string>(oldM.Operators.OfType<IBinaryVectorManipulator>()
    762             .Select(x => x.BinaryVectorParameter.ActualName));
     715          var oldBinParams = new HashSet<string>(oldM.Operators.OfType<IBinaryVectorManipulator>().Select(x => x.BinaryVectorParameter.ActualName));
    763716          foreach (var toAdd in newBinParams.Except(oldBinParams))
    764             oldM.Operators.Add(GetDefaultBinaryManipulator(toAdd, configuration));
     717            oldM.Operators.Add(GetDefaultBinaryManipulator(toAdd, encoding));
    765718          foreach (var toRemove in oldBinParams.Except(newBinParams)) {
    766             var op =
    767               oldM.Operators.OfType<IBinaryVectorManipulator>()
    768                 .SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
     719            var op = oldM.Operators.OfType<IBinaryVectorManipulator>().SingleOrDefault(x => x.BinaryVectorParameter.ActualName == toRemove);
    769720            if (op != null) oldM.Operators.Remove(op);
    770721          }
    771722          #endregion
    772723          #region ... for integer parameters
    773           var oldIntParams = new HashSet<string>(oldM.Operators.OfType<IIntegerVectorManipulator>()
    774             .Select(x => x.IntegerVectorParameter.ActualName));
     724          var oldIntParams = new HashSet<string>(oldM.Operators.OfType<IIntegerVectorManipulator>().Select(x => x.IntegerVectorParameter.ActualName));
    775725          foreach (var toAdd in newIntParams.Except(oldIntParams))
    776             oldM.Operators.Add(GetDefaultIntegerManipulator(toAdd, configuration));
     726            oldM.Operators.Add(GetDefaultIntegerManipulator(toAdd, encoding));
    777727          foreach (var toRemove in oldIntParams.Except(newIntParams)) {
    778             var op =
    779               oldM.Operators.OfType<IIntegerVectorManipulator>()
    780                 .SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
     728            var op = oldM.Operators.OfType<IIntegerVectorManipulator>().SingleOrDefault(x => x.IntegerVectorParameter.ActualName == toRemove);
    781729            if (op != null) oldM.Operators.Remove(op);
    782730          }
    783731          #endregion
    784732          #region ... for real parameters
    785           var oldRealParams = new HashSet<string>(oldM.Operators.OfType<IRealVectorManipulator>()
    786             .Select(x => x.RealVectorParameter.ActualName));
     733          var oldRealParams = new HashSet<string>(oldM.Operators.OfType<IRealVectorManipulator>().Select(x => x.RealVectorParameter.ActualName));
    787734          foreach (var toAdd in newRealParams.Except(oldRealParams))
    788             oldM.Operators.Add(GetDefaultRealManipulator(toAdd, configuration));
     735            oldM.Operators.Add(GetDefaultRealManipulator(toAdd, encoding));
    789736          foreach (var toRemove in oldRealParams.Except(newRealParams)) {
    790             var op =
    791               oldM.Operators.OfType<IRealVectorManipulator>()
    792                 .SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
     737            var op = oldM.Operators.OfType<IRealVectorManipulator>().SingleOrDefault(x => x.RealVectorParameter.ActualName == toRemove);
    793738            if (op != null) oldM.Operators.Remove(op);
    794739          }
    795740          #endregion
    796741          #region ... for permutation parameters
    797           var oldPermParams = new HashSet<string>(oldM.Operators.OfType<IPermutationManipulator>()
    798             .Select(x => x.PermutationParameter.ActualName));
     742          var oldPermParams = new HashSet<string>(oldM.Operators.OfType<IPermutationManipulator>().Select(x => x.PermutationParameter.ActualName));
    799743          foreach (var toAdd in newPermParams.Except(oldPermParams))
    800             oldM.Operators.Add(GetDefaultPermutationManipulator(toAdd, configuration));
     744            oldM.Operators.Add(GetDefaultPermutationManipulator(toAdd, encoding));
    801745          foreach (var toRemove in oldPermParams.Except(newPermParams)) {
    802             var op =
    803               oldM.Operators.OfType<IPermutationManipulator>()
    804                 .SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
     746            var op = oldM.Operators.OfType<IPermutationManipulator>().SingleOrDefault(x => x.PermutationParameter.ActualName == toRemove);
    805747            if (op != null) oldM.Operators.Remove(op);
    806748          }
     
    819761        Operators.RemoveAll(x => x is IMultiNeighborhoodShakingOperator);
    820762
    821         var crossover = new ParameterVectorCrossover();
    822         var manipulator = new ParameterVectorManipulator();
    823         foreach (var param in configuration.Parameters) {
    824           if (param.Value is BinaryParameterConfiguration) {
    825             crossover.Operators.Add(GetDefaultBinaryCrossover(param.Key, configuration));
    826             manipulator.Operators.Add(GetDefaultBinaryManipulator(param.Key, configuration));
     763        var crossover = new MultiEncodingCrossover();
     764        var manipulator = new MultiEncodingManipulator();
     765        foreach (var enc in encoding.Encodings) {
     766          if (enc is BinaryEncoding) {
     767            crossover.Operators.Add(GetDefaultBinaryCrossover(enc.Name, encoding));
     768            manipulator.Operators.Add(GetDefaultBinaryManipulator(enc.Name, encoding));
    827769            continue;
    828770          }
    829           var intConfig = param.Value as IntegerParameterConfiguration;
     771          var intConfig = enc as IntegerEncoding;
    830772          if (intConfig != null) {
    831             crossover.Operators.Add(GetDefaultIntegerCrossover(param.Key, configuration));
    832             manipulator.Operators.Add(GetDefaultIntegerManipulator(param.Key, configuration));
     773            crossover.Operators.Add(GetDefaultIntegerCrossover(enc.Name, encoding));
     774            manipulator.Operators.Add(GetDefaultIntegerManipulator(enc.Name, encoding));
    833775            continue;
    834776          }
    835           var realConfig = param.Value as RealParameterConfiguration;
     777          var realConfig = enc as RealEncoding;
    836778          if (realConfig != null) {
    837             crossover.Operators.Add(GetDefaultRealCrossover(param.Key, configuration));
    838             manipulator.Operators.Add(GetDefaultRealManipulator(param.Key, configuration));
     779            crossover.Operators.Add(GetDefaultRealCrossover(enc.Name, encoding));
     780            manipulator.Operators.Add(GetDefaultRealManipulator(enc.Name, encoding));
    839781            continue;
    840782          }
    841           var permConfig = param.Value as PermutationParameterConfiguration;
     783          var permConfig = enc as PermutationEncoding;
    842784          if (permConfig != null) {
    843             crossover.Operators.Add(GetDefaultPermutationCrossover(param.Key, configuration));
    844             manipulator.Operators.Add(GetDefaultPermutationManipulator(param.Key, configuration));
     785            crossover.Operators.Add(GetDefaultPermutationCrossover(enc.Name, encoding));
     786            manipulator.Operators.Add(GetDefaultPermutationManipulator(enc.Name, encoding));
    845787            continue;
    846788          }
    847           throw new InvalidOperationException("Unknown type for parameter " + param.Key);
     789          throw new InvalidOperationException("Unknown type for parameter " + enc.Name);
    848790        }
    849791        Operators.Add(crossover);
     
    854796
    855797    protected virtual void UpdateImprovementOperators() {
    856       if (!Operators.Any(x => x is SingleObjectiveParameterVectorImprover))
    857         Operators.Add(new SingleObjectiveParameterVectorImprover());
    858       foreach (var improver in Operators.OfType<SingleObjectiveParameterVectorImprover>()) {
    859         improver.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     798      if (!Operators.Any(x => x is SingleObjectiveImprover))
     799        Operators.Add(new SingleObjectiveImprover());
     800      foreach (var improver in Operators.OfType<SingleObjectiveImprover>()) {
     801        improver.EncodingParameter.ActualName = EncodingParameter.Name;
    860802        improver.MaximizationParameter.ActualName = MaximizationParameter.Name;
    861803        improver.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
     
    865807
    866808    protected virtual void UpdateMoveOperators() {
    867       if (!Operators.Any(x => x is ParameterVectorMoveGenerator))
    868         Operators.Add(new ParameterVectorMoveGenerator());
    869       if (!Operators.Any(x => x is ParameterVectorMoveEvaluator))
    870         Operators.Add(new ParameterVectorMoveEvaluator());
    871       if (!Operators.Any(x => x is ParameterVectorMoveMaker))
    872         Operators.Add(new ParameterVectorMoveMaker());
    873 
    874       foreach (var generator in Operators.OfType<ParameterVectorMoveGenerator>()) {
    875         generator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     809      if (!Operators.Any(x => x is SingleObjectiveMoveGenerator))
     810        Operators.Add(new SingleObjectiveMoveGenerator());
     811      if (!Operators.Any(x => x is SingleObjectiveMoveEvaluator))
     812        Operators.Add(new SingleObjectiveMoveEvaluator());
     813      if (!Operators.Any(x => x is SingleObjectiveMoveMaker))
     814        Operators.Add(new SingleObjectiveMoveMaker());
     815
     816      foreach (var generator in Operators.OfType<SingleObjectiveMoveGenerator>()) {
     817        generator.EncodingParameter.ActualName = EncodingParameter.Name;
    876818        generator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    877819      }
    878       foreach (var evaluator in Operators.OfType<ParameterVectorMoveEvaluator>()) {
    879         evaluator.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     820      foreach (var evaluator in Operators.OfType<SingleObjectiveMoveEvaluator>()) {
     821        evaluator.EncodingParameter.ActualName = EncodingParameter.Name;
    880822        evaluator.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    881823        evaluator.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    882824      }
    883       foreach (var maker in Operators.OfType<ParameterVectorMoveMaker>()) {
    884         maker.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
    885         maker.MoveQualityParameter.ActualName = Operators.OfType<ParameterVectorMoveEvaluator>().First().MoveQualityParameter.ActualName;
     825      foreach (var maker in Operators.OfType<SingleObjectiveMoveMaker>()) {
     826        maker.EncodingParameter.ActualName = EncodingParameter.Name;
     827        maker.MoveQualityParameter.ActualName = Operators.OfType<SingleObjectiveMoveEvaluator>().First().MoveQualityParameter.ActualName;
    886828        maker.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    887829      }
     
    890832    #region GetDefaultOperators for Crossovers and Manipulators
    891833    // ReSharper disable RedundantNameQualifier
    892     protected virtual IBinaryVectorCrossover GetDefaultBinaryCrossover(string paramName, Configuration config) {
    893       var binConfig = (BinaryParameterConfiguration)config.Parameters[paramName];
     834    protected virtual IBinaryVectorCrossover GetDefaultBinaryCrossover(string paramName, MultiEncoding config) {
     835      var binConfig = (BinaryEncoding)config.Encodings[paramName];
    894836      IBinaryVectorCrossover binXo;
    895837      if (binConfig.Length.Value > 3) binXo = new Encodings.BinaryVectorEncoding.SinglePointCrossover();
     
    900842    }
    901843
    902     protected virtual IBinaryVectorManipulator GetDefaultBinaryManipulator(string paramName, Configuration config) {
     844    protected virtual IBinaryVectorManipulator GetDefaultBinaryManipulator(string paramName, MultiEncoding config) {
    903845      var binM = new Encodings.BinaryVectorEncoding.SomePositionsBitflipManipulator();
    904846      binM.BinaryVectorParameter.ActualName = paramName;
     
    907849    }
    908850
    909     protected virtual IIntegerVectorCrossover GetDefaultIntegerCrossover(string paramName, Configuration config) {
     851    protected virtual IIntegerVectorCrossover GetDefaultIntegerCrossover(string paramName, MultiEncoding config) {
    910852      var intXo = new Encodings.IntegerVectorEncoding.RoundedBlendAlphaBetaCrossover();
    911853      intXo.ChildParameter.ActualName = paramName;
     
    917859    }
    918860
    919     protected virtual IIntegerVectorManipulator GetDefaultIntegerManipulator(string paramName, Configuration configuration) {
     861    protected virtual IIntegerVectorManipulator GetDefaultIntegerManipulator(string paramName, MultiEncoding configuration) {
    920862      var intM = new Encodings.IntegerVectorEncoding.UniformSomePositionsManipulator();
    921863      intM.IntegerVectorParameter.ActualName = paramName;
     
    925867    }
    926868
    927     protected virtual IRealVectorCrossover GetDefaultRealCrossover(string paramName, Configuration configuration) {
     869    protected virtual IRealVectorCrossover GetDefaultRealCrossover(string paramName, MultiEncoding configuration) {
    928870      var realXo = new Encodings.RealVectorEncoding.BlendAlphaBetaCrossover();
    929871      realXo.ChildParameter.ActualName = paramName;
     
    935877    }
    936878
    937     protected virtual IRealVectorManipulator GetDefaultRealManipulator(string paramName, Configuration configuration) {
     879    protected virtual IRealVectorManipulator GetDefaultRealManipulator(string paramName, MultiEncoding configuration) {
    938880      var realM = new Encodings.RealVectorEncoding.BreederGeneticAlgorithmManipulator();
    939881      realM.RealVectorParameter.ActualName = paramName;
     
    942884    }
    943885
    944     protected virtual IPermutationCrossover GetDefaultPermutationCrossover(string paramName, Configuration configuration) {
     886    protected virtual IPermutationCrossover GetDefaultPermutationCrossover(string paramName, MultiEncoding configuration) {
    945887      var permXo = new Encodings.PermutationEncoding.PartiallyMatchedCrossover();
    946888      permXo.ChildParameter.ActualName = paramName;
     
    949891    }
    950892
    951     protected virtual IPermutationManipulator GetDefaultPermutationManipulator(string paramName, Configuration configuration) {
     893    protected virtual IPermutationManipulator GetDefaultPermutationManipulator(string paramName, MultiEncoding configuration) {
    952894      var permM = new Encodings.PermutationEncoding.Swap2Manipulator();
    953895      permM.PermutationParameter.ActualName = paramName;
Note: See TracChangeset for help on using the changeset viewer.