Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/12/10 14:36:13 (15 years ago)
Author:
svonolfe
Message:

Added operations for the Alba encoding (#1039)

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  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Optimization;
    2728
    2829namespace 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.")]
    3031  [StorableClass]
    31   public sealed class AlbaManipulator : VRPManipulator {
    32     public IValueLookupParameter<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"]; }
    3435    }
    3536
    3637    [StorableConstructor]
    37     private AlbaManipulator(bool deserializing) : base(deserializing) { }
     38    protected AlbaManipulator(bool deserializing) : base(deserializing) { }
    3839
    3940    public AlbaManipulator()
    4041      : 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."));
    4243
    4344        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;
    4459    }
    4560
     
    4964        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
    5065      }
    51      
    52       OperationCollection next = new OperationCollection(base.Apply());
    5366
    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);
    5968
    60       return next;
     69      return base.Apply();
    6170    }
    6271  }
Note: See TracChangeset for help on using the changeset viewer.