Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/10 18:08:14 (14 years ago)
Author:
svonolfe
Message:

Refactored VRP based on the code review (#1039)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs

    r4177 r4179  
    154154        cities);
    155155    }
     156
     157    internal static void RemoveUnusedParameters(ParameterCollection parameters) {
     158      parameters.Remove("DistanceMatrix");
     159      parameters.Remove("UseDistanceMatrix");
     160      parameters.Remove("Capacity");
     161      parameters.Remove("Demand");
     162      parameters.Remove("ReadyTime");
     163      parameters.Remove("DueTime");
     164      parameters.Remove("ServiceTime");
     165    }
    156166  }
    157167}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs

    r4177 r4179  
    3030  [StorableClass]
    3131  public sealed class AlbaCrossover : VRPCrossover {   
    32     public IValueLookupParameter<IPermutationCrossover> PermutationCrossoverParameter {
    33       get { return (IValueLookupParameter<IPermutationCrossover>)Parameters["PermutationCrossover"]; }
     32    public IValueLookupParameter<IPermutationCrossover> InnerCrossoverParameter {
     33      get { return (IValueLookupParameter<IPermutationCrossover>)Parameters["InnerCrossover"]; }
    3434    }
     35
     36    [StorableConstructor]
     37    private AlbaCrossover(bool deserializing) : base(deserializing) { }
    3538
    3639    public AlbaCrossover()
    3740      : base() {
    38       Parameters.Add(new ValueLookupParameter<IPermutationCrossover>("PermutationCrossover", "The permutation crossover.", new EdgeRecombinationCrossover()));
     41      Parameters.Add(new ValueLookupParameter<IPermutationCrossover>("InnerCrossover", "The permutation crossover.", new EdgeRecombinationCrossover()));
     42   
     43      AlbaEncoding.RemoveUnusedParameters(Parameters);
    3944    }
    4045
    41     void Crossover() {
    42       PermutationCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
     46    private void Crossover() {
     47      //note - the inner crossover is called here and the result is converted to an alba representation
     48      //some refactoring should be done here in the future - the crossover operation should be called directly
     49
     50      InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
    4351      IAtomicOperation op = this.ExecutionContext.CreateOperation(
    44         PermutationCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
     52        InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope);
    4553      op.Operator.Execute((IExecutionContext)op);
    4654
    47       string childName = PermutationCrossoverParameter.ActualValue.ChildParameter.ActualName;
     55      string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;
    4856      if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {
    4957        Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r4177 r4179  
    2929  [Item("AlbaManipulator", "An operator which manipulates an alba VRP representation.")]
    3030  [StorableClass]
    31   public sealed class AlbaManipulator : VRPManipulator {   
    32     public IValueLookupParameter<IPermutationManipulator> PermutationManipulatorParameter {
    33       get { return (IValueLookupParameter<IPermutationManipulator>)Parameters["PermutationManipulator"]; }
     31  public sealed class AlbaManipulator : VRPManipulator {
     32    public IValueLookupParameter<IPermutationManipulator> InnerManipulatorParameter {
     33      get { return (IValueLookupParameter<IPermutationManipulator>)Parameters["InnerManipulator"]; }
    3434    }
     35
     36    [StorableConstructor]
     37    private AlbaManipulator(bool deserializing) : base(deserializing) { }
    3538
    3639    public AlbaManipulator()
    3740      : base() {
    38       Parameters.Add(new ValueLookupParameter<IPermutationManipulator>("PermutationManipulator", "The permutation manipulator.", new TranslocationManipulator()));
     41        Parameters.Add(new ValueLookupParameter<IPermutationManipulator>("InnerManipulator", "The permutation manipulator.", new TranslocationManipulator()));
     42
     43        AlbaEncoding.RemoveUnusedParameters(Parameters);
    3944    }
    4045
    4146    public override IOperation Apply() {
    42       IVRPEncoding solution = VRPSolutionParameter.ActualValue;
     47      IVRPEncoding solution = VRPToursParameter.ActualValue;
    4348      if (!(solution is AlbaEncoding)) {
    44         VRPSolutionParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     49        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
    4550      }
    4651     
    4752      OperationCollection next = new OperationCollection(base.Apply());
    4853
    49       IPermutationManipulator op = PermutationManipulatorParameter.ActualValue;
     54      IPermutationManipulator op = InnerManipulatorParameter.ActualValue;
    5055      if (op != null) {
    51         op.PermutationParameter.ActualName = VRPSolutionParameter.ActualName;
     56        op.PermutationParameter.ActualName = VRPToursParameter.ActualName;
    5257        next.Insert(0, ExecutionContext.CreateOperation(op));
    5358      }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveMaker.cs

    r4177 r4179  
    6161    }
    6262   
     63    [StorableConstructor]
     64    protected AlbaMoveMaker(bool deserializing) : base(deserializing) { }
    6365
    6466    public AlbaMoveMaker()
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs

    r4177 r4179  
    3333    protected abstract IPermutationMoveOperator PermutationMoveOperatorParameter { get; set; }
    3434
     35    [StorableConstructor]
     36    protected AlbaMoveOperator(bool deserializing) : base(deserializing) { }
     37
     38    public AlbaMoveOperator() : base()
     39    {
     40      AlbaEncoding.RemoveUnusedParameters(Parameters);
     41    }
     42
    3543    public override IOperation Apply() {
    36       IVRPEncoding solution = VRPSolutionParameter.ActualValue;
     44      IVRPEncoding solution = VRPToursParameter.ActualValue;
    3745      if (!(solution is AlbaEncoding)) {
    38         VRPSolutionParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     46        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
    3947      }
    4048
    41       PermutationMoveOperatorParameter.PermutationParameter.ActualName = VRPSolutionParameter.ActualName;
     49      PermutationMoveOperatorParameter.PermutationParameter.ActualName = VRPToursParameter.ActualName;
    4250      IAtomicOperation op = this.ExecutionContext.CreateChildOperation(PermutationMoveOperatorParameter);
    4351      op.Operator.Execute((IExecutionContext)op);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveEvaluator.cs

    r4177 r4179  
    3535    }
    3636
     37    [StorableConstructor]
     38    private AlbaTranslocationMoveEvaluator(bool deserializing) : base(deserializing) { }
     39
    3740    public AlbaTranslocationMoveEvaluator()
    3841      : base() {
     
    4346      TranslocationMove move = TranslocationMoveParameter.ActualValue;
    4447      //perform move
    45       AlbaEncoding newSolution = VRPSolutionParameter.ActualValue.Clone() as AlbaEncoding;
     48      AlbaEncoding newSolution = VRPToursParameter.ActualValue.Clone() as AlbaEncoding;
    4649      TranslocationManipulator.Apply(newSolution, move.Index1, move.Index2, move.Index3);
    4750
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs

    r4177 r4179  
    6868    }
    6969
     70    [StorableConstructor]
     71    private AlbaTranslocationMoveGenerator(bool deserializing) : base(deserializing) { }
     72
    7073    public AlbaTranslocationMoveGenerator()
    7174      : base() {
     
    8083      IOperation successor = base.Apply();
    8184
    82       Permutation permutation = VRPSolutionParameter.ActualValue as Permutation;
     85      Permutation permutation = VRPToursParameter.ActualValue as Permutation;
    8386      string moveName = TranslocationMoveGeneratorParameter.ActualValue.TranslocationMoveParameter.Name;
    8487
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveHardTabuCriterion.cs

    r4177 r4179  
    5656    }
    5757
     58    [StorableConstructor]
     59    private AlbaTranslocationMoveHardTabuCriterion(bool deserializing) : base(deserializing) { }
     60
    5861    public AlbaTranslocationMoveHardTabuCriterion()
    5962      : base() {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveMaker.cs

    r4177 r4179  
    5252    }
    5353
     54    [StorableConstructor]
     55    private AlbaTranslocationMoveMaker(bool deserializing) : base(deserializing) { }
     56
    5457    public AlbaTranslocationMoveMaker()
    5558      : base() {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveSoftTabuCriterion.cs

    r4177 r4179  
    5656    }
    5757
     58    [StorableConstructor]
     59    private AlbaTranslocationMoveSoftTabuCriterion(bool deserializing) : base(deserializing) { }
     60
    5861    public AlbaTranslocationMoveSoftTabuCriterion()
    5962      : base() {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveTabuMaker.cs

    r4177 r4179  
    5656    }
    5757
     58    [StorableConstructor]
     59    private AlbaTranslocationMoveTabuMaker(bool deserializing) : base(deserializing) { }
     60
    5861    public AlbaTranslocationMoveTabuMaker()
    5962      : base() {
Note: See TracChangeset for help on using the changeset viewer.