Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/24/20 00:58:42 (4 years ago)
Author:
abeham
Message:

#2521: working on VRP (WIP)

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuCrossover.cs

    r17226 r17698  
    4848    }
    4949
    50     protected abstract ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2);
     50    protected abstract ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2);
    5151
    5252    public override IOperation InstrumentedApply() {
    53       ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
     53      ItemArray<IVRPEncodedSolution> parents = new ItemArray<IVRPEncodedSolution>(ParentsParameter.ActualValue.Length);
    5454      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
    55         IVRPEncoding solution = ParentsParameter.ActualValue[i];
     55        IVRPEncodedSolution solution = ParentsParameter.ActualValue[i];
    5656
    57         if (!(solution is ZhuEncoding)) {
    58           parents[i] = ZhuEncoding.ConvertFrom(solution, ProblemInstance);
     57        if (!(solution is ZhuEncodedSolution)) {
     58          parents[i] = ZhuEncodedSolution.ConvertFrom(solution, ProblemInstance);
    5959        } else {
    6060          parents[i] = solution;
     
    6464
    6565      ChildParameter.ActualValue =
    66         Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncoding, parents[1] as ZhuEncoding);
     66        Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncodedSolution, parents[1] as ZhuEncodedSolution);
    6767
    6868      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover1.cs

    r17226 r17698  
    4343    }
    4444
    45     private void Swap(ZhuEncoding individual, int city1, int city2) {
     45    private void Swap(ZhuEncodedSolution individual, int city1, int city2) {
    4646      int index1 = individual.IndexOf(city1);
    4747      int index2 = individual.IndexOf(city2);
     
    5252    }
    5353
    54     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
    55       parent1 = parent1.Clone() as ZhuEncoding;
    56       parent2 = parent2.Clone() as ZhuEncoding;
     54    protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) {
     55      parent1 = parent1.Clone() as ZhuEncodedSolution;
     56      parent2 = parent2.Clone() as ZhuEncodedSolution;
    5757
    58       ZhuEncoding child = parent2.Clone() as ZhuEncoding;
     58      ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution;
    5959
    6060      if (parent1.Length != parent2.Length)
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover2.cs

    r17226 r17698  
    4444    }
    4545
    46     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
     46    protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) {
    4747      List<int> p1 = new List<int>(parent1);
    4848      List<int> p2 = new List<int>(parent2);
    4949
    50       ZhuEncoding child = parent2.Clone() as ZhuEncoding;
     50      ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution;
    5151
    5252      if (parent1.Length != parent2.Length)
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs

    r17226 r17698  
    4545    }
    4646
    47     private void Swap(ZhuEncoding individual, int city1, int city2) {
     47    private void Swap(ZhuEncodedSolution individual, int city1, int city2) {
    4848      int index1 = individual.IndexOf(city1);
    4949      int index2 = individual.IndexOf(city2);
     
    5454    }
    5555
    56     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
    57       parent1 = parent1.Clone() as ZhuEncoding;
    58       parent2 = parent2.Clone() as ZhuEncoding;
     56    protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) {
     57      parent1 = parent1.Clone() as ZhuEncodedSolution;
     58      parent2 = parent2.Clone() as ZhuEncodedSolution;
    5959
    60       ZhuEncoding child = parent2.Clone() as ZhuEncoding;
     60      ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution;
    6161
    6262      if (parent1.Length != parent2.Length)
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs

    r17226 r17698  
    4646    }
    4747
    48     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
     48    protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) {
    4949      List<int> p1 = new List<int>(parent1);
    5050      List<int> p2 = new List<int>(parent2);
    5151
    52       ZhuEncoding child = parent2.Clone() as ZhuEncoding;
     52      ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution;
    5353
    5454      if (parent1.Length != parent2.Length)
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs

    r17226 r17698  
    5050    }
    5151
    52     protected override ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2) {
     52    protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) {
    5353      //note - the inner crossover is called here and the result is converted to a prins representation
    5454      //some refactoring should be done here in the future - the crossover operation should be called directly
    5555      if (parent1.Length != parent2.Length)
    56         return parent1.Clone() as ZhuEncoding;
     56        return parent1.Clone() as ZhuEncodedSolution;
    5757
    5858      InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
     
    6666        ExecutionContext.Scope.Variables.Remove(childName);
    6767
    68         return new ZhuEncoding(permutation, ProblemInstance);
     68        return new ZhuEncodedSolution(permutation, ProblemInstance);
    6969      } else
    7070        return null;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuManipulator.cs

    r17226 r17698  
    4848    }
    4949
    50     protected abstract void Manipulate(IRandom random, ZhuEncoding individual);
     50    protected abstract void Manipulate(IRandom random, ZhuEncodedSolution individual);
    5151
    5252    public override IOperation InstrumentedApply() {
    53       IVRPEncoding solution = VRPToursParameter.ActualValue;
    54       if (!(solution is ZhuEncoding)) {
    55         VRPToursParameter.ActualValue = ZhuEncoding.ConvertFrom(solution, ProblemInstance);
     53      IVRPEncodedSolution solution = VRPToursParameter.ActualValue;
     54      if (!(solution is ZhuEncodedSolution)) {
     55        VRPToursParameter.ActualValue = ZhuEncodedSolution.ConvertFrom(solution, ProblemInstance);
    5656      }
    5757
    58       Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncoding);
     58      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncodedSolution);
    5959
    6060      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuPermutationManipulator.cs

    r17226 r17698  
    5050    }
    5151
    52     protected override void Manipulate(IRandom random, ZhuEncoding individual) {
     52    protected override void Manipulate(IRandom random, ZhuEncodedSolution individual) {
    5353      InnerManipulatorParameter.ActualValue.PermutationParameter.ActualName = VRPToursParameter.ActualName;
    5454
Note: See TracChangeset for help on using the changeset viewer.