[10102] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Linq;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
| 27 | using HeuristicLab.Operators;
|
---|
| 28 | using HeuristicLab.Optimization;
|
---|
| 29 | using HeuristicLab.Parameters;
|
---|
| 30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 31 | using HeuristicLab.PluginInfrastructure;
|
---|
| 32 |
|
---|
| 33 | namespace HeuristicLab.Analysis.SolutionCaching.PermutationEncoding {
|
---|
| 34 | [Item("PermutationMutationPointcut", "Wraps a mutator and applies after-mutation actions.")]
|
---|
| 35 | [StorableClass]
|
---|
| 36 | public class PermutationMutationPointcut : MutationPointcut<IPermutationAdvice, IPermutationManipulator>, IPermutationManipulator, IPermutationPointcut {
|
---|
| 37 | public ILookupParameter<Permutation> PermutationParameter {
|
---|
| 38 | get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | [StorableConstructor]
|
---|
| 42 | protected PermutationMutationPointcut(bool deserializing) : base(deserializing) { }
|
---|
| 43 | protected PermutationMutationPointcut(PermutationMutationPointcut original, Cloner cloner) : base(original, cloner) { }
|
---|
| 44 |
|
---|
| 45 | public PermutationMutationPointcut()
|
---|
| 46 | : base() {
|
---|
| 47 | Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is being manipulated."));
|
---|
| 48 |
|
---|
| 49 | foreach (Type t in ApplicationManager.Manager.GetTypes(typeof(IPermutationManipulator))) {
|
---|
| 50 | if ((!typeof(PermutationMutationPointcut).IsAssignableFrom(t)) &&
|
---|
| 51 | (!typeof(MultiOperator<IPermutationManipulator>).IsAssignableFrom(t))) {
|
---|
| 52 | MutatorsParameter.ValidValues.Add((IPermutationManipulator)Activator.CreateInstance(t));
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | ParameterizeManipulators();
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 60 | return new PermutationMutationPointcut(this, cloner);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | private void ParameterizeManipulators() {
|
---|
| 64 | foreach (IPermutationManipulator manipulator in MutatorsParameter.ValidValues.OfType<IPermutationManipulator>()) {
|
---|
| 65 | manipulator.PermutationParameter.ActualName = PermutationParameter.Name;
|
---|
| 66 | }
|
---|
| 67 | foreach (IStochasticOperator op in MutatorsParameter.ValidValues.OfType<IStochasticOperator>()) {
|
---|
| 68 | op.RandomParameter.ActualName = RandomParameter.Name;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | }
|
---|