Changeset 4204 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators
- Timestamp:
- 08/12/10 14:36:13 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators
- Files:
-
- 6 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs
r4179 r4204 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Optimization; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 29 [Item("AlbaManipulator", "An operator which manipulates an alba VRP representation.")]30 [Item("AlbaManipulator", "An operator which manipulates an Alba VRP representation.")] 30 31 [StorableClass] 31 public sealed class AlbaManipulator : VRPManipulator {32 public I ValueLookupParameter<IPermutationManipulator> InnerManipulatorParameter {33 get { return ( IValueLookupParameter<IPermutationManipulator>)Parameters["InnerManipulator"]; }32 public abstract class AlbaManipulator : VRPManipulator, IStochasticOperator { 33 public ILookupParameter<IRandom> RandomParameter { 34 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 34 35 } 35 36 36 37 [StorableConstructor] 37 pr ivateAlbaManipulator(bool deserializing) : base(deserializing) { }38 protected AlbaManipulator(bool deserializing) : base(deserializing) { } 38 39 39 40 public AlbaManipulator() 40 41 : base() { 41 Parameters.Add(new ValueLookupParameter<IPermutationManipulator>("InnerManipulator", "The permutation manipulator.", new TranslocationManipulator()));42 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 42 43 43 44 AlbaEncoding.RemoveUnusedParameters(Parameters); 45 } 46 47 protected abstract void Manipulate(IRandom random, AlbaEncoding individual); 48 49 protected int FindCustomerLocation(int customer, AlbaEncoding individual) { 50 int pos = -1; 51 for (int i = 0; i < individual.Length; i++) { 52 if (individual[i] == customer) { 53 pos = i; 54 break; 55 } 56 } 57 58 return pos; 44 59 } 45 60 … … 49 64 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); 50 65 } 51 52 OperationCollection next = new OperationCollection(base.Apply());53 66 54 IPermutationManipulator op = InnerManipulatorParameter.ActualValue; 55 if (op != null) { 56 op.PermutationParameter.ActualName = VRPToursParameter.ActualName; 57 next.Insert(0, ExecutionContext.CreateOperation(op)); 58 } 67 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as AlbaEncoding); 59 68 60 return next;69 return base.Apply(); 61 70 } 62 71 }
Note: See TracChangeset
for help on using the changeset viewer.