Changeset 15504 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators
- Timestamp:
- 12/10/17 22:11:10 (7 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/DemandEquivalentSwapEquipmentManipluator.cs
r7813 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Encodings.IntegerVectorEncoding; 29 using HeuristicLab.Parameters;30 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 30 using HeuristicLab.Random; … … 35 34 [Item("DemandEquivalentSwapEquipmentManipluator", "Swaps equipment X from location A with as much equipments from location B that the demand of X is less than or equal to the demand of the swapped equipments in B.")] 36 35 [StorableClass] 37 public class DemandEquivalentSwapEquipmentManipluator : GQAPManipulator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator { 38 39 public ILookupParameter<DoubleArray> DemandsParameter { 40 get { return (ILookupParameter<DoubleArray>)Parameters["Demands"]; } 41 } 42 public ILookupParameter<DoubleArray> CapacitiesParameter { 43 get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; } 44 } 36 public class DemandEquivalentSwapEquipmentManipluator : GQAPManipulator { 45 37 46 38 [StorableConstructor] … … 49 41 public DemandEquivalentSwapEquipmentManipluator() 50 42 : base() { 51 Parameters.Add(new LookupParameter<DoubleArray>("Demands", GeneralizedQuadraticAssignmentProblem.DemandsDescription));52 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));53 43 } 54 44 … … 85 75 } 86 76 87 protected override void Manipulate(IRandom random, IntegerVector vector ) {88 Apply(random, vector, CapacitiesParameter.ActualValue, DemandsParameter.ActualValue);77 protected override void Manipulate(IRandom random, IntegerVector vector, GQAPInstance problemInstance) { 78 Apply(random, vector, problemInstance.Capacities, problemInstance.Demands); 89 79 } 90 80 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/GQAPManipulator.cs
r7523 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 [Item("GQAPManipulator", "A base class for operators that manipulate assignment vectors of the GeneralizedQuadraticAssignment problems.")] 32 32 [StorableClass] 33 public abstract class GQAPManipulator : SingleSuccessorOperator, IGQAPManipulator, I AssignmentAwareGQAPOperator, IStochasticOperator {33 public abstract class GQAPManipulator : SingleSuccessorOperator, IGQAPManipulator, IProblemInstanceAwareGQAPOperator, IStochasticOperator { 34 34 public override bool CanChangeName { 35 35 get { return false; } … … 39 39 get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; } 40 40 } 41 public ILookupParameter<GQAPInstance> ProblemInstanceParameter { 42 get { return (ILookupParameter<GQAPInstance>)Parameters["ProblemInstance"]; } 43 } 44 41 45 public ILookupParameter<IRandom> RandomParameter { 42 46 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 49 53 : base() { 50 54 Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription)); 55 Parameters.Add(new LookupParameter<GQAPInstance>("ProblemInstance", GQAP.ProblemInstanceDescription)); 51 56 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 52 57 } 53 58 54 59 public sealed override IOperation Apply() { 55 Manipulate(RandomParameter.ActualValue, AssignmentParameter.ActualValue );60 Manipulate(RandomParameter.ActualValue, AssignmentParameter.ActualValue, ProblemInstanceParameter.ActualValue); 56 61 return base.Apply(); 57 62 } 58 63 59 protected abstract void Manipulate(IRandom random, IntegerVector integerVector );64 protected abstract void Manipulate(IRandom random, IntegerVector integerVector, GQAPInstance problemInstance); 60 65 } 61 66 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/MultiGQAPManipulator.cs
r11505 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 35 35 [Item("MultiGQAPManipulator", "Randomly selects and applies one of its manipulators every time it is called.")] 36 36 [StorableClass] 37 public class MultiGQAPManipulator : StochasticMultiBranch<IGQAPManipulator>, IGQAPManipulator { 37 public class MultiGQAPManipulator : StochasticMultiBranch<IGQAPManipulator>, IGQAPManipulator, 38 IProblemInstanceAwareGQAPOperator { 38 39 public override bool CanChangeName { 39 40 get { return false; } … … 46 47 get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; } 47 48 } 49 public ILookupParameter<GQAPInstance> ProblemInstanceParameter { 50 get { return (ILookupParameter<GQAPInstance>)Parameters["ProblemInstance"]; } 51 } 48 52 49 53 [StorableConstructor] … … 53 57 : base() { 54 58 Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription)); 59 Parameters.Add(new LookupParameter<GQAPInstance>("ProblemInstance", GQAP.ProblemInstanceDescription)); 60 55 61 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IGQAPManipulator))) { 56 62 if (!typeof(MultiOperator<IGQAPManipulator>).IsAssignableFrom(type)) … … 73 79 74 80 private void Parameterize() { 75 foreach (var op in Operators.OfType<IGQAPManipulator>()) 81 foreach (var op in Operators.OfType<IGQAPManipulator>()) { 76 82 op.AssignmentParameter.ActualName = AssignmentParameter.Name; 77 foreach (var op in Operators.OfType<IStochasticOperator>()) 83 op.AssignmentParameter.Hidden = true; 84 } 85 foreach (var op in Operators.OfType<IStochasticOperator>()) { 78 86 op.RandomParameter.ActualName = RandomParameter.Name; 87 op.RandomParameter.Hidden = true; 88 } 89 foreach (var op in Operators.OfType<IProblemInstanceAwareGQAPOperator>()) { 90 op.ProblemInstanceParameter.ActualName = ProblemInstanceParameter.Name; 91 op.ProblemInstanceParameter.Hidden = true; 92 } 79 93 } 80 94 81 95 public override IOperation InstrumentedApply() { 82 96 if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one manipulator to choose from."); 83 return base. Apply();97 return base.InstrumentedApply(); 84 98 } 85 99 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/RelocateEquipmentManipluator.cs
r7813 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Encodings.IntegerVectorEncoding; 29 using HeuristicLab.Parameters;30 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 30 using HeuristicLab.Random; … … 35 34 [Item("RelocateEquipmentManipluator", "Relocates a random equipment from an overstuffed location to a random one with space or a random equipment if constraints are satisfied.")] 36 35 [StorableClass] 37 public class RelocateEquipmentManipluator : GQAPManipulator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator { 38 39 public ILookupParameter<DoubleArray> CapacitiesParameter { 40 get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; } 41 } 42 public ILookupParameter<DoubleArray> DemandsParameter { 43 get { return (ILookupParameter<DoubleArray>)Parameters["Demands"]; } 44 } 45 36 public class RelocateEquipmentManipluator : GQAPManipulator { 37 46 38 [StorableConstructor] 47 39 protected RelocateEquipmentManipluator(bool deserializing) : base(deserializing) { } … … 49 41 public RelocateEquipmentManipluator() 50 42 : base() { 51 Parameters.Add(new LookupParameter<DoubleArray>("Demands", GeneralizedQuadraticAssignmentProblem.DemandsDescription));52 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));53 43 } 54 44 … … 92 82 } 93 83 94 protected override void Manipulate(IRandom random, IntegerVector vector ) {95 Apply(random, vector, CapacitiesParameter.ActualValue, DemandsParameter.ActualValue);84 protected override void Manipulate(IRandom random, IntegerVector vector, GQAPInstance problemInstance) { 85 Apply(random, vector, problemInstance.Capacities, problemInstance.Demands); 96 86 } 97 87 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/SwapEquipmentManipluator.cs
r7523 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 56 56 } 57 57 58 protected override void Manipulate(IRandom random, IntegerVector vector ) {58 protected override void Manipulate(IRandom random, IntegerVector vector, GQAPInstance problemInstance) { 59 59 Apply(random, vector); 60 60 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/SwapLocationManipulator.cs
r7523 r15504 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 26 using HeuristicLab.Encodings.IntegerVectorEncoding; 28 using HeuristicLab.Parameters;29 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 28 … … 33 31 [Item("SwapLocationManipluator", "Swaps two locations by exchanging all equipments between the locations.")] 34 32 [StorableClass] 35 public class SwapLocationManipluator : GQAPManipulator, ICapacitiesAwareGQAPOperator { 36 37 public ILookupParameter<DoubleArray> CapacitiesParameter { 38 get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; } 39 } 40 33 public class SwapLocationManipluator : GQAPManipulator { 34 41 35 [StorableConstructor] 42 36 protected SwapLocationManipluator(bool deserializing) : base(deserializing) { } … … 44 38 public SwapLocationManipluator() 45 39 : base() { 46 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));47 40 } 48 41 … … 72 65 } 73 66 74 protected override void Manipulate(IRandom random, IntegerVector vector ) {75 Apply(random, vector, CapacitiesParameter.ActualValue.Length);67 protected override void Manipulate(IRandom random, IntegerVector vector, GQAPInstance problemInstance) { 68 Apply(random, vector, problemInstance.Capacities.Length); 76 69 } 77 70 }
Note: See TracChangeset
for help on using the changeset viewer.