Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11398 for branches


Ignore:
Timestamp:
09/28/14 12:39:33 (10 years ago)
Author:
abeham
Message:

#2174:

  • Structured code into regions
  • Added shaking operators for the different encodings
  • Added particle and swarm operators for realvectors
  • Fixed bug in view
Location:
branches/ProgrammableProblem
Files:
2 edited

Legend:

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

    r11397 r11398  
    6767      this.toolTip.SetToolTip(this.compileButton, "Compile (F6)");
    6868      //
    69       // imageList
    70       //
    71       this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
    72       this.imageList.Images.SetKeyName(0, "");
    73       this.imageList.Images.SetKeyName(1, "");
    74       //
    7569      // infoTabControl
    7670      //
     
    113107      // splitContainer2
    114108      //
    115       this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    116             | System.Windows.Forms.AnchorStyles.Left) 
     109      this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     110            | System.Windows.Forms.AnchorStyles.Left)
    117111            | System.Windows.Forms.AnchorStyles.Right)));
    118112      this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r11396 r11398  
    165165
    166166      if (solutionCreators.Count == 1) {
     167        Operators.RemoveAll(x => x is ParameterVectorCrossover
     168                              || x is ParameterVectorManipulator);
    167169        UpdateSingleVectorEncodingOperators(solutionCreators, configuration);
    168170      } else {
     
    179181      var solutionCreators = new List<ISolutionCreator>();
    180182      foreach (var param in configuration.Parameters) {
    181         /*
    182          * Binary Vectors
    183          */
     183        #region Configure BinaryVector Creator
    184184        var binConfig = param.Value as BinaryParameterConfiguration;
    185185        if (binConfig != null) {
     
    192192          solutionCreators.Add(creator);
    193193        }
    194         /*
    195          * Integer Vectors
    196          */
     194        #endregion
     195        #region Configure IntegerVector Creator
    197196        var intConfig = param.Value as IntegerParameterConfiguration;
    198197        if (intConfig != null) {
     
    208207          solutionCreators.Add(creator);
    209208        }
    210         /*
    211          * Real Vectors
    212          */
     209        #endregion
     210        #region Configure RealVector Creator
    213211        var realConfig = param.Value as RealParameterConfiguration;
    214212        if (realConfig != null) {
     
    224222          solutionCreators.Add(creator);
    225223        }
    226         /*
    227          * Permutations
    228          */
     224        #endregion
     225        #region Configure Permutation Creator
    229226        var permConfig = param.Value as PermutationParameterConfiguration;
    230227        if (permConfig != null) {
     
    238235          solutionCreators.Add(creator);
    239236        }
     237        #endregion
    240238      }
    241239
     
    249247    protected virtual void UpdateSingleVectorEncodingOperators(List<ISolutionCreator> solutionCreators, Configuration configuration) {
    250248      var newCreator = solutionCreators.Single();
     249      #region Configure Operators for BinaryVectorEncoding
    251250      var binCreator = newCreator as IBinaryVectorCreator;
    252251      if (binCreator != null) {
     
    258257          Operators.Add(SolutionCreator);
    259258        }
    260         Operators.RemoveAll(x => x is ICrossover && !(x is IBinaryVectorCrossover) || x is IBinaryVectorCrossover && ((IBinaryVectorCrossover)x).ChildParameter.ActualName != paramName);
    261         Operators.RemoveAll(x => x is IManipulator && !(x is IBinaryVectorManipulator) || x is IBinaryVectorManipulator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
     259
     260        #region Wire BinaryVector Crossovers
     261        Operators.RemoveAll(x => x is IBinaryVectorCrossover && ((IBinaryVectorCrossover)x).ChildParameter.ActualName != paramName);
    262262        var crossovers = ApplicationManager.Manager.GetInstances<IBinaryVectorCrossover>().ToList();
    263         var manipulators = ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>().ToList();
    264263        foreach (var xo in crossovers) {
    265264          xo.ChildParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
     265          xo.ChildParameter.Hidden = true;
    266266          xo.ParentsParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
    267         }
    268         foreach (var m in manipulators)
     267          xo.ParentsParameter.Hidden = true;
     268        }
     269        Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     270        #endregion
     271        #region Wire BinaryVector Manipulators
     272        Operators.RemoveAll(x => x is IBinaryVectorManipulator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
     273        var manipulators = ApplicationManager.Manager.GetInstances<IBinaryVectorManipulator>().ToList();
     274        foreach (var m in manipulators) {
    269275          m.BinaryVectorParameter.ActualName = binCreator.BinaryVectorParameter.ActualName;
    270         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     276          m.BinaryVectorParameter.Hidden = true;
     277        }
    271278        Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    272       }
     279        #endregion
     280        #region Wire BinaryVector ShakingOperators
     281        Operators.RemoveAll(x => x is IBinaryVectorMultiNeighborhoodShakingOperator && ((IBinaryVectorManipulator)x).BinaryVectorParameter.ActualName != paramName);
     282        var shakingOperators = ApplicationManager.Manager.GetInstances<IBinaryVectorMultiNeighborhoodShakingOperator>().ToList();
     283        foreach (var so in shakingOperators) {
     284          so.BinaryVectorParameter.ActualName = paramName;
     285          so.BinaryVectorParameter.Hidden = true;
     286        }
     287        Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     288        #endregion
     289      } else {
     290        Operators.RemoveAll(x => x is IBinaryVectorCrossover
     291          || x is IBinaryVectorManipulator
     292          || x is IBinaryVectorMultiNeighborhoodShakingOperator);
     293      }
     294      #endregion
     295      #region Configure Operators for IntegerVectorEncoding
    273296      var intCreator = newCreator as IIntegerVectorCreator;
    274297      if (intCreator != null) {
     
    281304          Operators.Add(SolutionCreator);
    282305        }
    283         Operators.RemoveAll(x => x is ICrossover && !(x is IIntegerVectorCrossover) || x is IIntegerVectorCrossover && ((IIntegerVectorCrossover)x).ChildParameter.ActualName != paramName);
    284         Operators.RemoveAll(x => x is IManipulator && !(x is IIntegerVectorManipulator) || x is IIntegerVectorManipulator && ((IIntegerVectorManipulator)x).IntegerVectorParameter.ActualName != paramName);
     306
     307        #region Wire IntegerVector Crossovers
     308        Operators.RemoveAll(x => x is IIntegerVectorCrossover && ((IIntegerVectorCrossover)x).ChildParameter.ActualName != paramName);
     309        var crossovers = ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>().ToList();
     310        foreach (var xo in crossovers) {
     311          xo.ChildParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     312          xo.ChildParameter.Hidden = true;
     313          xo.ParentsParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     314          xo.ParentsParameter.Hidden = true;
     315          var bx = xo as IBoundedIntegerVectorOperator;
     316          if (bx != null) {
     317            bx.BoundsParameter.ActualName = intCreator.BoundsParameter.ActualName;
     318            bx.BoundsParameter.Hidden = true;
     319          }
     320        }
     321        Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     322        #endregion
     323        #region Wire IntegerVector Manipulators
     324        Operators.RemoveAll(x => x is IIntegerVectorManipulator && ((IIntegerVectorManipulator)x).IntegerVectorParameter.ActualName != paramName);
     325        var manipulators = ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>().ToList();
     326        foreach (var m in manipulators) {
     327          m.IntegerVectorParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
     328          m.IntegerVectorParameter.Hidden = true;
     329          var sm = m as ISelfAdaptiveManipulator;
     330          if (sm != null) {
     331            var p = sm.StrategyParameterParameter as ILookupParameter;
     332            if (p != null) {
     333              p.ActualName = paramName + "Strategy";
     334              p.Hidden = true;
     335            }
     336          }
     337          var bm = m as IBoundedIntegerVectorOperator;
     338          if (bm != null) {
     339            bm.BoundsParameter.ActualName = intCreator.BoundsParameter.ActualName;
     340            bm.BoundsParameter.Hidden = true;
     341          }
     342        }
     343        Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     344        #region Wire IntegerVector StrategyParameters for SelfAdaptiveManipulators
    285345        Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IIntegerVectorStdDevStrategyParameterCreator) || x is IIntegerVectorStdDevStrategyParameterCreator && ((IIntegerVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    286346        Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IIntegerVectorStdDevStrategyParameterManipulator) || x is IIntegerVectorStdDevStrategyParameterManipulator && ((IIntegerVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    287347        Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IIntegerVectorStdDevStrategyParameterCrossover) || x is IIntegerVectorStdDevStrategyParameterCrossover && ((IIntegerVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    288         var crossovers = ApplicationManager.Manager.GetInstances<IIntegerVectorCrossover>().ToList();
    289         var manipulators = ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>().ToList();
    290348        var strategyOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorStdDevStrategyParameterOperator>().ToList();
    291         foreach (var xo in crossovers) {
    292           xo.ChildParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
    293           xo.ParentsParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
    294         }
    295         foreach (var m in manipulators) {
    296           m.IntegerVectorParameter.ActualName = intCreator.IntegerVectorParameter.ActualName;
    297           var sm = m as ISelfAdaptiveManipulator;
    298           if (sm != null) {
    299             var p = sm.StrategyParameterParameter as ILookupParameter;
    300             if (p != null) p.ActualName = paramName + "Strategy";
    301           }
    302         }
    303         foreach (var bo in crossovers.OfType<IBoundedIntegerVectorOperator>()
    304               .Concat(manipulators.OfType<IBoundedIntegerVectorOperator>())
    305               .ToList()) {
    306           bo.BoundsParameter.ActualName = intCreator.BoundsParameter.ActualName;
    307         }
    308349        if (!(configuration.Parameters.First().Value is IntegerParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with integervector creator that is not an integer-coded problem.");
    309350        var problemSize = ((IntegerParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
     
    338379          }
    339380        }
    340         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    341         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    342381        Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    343       }
     382        #endregion
     383        #endregion
     384        #region Wire IntegerVector ShakingOperators
     385        Operators.RemoveAll(x => x is IIntegerVectorMultiNeighborhoodShakingOperator && ((IIntegerVectorMultiNeighborhoodShakingOperator)x).IntegerVectorParameter.ActualName != paramName);
     386        var shakingOperators = ApplicationManager.Manager.GetInstances<IIntegerVectorMultiNeighborhoodShakingOperator>().ToList();
     387        foreach (var so in shakingOperators) {
     388          so.IntegerVectorParameter.ActualName = paramName;
     389          so.IntegerVectorParameter.Hidden = true;
     390        }
     391        Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     392        #endregion
     393      } else {
     394        Operators.RemoveAll(x => x is IIntegerVectorCrossover
     395          || x is IIntegerVectorManipulator
     396          || x is IIntegerVectorStdDevStrategyParameterOperator
     397          || x is IIntegerVectorMultiNeighborhoodShakingOperator);
     398      }
     399      #endregion
     400      #region Configure Operators for RealVectorEncoding
    344401      var realCreator = newCreator as IRealVectorCreator;
    345402      if (realCreator != null) {
     
    352409          Operators.Add(SolutionCreator);
    353410        }
    354         Operators.RemoveAll(x => x is ICrossover && !(x is IRealVectorCrossover) || x is IRealVectorCrossover && ((IRealVectorCrossover)x).ChildParameter.ActualName != paramName);
    355         Operators.RemoveAll(x => x is IManipulator && !(x is IRealVectorManipulator) || x is IRealVectorManipulator && ((IRealVectorManipulator)x).RealVectorParameter.ActualName != paramName);
     411
     412        #region Wire RealVector Crossovers
     413        Operators.RemoveAll(x => x is IRealVectorCrossover && ((IRealVectorCrossover)x).ChildParameter.ActualName != paramName);
     414        var crossovers = ApplicationManager.Manager.GetInstances<IRealVectorCrossover>().ToList();
     415        foreach (var xo in crossovers) {
     416          xo.ChildParameter.ActualName = paramName;
     417          xo.ChildParameter.Hidden = true;
     418          xo.ParentsParameter.ActualName = paramName;
     419          xo.ParentsParameter.Hidden = true;
     420          xo.BoundsParameter.ActualName = realCreator.BoundsParameter.ActualName;
     421          xo.BoundsParameter.Hidden = true;
     422        }
     423        Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     424        #endregion
     425        #region Wire RealVector Manipulators
     426        Operators.RemoveAll(x => x is IRealVectorManipulator && ((IRealVectorManipulator)x).RealVectorParameter.ActualName != paramName);
     427        var manipulators = ApplicationManager.Manager.GetInstances<IRealVectorManipulator>().ToList();
     428        foreach (var m in manipulators) {
     429          m.RealVectorParameter.ActualName = paramName;
     430          m.RealVectorParameter.Hidden = true;
     431          m.BoundsParameter.ActualName = realCreator.BoundsParameter.ActualName;
     432          m.BoundsParameter.Hidden = true;
     433          var sm = m as ISelfAdaptiveManipulator;
     434          if (sm != null) {
     435            var p = sm.StrategyParameterParameter as ILookupParameter;
     436            if (p != null) {
     437              p.ActualName = paramName + "Strategy";
     438              p.Hidden = true;
     439            }
     440          }
     441        }
     442        Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     443        #region Wire RealVector Strategy Parameters for SelfAdaptiveManipulators
     444
    356445        Operators.RemoveAll(x => x is IStrategyParameterCreator && !(x is IRealVectorStdDevStrategyParameterCreator) || x is IRealVectorStdDevStrategyParameterCreator && ((IRealVectorStdDevStrategyParameterCreator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    357446        Operators.RemoveAll(x => x is IStrategyParameterManipulator && !(x is IRealVectorStdDevStrategyParameterManipulator) || x is IRealVectorStdDevStrategyParameterManipulator && ((IRealVectorStdDevStrategyParameterManipulator)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    358447        Operators.RemoveAll(x => x is IStrategyParameterCrossover && !(x is IRealVectorStdDevStrategyParameterCrossover) || x is IRealVectorStdDevStrategyParameterCrossover && ((IRealVectorStdDevStrategyParameterCrossover)x).StrategyParameterParameter.ActualName != paramName + "Strategy");
    359         var crossovers = ApplicationManager.Manager.GetInstances<IRealVectorCrossover>().ToList();
    360         var manipulators = ApplicationManager.Manager.GetInstances<IRealVectorManipulator>().ToList();
    361448        var strategyOperators = ApplicationManager.Manager.GetInstances<IRealVectorStdDevStrategyParameterOperator>().ToList();
    362         foreach (var xo in crossovers) {
    363           xo.ChildParameter.ActualName = paramName;
    364           xo.ParentsParameter.ActualName = paramName;
    365           xo.BoundsParameter.ActualName = realCreator.BoundsParameter.ActualName;
    366         }
    367         foreach (var m in manipulators) {
    368           m.RealVectorParameter.ActualName = paramName;
    369           m.BoundsParameter.ActualName = realCreator.BoundsParameter.ActualName;
    370           var sm = m as ISelfAdaptiveManipulator;
    371           if (sm != null) {
    372             var p = sm.StrategyParameterParameter as ILookupParameter;
    373             if (p != null) p.ActualName = paramName + "Strategy";
    374           }
    375         }
    376449        if (!(configuration.Parameters.First().Value is RealParameterConfiguration)) throw new InvalidOperationException("Single-encoded problem with realvector creator that is not a real-coded problem.");
    377450        var problemSize = ((RealParameterConfiguration)configuration.Parameters.First().Value).Length.Value;
     
    404477          }
    405478        }
    406         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    407         Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    408479        Operators.AddRange(strategyOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    409       }
     480        #endregion
     481        #endregion
     482        #region Wire RealVector ParticleCreators
     483        Operators.RemoveAll(x => x is IRealVectorParticleCreator && ((IRealVectorParticleCreator)x).RealVectorParameter.ActualName != paramName);
     484        var particleCreators = ApplicationManager.Manager.GetInstances<IRealVectorParticleCreator>().ToList();
     485        foreach (var pc in particleCreators) {
     486          pc.RealVectorParameter.ActualName = paramName;
     487          pc.RealVectorParameter.Hidden = true;
     488          pc.BoundsParameter.ActualName = realCreator.BoundsParameter.Name;
     489          pc.BoundsParameter.Hidden = true;
     490          pc.ProblemSizeParameter.ActualName = paramName + "Length";
     491          pc.ProblemSizeParameter.Hidden = true;
     492        }
     493        Operators.AddRange(particleCreators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     494        #endregion
     495        #region Wire RealVector ParticleUpdaters
     496        Operators.RemoveAll(x => x is IRealVectorParticleUpdater && ((IRealVectorParticleUpdater)x).RealVectorParameter.ActualName != paramName);
     497        var particleUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorParticleUpdater>().ToList();
     498        foreach (var pu in particleUpdaters) {
     499          pu.RealVectorParameter.ActualName = paramName;
     500          pu.RealVectorParameter.Hidden = true;
     501          pu.BoundsParameter.ActualName = realCreator.BoundsParameter.Name;
     502          pu.BoundsParameter.Hidden = true;
     503        }
     504        Operators.AddRange(particleUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     505        #endregion
     506        #region Wire RealVector SwarmUpdaters
     507        Operators.RemoveAll(x => x is IRealVectorSwarmUpdater && ((IRealVectorSwarmUpdater)x).RealVectorParameter.ActualName != paramName);
     508        var swarmUpdaters = ApplicationManager.Manager.GetInstances<IRealVectorSwarmUpdater>().ToList();
     509        foreach (var su in swarmUpdaters) {
     510          su.RealVectorParameter.ActualName = paramName;
     511          su.RealVectorParameter.Hidden = true;
     512          su.MaximizationParameter.ActualName = MaximizationParameter.Name;
     513          su.MaximizationParameter.Hidden = true;
     514        }
     515        Operators.AddRange(swarmUpdaters.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     516        #endregion
     517        #region Wire RealVector ShakingOperators
     518        Operators.RemoveAll(x => x is IRealVectorMultiNeighborhoodShakingOperator && ((IRealVectorMultiNeighborhoodShakingOperator)x).RealVectorParameter.ActualName != paramName);
     519        var shakingOperators = ApplicationManager.Manager.GetInstances<IRealVectorMultiNeighborhoodShakingOperator>().ToList();
     520        foreach (var so in shakingOperators) {
     521          so.RealVectorParameter.ActualName = paramName;
     522          so.RealVectorParameter.Hidden = true;
     523        }
     524        Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     525        #endregion
     526      } else {
     527        Operators.RemoveAll(x => x is IRealVectorCrossover
     528          || x is IRealVectorManipulator
     529          || x is IRealVectorStdDevStrategyParameterOperator
     530          || x is IRealVectorParticleCreator
     531          || x is IRealVectorParticleUpdater
     532          || x is IRealVectorSwarmUpdater
     533          || x is IRealVectorMultiNeighborhoodShakingOperator);
     534      }
     535      #endregion
     536      #region Configure Operators for PermutationEncoding
    410537      var permCreator = newCreator as IPermutationCreator;
    411538      if (permCreator != null) {
     
    418545          Operators.Add(SolutionCreator);
    419546        }
    420         Operators.RemoveAll(x => x is ICrossover && !(x is IPermutationCrossover) || x is IPermutationCrossover && ((IPermutationCrossover)x).ChildParameter.ActualName != paramName);
    421         Operators.RemoveAll(x => x is IManipulator && !(x is IPermutationManipulator) || x is IPermutationManipulator && ((IPermutationManipulator)x).PermutationParameter.ActualName != paramName);
     547
     548        #region Wire Permutation Crossovers
     549        Operators.RemoveAll(x => x is IPermutationCrossover && ((IPermutationCrossover)x).ChildParameter.ActualName != paramName);
    422550        var crossovers = ApplicationManager.Manager.GetInstances<IPermutationCrossover>().ToList();
    423         var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList();
    424551        foreach (var xo in crossovers) {
    425552          xo.ChildParameter.ActualName = permCreator.PermutationParameter.ActualName;
     553          xo.ChildParameter.Hidden = true;
    426554          xo.ParentsParameter.ActualName = permCreator.PermutationParameter.ActualName;
    427         }
    428         foreach (var m in manipulators)
     555          xo.ParentsParameter.Hidden = true;
     556        }
     557        Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     558        #endregion
     559        #region Wire Permutation Manipulators
     560        Operators.RemoveAll(x => x is IPermutationManipulator && ((IPermutationManipulator)x).PermutationParameter.ActualName != paramName);
     561        var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList();
     562        foreach (var m in manipulators) {
    429563          m.PermutationParameter.ActualName = permCreator.PermutationParameter.ActualName;
    430         Operators.AddRange(crossovers.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     564          m.PermutationParameter.Hidden = true;
     565        }
    431566        Operators.AddRange(manipulators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
    432       }
     567        #endregion
     568        #region Wire ShakingOperators
     569        Operators.RemoveAll(x => x is IPermutationMultiNeighborhoodShakingOperator && ((IPermutationMultiNeighborhoodShakingOperator)x).PermutationParameter.ActualName != paramName);
     570        var shakingOperators = ApplicationManager.Manager.GetInstances<IPermutationMultiNeighborhoodShakingOperator>().ToList();
     571        foreach (var op in shakingOperators) {
     572          op.PermutationParameter.ActualName = paramName;
     573          op.PermutationParameter.Hidden = true;
     574        }
     575        Operators.AddRange(shakingOperators.Where(x => Operators.All(y => x.GetType() != y.GetType())));
     576        #endregion
     577      } else {
     578        Operators.RemoveAll(x => x is IPermutationCrossover
     579          || x is IPermutationManipulator
     580          || x is IPermutationMultiNeighborhoodShakingOperator);
     581      }
     582      #endregion
    433583    }
    434584
     
    437587      var newCreator = new ParameterVectorCreater();
    438588
    439       /*
    440        * Binary Vectors
    441        */
     589      #region Configure BinaryVector Creator
    442590      var newBinParams = new HashSet<string>(solutionCreators.OfType<IBinaryVectorCreator>().Select(x => x.BinaryVectorParameter.ActualName));
    443591      if (oldCreator != null) {
     
    463611        }
    464612      }
    465 
    466       /*
    467        * Integer Vectors
    468        */
     613      #endregion
     614      #region Configure IntegerVector Creator
    469615      var newIntParams = new HashSet<string>(solutionCreators.OfType<IIntegerVectorCreator>().Select(x => x.IntegerVectorParameter.ActualName));
    470616      if (oldCreator != null) {
     
    491637        }
    492638      }
    493 
    494       /*
    495        * Real Vectors
    496        */
     639      #endregion
     640      #region Configure RealVector Creator
    497641      var newRealParams = new HashSet<string>(solutionCreators.OfType<IRealVectorCreator>().Select(x => x.RealVectorParameter.ActualName));
    498642      if (oldCreator != null) {
     
    519663        }
    520664      }
    521 
    522       /*
    523        * Permutations
    524        */
     665      #endregion
     666      #region Configure Permutation Creator
    525667      var newPermParams = new HashSet<string>(solutionCreators.OfType<IPermutationCreator>().Select(x => x.PermutationParameter.ActualName));
    526668      if (oldCreator != null) {
     
    556698        }
    557699      }
     700      #endregion
    558701
    559702      if (oldCreator == null) SolutionCreator = newCreator;
     
    562705      // the condition checks if a multi-vector encoding is to be updated (there already exists ParameterVectorCrossover and ParameterVectorManipulator)
    563706      if (Operators.OfType<ParameterVectorCrossover>().Any() && Operators.OfType<ParameterVectorManipulator>().Any()) {
    564         // Update the crossovers
     707        #region Update existing multi-vector encoding
     708        #region Update ParameterVector Crossover ...
    565709        foreach (var oldXo in Operators.OfType<ParameterVectorCrossover>()) {
    566           /*
    567            * Binary Vectors
    568            */
     710          #region ... for binary parameters
    569711          var oldBinParams = new HashSet<string>(oldXo.Operators.OfType<IBinaryVectorCrossover>()
    570712            .Select(x => x.ChildParameter.ActualName));
     
    576718            if (op != null) oldXo.Operators.Remove(op);
    577719          }
    578 
    579           /*
    580            * Integer Vectors
    581            */
     720          #endregion
     721          #region ... for integer parameters
    582722          var oldIntParams = new HashSet<string>(oldXo.Operators.OfType<IIntegerVectorCrossover>()
    583723            .Select(x => x.ChildParameter.ActualName));
     
    590730            if (op != null) oldXo.Operators.Remove(op);
    591731          }
    592 
    593           /*
    594            * Real Vectors
    595            */
     732          #endregion
     733          #region ... for real parameters
    596734          var oldRealParams = new HashSet<string>(oldXo.Operators.OfType<IRealVectorCrossover>()
    597735            .Select(x => x.ChildParameter.ActualName));
     
    603741            if (op != null) oldXo.Operators.Remove(op);
    604742          }
    605 
    606           /*
    607            * Permutations
    608            */
     743          #endregion
     744          #region ... for permutation parameters
    609745          var oldPermParams = new HashSet<string>(oldXo.Operators.OfType<IPermutationCrossover>()
    610746            .Select(x => x.ChildParameter.ActualName));
     
    616752            if (op != null) oldXo.Operators.Remove(op);
    617753          }
    618         }
    619         // Update the manipulators
     754          #endregion
     755        }
     756        #endregion
     757        #region Update ParameterVector Manipulator ...
    620758        foreach (var oldM in Operators.OfType<ParameterVectorManipulator>()) {
    621           /*
    622            * Binary Vectors
    623            */
     759          #region ... for binary parameters
    624760          var oldBinParams = new HashSet<string>(oldM.Operators.OfType<IBinaryVectorManipulator>()
    625761            .Select(x => x.BinaryVectorParameter.ActualName));
     
    632768            if (op != null) oldM.Operators.Remove(op);
    633769          }
    634 
    635           /*
    636            * Integer Vectors
    637            */
     770          #endregion
     771          #region ... for integer parameters
    638772          var oldIntParams = new HashSet<string>(oldM.Operators.OfType<IIntegerVectorManipulator>()
    639773            .Select(x => x.IntegerVectorParameter.ActualName));
     
    646780            if (op != null) oldM.Operators.Remove(op);
    647781          }
    648 
    649           /*
    650            * Real Vectors
    651            */
     782          #endregion
     783          #region ... for real parameters
    652784          var oldRealParams = new HashSet<string>(oldM.Operators.OfType<IRealVectorManipulator>()
    653785            .Select(x => x.RealVectorParameter.ActualName));
     
    660792            if (op != null) oldM.Operators.Remove(op);
    661793          }
    662 
    663           /*
    664            * Permutations
    665            */
     794          #endregion
     795          #region ... for permutation parameters
    666796          var oldPermParams = new HashSet<string>(oldM.Operators.OfType<IPermutationManipulator>()
    667797            .Select(x => x.PermutationParameter.ActualName));
     
    674804            if (op != null) oldM.Operators.Remove(op);
    675805          }
    676         }
     806          #endregion
     807        }
     808        #endregion
     809        #endregion
    677810      } else {
    678         // change from single-vector encoding to multi-vector encoding
     811        #region Handle transition from single-vector to multi-vector encoding
    679812        Operators.RemoveAll(x => x is ICrossover);
    680813        Operators.RemoveAll(x => x is IManipulator);
     814        Operators.RemoveAll(x => x is IStrategyParameterCreator || x is IStrategyParameterManipulator || x is IStrategyParameterCrossover);
     815        Operators.RemoveAll(x => x is IParticleCreator);
     816        Operators.RemoveAll(x => x is IParticleUpdater);
     817        Operators.RemoveAll(x => x is ISwarmUpdater);
     818        Operators.RemoveAll(x => x is IMultiNeighborhoodShakingOperator);
     819
    681820        var crossover = new ParameterVectorCrossover();
    682821        var manipulator = new ParameterVectorManipulator();
     
    709848        Operators.Add(crossover);
    710849        Operators.Add(manipulator);
     850        #endregion
    711851      }
    712852    }
     
    731871    }
    732872
     873    #region GetDefaultOperators for Crossovers and Manipulators
    733874    // ReSharper disable RedundantNameQualifier
    734875    protected virtual IBinaryVectorCrossover GetDefaultBinaryCrossover(string paramName, Configuration config) {
     
    797938    }
    798939    // ReSharper restore RedundantNameQualifier
     940    #endregion
    799941  }
    800942}
Note: See TracChangeset for help on using the changeset viewer.