Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 14:48:13 (11 years ago)
Author:
pfleck
Message:
  • merged trunk
Location:
branches/DataPreprocessing
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting

  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/AlbaCreator.cs

    r9456 r10538  
    4545    }
    4646
    47     public override IOperation Apply() {
     47    public override IOperation InstrumentedApply() {
    4848      (VRPToursParameter.ActualValue as AlbaEncoding).Repair();
    4949
    50       return base.Apply();
     50      return base.InstrumentedApply();
    5151    }
    5252  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs

    r9456 r10538  
    8686    }
    8787
    88     public override IOperation Apply() {
     88    public override IOperation InstrumentedApply() {
    8989      //choose default encoding here
    9090      VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution(), ProblemInstance);
    9191
    92       return base.Apply();
     92      return base.InstrumentedApply();
    9393    }
    9494  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Crossovers/AlbaCrossover.cs

    r9456 r10538  
    5252    protected abstract AlbaEncoding Crossover(IRandom random, AlbaEncoding parent1, AlbaEncoding parent2);
    5353
    54     public override IOperation Apply() {
     54    public override IOperation InstrumentedApply() {
    5555      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    5656      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
     
    6969      (ChildParameter.ActualValue as AlbaEncoding).Repair();
    7070
    71       return base.Apply();
     71      return base.InstrumentedApply();
    7272    }
    7373  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs

    r9462 r10538  
    125125    }
    126126
    127     public override IOperation Apply() {
     127    public override IOperation InstrumentedApply() {
    128128      int maxIterations = MaximumIterationsParameter.ActualValue.Value;
    129129      AlbaEncoding solution = null;
     
    146146      QualityParameter.ActualValue.Value = quality;
    147147
    148       return base.Apply();
     148      return base.InstrumentedApply();
    149149    }
    150150  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r9456 r10538  
    6262    }
    6363
    64     public override IOperation Apply() {
     64    public override IOperation InstrumentedApply() {
    6565      IVRPEncoding solution = VRPToursParameter.ActualValue;
    6666      if (!(solution is AlbaEncoding)) {
     
    7171      (VRPToursParameter.ActualValue as AlbaEncoding).Repair();
    7272
    73       return base.Apply();
     73      return base.InstrumentedApply();
    7474    }
    7575  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/AlbaMoveGenerator.cs

    r9456 r10538  
    4141    }
    4242
    43     public override IOperation Apply() {
     43    public override IOperation InstrumentedApply() {
    4444      IVRPEncoding solution = VRPToursParameter.ActualValue;
    4545      if (!(solution is AlbaEncoding)) {
     
    4747      }
    4848
    49       return base.Apply();
     49      return base.InstrumentedApply();
    5050    }
    5151  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveGenerator.cs

    r9456 r10538  
    5858    protected abstract AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance);
    5959
    60     public override IOperation Apply() {
    61       IOperation next = base.Apply();
     60    public override IOperation InstrumentedApply() {
     61      IOperation next = base.InstrumentedApply();
    6262
    6363      AlbaEncoding individual = VRPToursParameter.ActualValue as AlbaEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveGenerator.cs

    r9456 r10538  
    6868    protected abstract AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance, int lambda);
    6969
    70     public override IOperation Apply() {
    71       IOperation next = base.Apply();
     70    public override IOperation InstrumentedApply() {
     71      IOperation next = base.InstrumentedApply();
    7272
    7373      AlbaEncoding individual = VRPToursParameter.ActualValue as AlbaEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaStochasticTranslocationSingleMoveGenerator.cs

    r9456 r10538  
    6969    }
    7070
    71     public override IOperation Apply() {
    72       IOperation next = base.Apply();
     71    public override IOperation InstrumentedApply() {
     72      IOperation next = base.InstrumentedApply();
    7373
    7474      IVRPEncoding solution = VRPToursParameter.ActualValue;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs

    r9456 r10538  
    9393    }
    9494
    95     public override IOperation Apply() {
    96       IOperation next = base.Apply();
     95    public override IOperation InstrumentedApply() {
     96      IOperation next = base.InstrumentedApply();
    9797
    9898      IVRPEncoding solution = VRPToursParameter.ActualValue;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveHardTabuCriterion.cs

    r9456 r10538  
    8181    }
    8282
    83     public override IOperation Apply() {
    84       IOperation next = base.Apply();
     83    public override IOperation InstrumentedApply() {
     84      IOperation next = base.InstrumentedApply();
    8585
    8686      IVRPEncoding solution = VRPToursParameter.ActualValue;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveSoftTabuCriterion.cs

    r9456 r10538  
    8181    }
    8282
    83     public override IOperation Apply() {
    84       IOperation next = base.Apply();
     83    public override IOperation InstrumentedApply() {
     84      IOperation next = base.InstrumentedApply();
    8585
    8686      IVRPEncoding solution = VRPToursParameter.ActualValue;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveTabuMaker.cs

    r9456 r10538  
    8181    }
    8282
    83     public override IOperation Apply() {
    84       IOperation next = base.Apply();
     83    public override IOperation InstrumentedApply() {
     84      IOperation next = base.InstrumentedApply();
    8585
    8686      IVRPEncoding solution = VRPToursParameter.ActualValue;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/GVR/Crossovers/GVRCrossover.cs

    r9456 r10538  
    103103    }
    104104
    105     public override IOperation Apply() {
     105    public override IOperation InstrumentedApply() {
    106106      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    107107      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
     
    117117      ChildParameter.ActualValue = Crossover(RandomParameter.ActualValue, parents[0] as GVREncoding, parents[1] as GVREncoding);
    118118
    119       return base.Apply();
     119      return base.InstrumentedApply();
    120120    }
    121121  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/GVR/Manipulators/GVRManipulator.cs

    r9456 r10538  
    4949    protected abstract void Manipulate(IRandom random, GVREncoding individual);
    5050
    51     public override IOperation Apply() {
     51    public override IOperation InstrumentedApply() {
    5252      IVRPEncoding solution = VRPToursParameter.ActualValue;
    5353      if (!(solution is GVREncoding)) {
     
    5757      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as GVREncoding);
    5858
    59       return base.Apply();
     59      return base.InstrumentedApply();
    6060    }
    6161  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Creators/MultiVRPSolutionCreator.cs

    r9456 r10538  
    9797    }
    9898
    99     public override IOperation Apply() {
     99    public override IOperation InstrumentedApply() {
    100100      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one VRP creator to choose from.");
    101       return base.Apply();
     101      return base.InstrumentedApply();
    102102    }
    103103  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs

    r9462 r10538  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text;
     24using HeuristicLab.Analysis;
     25using HeuristicLab.Collections;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     28using HeuristicLab.Data;
     29using HeuristicLab.Optimization;
     30using HeuristicLab.Parameters;
    2731using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Analysis;
    30 using HeuristicLab.Parameters;
    31 using HeuristicLab.Optimization;
    32 using HeuristicLab.Data;
    33 using HeuristicLab.Collections;
     32using HeuristicLab.Random;
    3433
    3534namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    6968      Parameters.Add(new ValueParameter<DoubleValue>("LowerBound", "The depth of the individuals in the scope tree.", new DoubleValue(0.01)));
    7069      Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1)));
     70
     71      SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator";
    7172    }
    7273
     
    8182    }
    8283
    83     public override IOperation Apply() {
     84    public override IOperation InstrumentedApply() {
    8485      IOperator successor = null;
    8586
     
    133134      }
    134135
    135       ////////////////
     136      //////////////// code has to be duplicated since ActualProbabilitiesParameter.ActualValue are updated and used for operator selection
    136137      IRandom random = RandomParameter.ActualValue;
    137138      DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue;
     
    142143      if (checkedOperators.Count() > 0) {
    143144        // select a random operator from the checked operators
    144         double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
    145         if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
    146         double r = random.NextDouble() * sum;
    147         sum = 0;
    148         foreach (var indexedItem in checkedOperators) {
    149           sum += probabilities[indexedItem.Index];
    150           if (sum > r) {
    151             successor = indexedItem.Value;
    152             break;
    153           }
    154         }
     145        successor = checkedOperators.SampleProportional(random, 1, checkedOperators.Select(x => probabilities[x.Index]), false, false).First().Value;
    155146      }
    156147
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/MultiVRPSolutionCrossover.cs

    r9456 r10538  
    6767      Parameters.Add(new LookupParameter<IVRPEncoding>("Child", "The child permutation resulting from the crossover."));
    6868      ChildParameter.ActualName = "VRPTours";
     69
     70      SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator";
    6971    }
    7072
     
    106108    }
    107109
    108     public override IOperation Apply() {
     110    public override IOperation InstrumentedApply() {
    109111      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one permutation crossover to choose from.");
    110       return base.Apply();
     112      return base.InstrumentedApply();
    111113    }
    112114  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/RandomParentCloneCrossover.cs

    r9456 r10538  
    6565    }
    6666
    67     public override IOperation Apply() {
     67    public override IOperation InstrumentedApply() {
    6868      if (RandomParameter.ActualValue.Next() < 0.5)
    6969        ChildParameter.ActualValue = ParentsParameter.ActualValue[0].Clone() as IVRPEncoding;
     
    7171        ChildParameter.ActualValue = ParentsParameter.ActualValue[1].Clone() as IVRPEncoding;
    7272
    73       return base.Apply();
     73      return base.InstrumentedApply();
    7474    }
    7575  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs

    r9462 r10538  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text;
     24using HeuristicLab.Analysis;
     25using HeuristicLab.Collections;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     28using HeuristicLab.Data;
     29using HeuristicLab.Optimization;
     30using HeuristicLab.Parameters;
    2731using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Analysis;
    30 using HeuristicLab.Parameters;
    31 using HeuristicLab.Optimization;
    32 using HeuristicLab.Data;
    33 using HeuristicLab.Collections;
     32using HeuristicLab.Random;
    3433
    3534namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    4039      get { return (ValueLookupParameter<DoubleArray>)Parameters["ActualProbabilities"]; }
    4140    }
    42    
     41
    4342    public ValueLookupParameter<StringValue> SuccessProgressAnalyisis {
    4443      get { return (ValueLookupParameter<StringValue>)Parameters["SuccessProgressAnalysis"]; }
     
    6362      : base() {
    6463      Parameters.Add(new ValueLookupParameter<DoubleArray>("ActualProbabilities", "The array of relative probabilities for each operator."));
    65       Parameters.Add(new ValueLookupParameter<StringValue>("SuccessProgressAnalysis", "The success progress analyisis to be considered", 
     64      Parameters.Add(new ValueLookupParameter<StringValue>("SuccessProgressAnalysis", "The success progress analyisis to be considered",
    6665        new StringValue("ExecutedMutationOperator")));
    6766
     
    6968      Parameters.Add(new ValueParameter<DoubleValue>("LowerBound", "The depth of the individuals in the scope tree.", new DoubleValue(0.01)));
    7069      Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1)));
     70
     71      SelectedOperatorParameter.ActualName = "SelectedManipulationOperator";
    7172    }
    7273
     
    8182    }
    8283
    83     public override IOperation Apply() {
     84    public override IOperation InstrumentedApply() {
    8485      IOperator successor = null;
    8586
     
    133134      }
    134135
    135       ////////////////
     136      //////////////// code has to be duplicated since ActualProbabilitiesParameter.ActualValue are updated and used for operator selection
    136137      IRandom random = RandomParameter.ActualValue;
    137138      DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue;
     
    142143      if (checkedOperators.Count() > 0) {
    143144        // select a random operator from the checked operators
    144         double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum();
    145         if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability.");
    146         double r = random.NextDouble() * sum;
    147         sum = 0;
    148         foreach (var indexedItem in checkedOperators) {
    149           sum += probabilities[indexedItem.Index];
    150           if (sum > r) {
    151             successor = indexedItem.Value;
    152             break;
    153           }
    154         }
     145        successor =
     146          checkedOperators.SampleProportional(random, 1, checkedOperators.Select(x => probabilities[x.Index]), false, false).First().Value;
    155147      }
    156148
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/MultiVRPSolutionManipulator.cs

    r9456 r10538  
    5959      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
    6060      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours to be manipulated."));
     61
     62      SelectedOperatorParameter.ActualName = "SelectedManipulationOperator";
    6163    }
    6264
     
    9799    }
    98100
    99     public override IOperation Apply() {
     101    public override IOperation InstrumentedApply() {
    100102      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one permutation manipulator to choose from.");
    101       return base.Apply();
     103      return base.InstrumentedApply();
    102104    }
    103105  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r9456 r10538  
    5353    protected override void EvaluateMove() { }
    5454
    55     public override IOperation Apply() {
     55    public override IOperation InstrumentedApply() {
    5656      IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove;
    5757
     
    5959      moveEvaluator.VRPMoveParameter.ActualName = VRPMoveParameter.Name;
    6060
    61       OperationCollection next = new OperationCollection(base.Apply());
     61      OperationCollection next = new OperationCollection(base.InstrumentedApply());
    6262      next.Insert(0, ExecutionContext.CreateOperation(moveEvaluator));
    6363
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs

    r9456 r10538  
    153153    }
    154154
    155     public override IOperation Apply() {
     155    public override IOperation InstrumentedApply() {
    156156      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one VRP move generator choose from.");
    157       OperationCollection next = new OperationCollection(base.Apply());
     157      OperationCollection next = new OperationCollection(base.InstrumentedApply());
    158158
    159159      for (int i = 0; i < SelectedOperatorsParameter.ActualValue.Value; i++) {
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveEvaluator.cs

    r9456 r10538  
    7676    protected abstract void EvaluateMove();
    7777
    78     public override IOperation Apply() {
     78    public override IOperation InstrumentedApply() {
    7979      EvaluateMove();
    8080
    81       return base.Apply();
     81      return base.InstrumentedApply();
    8282    }
    8383  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveMaker.cs

    r9456 r10538  
    9999    }
    100100
    101     public override IOperation Apply() {
     101    public override IOperation InstrumentedApply() {
    102102      PerformMove();
    103103      UpdateMoveEvaluation();
    104104
    105       return base.Apply();
     105      return base.InstrumentedApply();
    106106    }
    107107  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs

    r9456 r10538  
    8181    }
    8282
    83     private static PotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) {
     83    public static PotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) {
    8484      PotvinEncoding result = new PotvinEncoding(instance);
    8585
     
    9191          customers.Add(i);
    9292
    93       customers.Sort(delegate(int city1, int city2) {
    94             double angle1 = CalculateAngleToDepot(instance, city1);
    95             double angle2 = CalculateAngleToDepot(instance, city2);
     93      customers.Sort((city1, city2) => {
     94        double angle1 = CalculateAngleToDepot(instance, city1);
     95        double angle2 = CalculateAngleToDepot(instance, city2);
    9696
    97             return angle1.CompareTo(angle2);
    98           });
     97        return angle1.CompareTo(angle2);
     98      });
    9999
    100100      Tour currentTour = new Tour();
     
    140140    }
    141141
    142     public override IOperation Apply() {
     142    public override IOperation InstrumentedApply() {
    143143      VRPToursParameter.ActualValue = CreateSolution(ProblemInstance, RandomParameter.ActualValue, AdhereTimeWindowsParameter.Value.Value);
    144144
    145       return base.Apply();
     145      return base.InstrumentedApply();
    146146    }
    147147  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PushForwardInsertionCreator.cs

    r9456 r10538  
    373373    }
    374374
    375     public override IOperation Apply() {
     375    public override IOperation InstrumentedApply() {
    376376      VRPToursParameter.ActualValue = CreateSolution(ProblemInstance, RandomParameter.ActualValue,
    377377        Alpha.Value.Value, Beta.Value.Value, Gamma.Value.Value,
    378378        AlphaVariance.Value.Value, BetaVariance.Value.Value, GammaVariance.Value.Value);
    379379
    380       return base.Apply();
     380      return base.InstrumentedApply();
    381381    }
    382382  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinCrossover.cs

    r9456 r10538  
    144144    }
    145145
    146     public override IOperation Apply() {
     146    public override IOperation InstrumentedApply() {
    147147      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    148148      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
     
    160160      (ChildParameter.ActualValue as PotvinEncoding).Repair();
    161161
    162       return base.Apply();
     162      return base.InstrumentedApply();
    163163    }
    164164  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs

    r9456 r10538  
    5252    }
    5353
    54     private bool FindBetterInsertionPlace(
    55       PotvinEncoding individual, int tour, int city, int length,
     54    private static bool FindBetterInsertionPlace(
     55      PotvinEncoding individual, IVRPProblemInstance instance, int tour, int city, int length,
    5656      out int insertionTour, out int insertionPlace) {
    5757      bool insertionFound = false;
     
    7070          distance = individual.GetTourLength(individual.Tours[currentTour]);
    7171          individual.Tours[currentTour].Stops.InsertRange(currentCity, toBeDeleted);
    72           if (ProblemInstance.TourFeasible(individual.Tours[currentTour], individual)) {
     72          if (instance.TourFeasible(individual.Tours[currentTour], individual)) {
    7373            double lengthIncrease =
    7474              individual.GetTourLength(individual.Tours[currentTour]) - distance;
     
    9292    }
    9393
    94     protected override void Manipulate(IRandom random, PotvinEncoding individual) {
     94    public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, int maxIterations) {
    9595      //only apply to feasible individuals
    96       if (ProblemInstance.Feasible(individual)) {
     96      if (instance.Feasible(individual)) {
    9797        bool insertionFound;
    9898        int iterations = 0;
     
    107107              while (city <= individual.Tours[tour].Stops.Count - length && !insertionFound) {
    108108                int insertionTour, insertionPlace;
    109                 if (FindBetterInsertionPlace(individual, tour, city, length,
     109                if (FindBetterInsertionPlace(individual, instance, tour, city, length,
    110110                 out insertionTour, out insertionPlace)) {
    111111                  insertionFound = true;
     
    126126          iterations++;
    127127        } while (insertionFound &&
    128           iterations < Iterations.Value.Value);
     128          iterations < maxIterations);
    129129
    130130        IList<Tour> toBeRemoved = new List<Tour>();
     
    139139      }
    140140    }
     141 
     142
     143    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
     144      ApplyManipulation(random, individual, ProblemInstance, Iterations.Value.Value);     
     145    }
    141146  }
    142147}
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinManipulator.cs

    r9456 r10538  
    5555    protected abstract void Manipulate(IRandom random, PotvinEncoding individual);
    5656
    57     protected int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {
     57    protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance) {
    5858      int tourIndex = -1;
    5959
     
    6161      double[] probabilities = new double[individual.Tours.Count];
    6262      for (int i = 0; i < individual.Tours.Count; i++) {
    63         probabilities[i] = 1.0 / ((double)individual.Tours[i].Stops.Count / (double)ProblemInstance.Cities.Value);
     63        probabilities[i] = 1.0 / ((double)individual.Tours[i].Stops.Count / (double)instance.Cities.Value);
    6464        sum += probabilities[i];
    6565      }
     
    8282    }
    8383
    84     protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, bool allowInfeasible, out int route, out int place) {
     84    protected static bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, bool allowInfeasible, out int route, out int place) {
    8585      return individual.FindInsertionPlace(
    8686        city, routeToAvoid, allowInfeasible, out route, out place);
    8787    }
    8888
    89     public override IOperation Apply() {
     89    public override IOperation InstrumentedApply() {
    9090      IVRPEncoding solution = VRPToursParameter.ActualValue;
    9191      if (!(solution is PotvinEncoding)) {
     
    9696      (VRPToursParameter.ActualValue as PotvinEncoding).Repair();
    9797
    98       return base.Apply();
     98      return base.InstrumentedApply();
    9999    }
    100100  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs

    r9456 r10538  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2526
    2627namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4142    }
    4243
    43     protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    44       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    45 
    46       int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
     44    public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, bool allowInfeasible) {
     45      int selectedIndex = SelectRandomTourBiasedByLength(random, individual, instance);
    4746      if (selectedIndex >= 0) {
    4847        Tour route1 =
     
    6867      }
    6968    }
     69
     70    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
     71      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     72      ApplyManipulation(random, individual, ProblemInstance, allowInfeasible);     
     73    }
    7074  }
    7175}
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs

    r9456 r10538  
    2525using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    2626using HeuristicLab.Problems.VehicleRouting.Variants;
     27using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4344    }
    4445
    45     public bool PairwiseMove(PotvinEncoding individual, int city, bool allowInfeasible) {
     46    public static bool PairwiseMove(PotvinEncoding individual, IVRPProblemInstance instance, int city, bool allowInfeasible) {
    4647      bool success;
    4748
    48       IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;
     49      IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance;
    4950
    5051      if (pdp != null) {
     
    6465
    6566        int source, target;
    66         if (ProblemInstance.GetDemand(city) >= 0) {
     67        if (instance.GetDemand(city) >= 0) {
    6768          source = city;
    6869          target = dest;
     
    8081          if (tourIdx != routeToAvoid) {
    8182            Tour tour = individual.Tours[tourIdx];
    82             VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, individual);
    83             individual.InsertPair(tour, source, target, ProblemInstance);
    84             VRPEvaluation evalNew = ProblemInstance.EvaluateTour(tour, individual);
     83            VRPEvaluation eval = instance.EvaluateTour(tour, individual);
     84            individual.InsertPair(tour, source, target, instance);
     85            VRPEvaluation evalNew = instance.EvaluateTour(tour, individual);
    8586
    8687            double delta = evalNew.Quality - eval.Quality;
    8788
    8889            if (delta < bestQuality &&
    89                (ProblemInstance.Feasible(evalNew) || allowInfeasible)) {
     90               (instance.Feasible(evalNew) || allowInfeasible)) {
    9091              bestQuality = delta;
    9192              bestTour = tourIdx;
     
    127128    }
    128129
     130    public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IPickupAndDeliveryProblemInstance pdp, bool allowInfeasible) {
     131      int selectedIndex = SelectRandomTourBiasedByLength(random, individual, pdp);
     132      if (selectedIndex >= 0) {
     133        Tour route1 =
     134          individual.Tours[selectedIndex];
     135
     136        int count = route1.Stops.Count;
     137
     138        if (count > 0) {
     139          int i = random.Next(0, count);
     140          int city = route1.Stops[i];
     141
     142          if (!PairwiseMove(individual, pdp, city, allowInfeasible))
     143            i++;
     144
     145          count = route1.Stops.Count;
     146        }
     147      }
     148    }
     149
     150
    129151    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    130152      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     153
    131154      IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;
    132155
    133156      if (pdp != null) {
    134         int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    135         if (selectedIndex >= 0) {
    136           Tour route1 =
    137             individual.Tours[selectedIndex];
    138 
    139           int count = route1.Stops.Count;
    140 
    141           if (count > 0) {
    142             int i = random.Next(0, count);
    143             int city = route1.Stops[i];
    144 
    145             if (!PairwiseMove(individual, city, allowInfeasible))
    146               i++;
    147 
    148             count = route1.Stops.Count;
    149           }
    150         }
     157        ApplyManipulation(random, individual, pdp, allowInfeasible);
    151158      }
    152159    }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseTwoLevelExchangeManipulator.cs

    r9456 r10538  
    2626using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    2727using HeuristicLab.Problems.VehicleRouting.Variants;
     28using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2829
    2930namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4445    }
    4546
    46     private PotvinEncoding ReplacePair(PotvinEncoding individual, int replaced, int replacing, bool allowInfeasible) {
     47    private static PotvinEncoding ReplacePair(PotvinEncoding individual, IVRPProblemInstance instance, int replaced, int replacing, bool allowInfeasible) {
    4748      individual = individual.Clone() as PotvinEncoding;
    48       IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;
     49      IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance;
    4950
    5051      int replacedDest = pdp.GetPickupDeliveryLocation(replaced);
     
    7677
    7778      replacedSourceTour.Stops[replacedSourceTour.Stops.IndexOf(replacedSource)] = replacingSource;
    78       if (!allowInfeasible && !ProblemInstance.TourFeasible(replacedSourceTour, individual))
     79      if (!allowInfeasible && !instance.TourFeasible(replacedSourceTour, individual))
    7980        return null;
    8081
    8182      replacedTargetTour.Stops[replacedTargetTour.Stops.IndexOf(replacedTarget)] = replacingTarget;
    82       if (!allowInfeasible && !ProblemInstance.TourFeasible(replacedTargetTour, individual))
     83      if (!allowInfeasible && !instance.TourFeasible(replacedTargetTour, individual))
    8384        return null;
    8485
     
    9394        if (tourIdx != routeToAvoid) {
    9495          Tour tour = individual.Tours[tourIdx];
    95           VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, individual);
    96           individual.InsertPair(tour, replacedSource, replacedTarget, ProblemInstance);
    97           VRPEvaluation evalNew = ProblemInstance.EvaluateTour(tour, individual);
     96          VRPEvaluation eval = instance.EvaluateTour(tour, individual);
     97          individual.InsertPair(tour, replacedSource, replacedTarget, instance);
     98          VRPEvaluation evalNew = instance.EvaluateTour(tour, individual);
    9899
    99100          double delta = evalNew.Quality - eval.Quality;
    100101
    101102          if (delta < bestQuality &&
    102               (ProblemInstance.Feasible(evalNew) || allowInfeasible)) {
     103              (instance.Feasible(evalNew) || allowInfeasible)) {
    103104            bestQuality = delta;
    104105            bestTour = tourIdx;
     
    127128    }
    128129
     130    public static PotvinEncoding ApplyManipulation(IRandom random, PotvinEncoding individual, IPickupAndDeliveryProblemInstance pdp, bool allowInfeasible) {
     131      PotvinEncoding result = null;
     132     
     133      int selectedIndex = SelectRandomTourBiasedByLength(random, individual, pdp);
     134      if (selectedIndex >= 0) {
     135        bool performed = false;
     136        Tour route1 = individual.Tours[selectedIndex];
     137
     138        if (route1.Stops.Count > 0) {
     139          //randomize customer selection
     140          Permutation perm = new Permutation(PermutationTypes.Absolute, route1.Stops.Count, random);
     141          int customer1Position = 0;
     142
     143          while (customer1Position < route1.Stops.Count) {
     144            performed = false;
     145
     146            int customer1 = route1.Stops[perm[customer1Position]];
     147            int customer2 = -1;
     148
     149            for (int i = 0; i < individual.Tours.Count; i++) {
     150              if (i != selectedIndex) {
     151                Tour tour = individual.Tours[i];
     152                for (int customer2Position = 0; customer2Position < tour.Stops.Count; customer2Position++) {
     153                  customer2 = tour.Stops[customer2Position];
     154
     155                  if (pdp.GetPickupDeliveryLocation(customer1) != customer2) {
     156                    result = ReplacePair(individual, pdp, customer2, customer1, allowInfeasible);
     157                    if (result != null) {
     158                      individual = result;
     159
     160                      route1 = individual.Tours[selectedIndex];
     161                      performed = true;
     162                      break;
     163                    }
     164                  }
     165                }
     166              }
     167
     168              if (performed) {
     169                break;
     170              }
     171            }
     172
     173            if (!performed)
     174              customer1Position++;
     175            else
     176              break;
     177          }
     178        }
     179      }
     180
     181      return result;
     182    }
     183
    129184    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    130185      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     
    132187
    133188      if (pdp != null) {
    134         int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    135         if (selectedIndex >= 0) {
    136           bool performed = false;
    137           Tour route1 = individual.Tours[selectedIndex];
    138 
    139           if (route1.Stops.Count > 0) {
    140             //randomize customer selection
    141             Permutation perm = new Permutation(PermutationTypes.Absolute, route1.Stops.Count, random);
    142             int customer1Position = 0;
    143 
    144             while (customer1Position < route1.Stops.Count) {
    145               performed = false;
    146 
    147               int customer1 = route1.Stops[perm[customer1Position]];
    148               int customer2 = -1;
    149 
    150               for (int i = 0; i < individual.Tours.Count; i++) {
    151                 if (i != selectedIndex) {
    152                   Tour tour = individual.Tours[i];
    153                   for (int customer2Position = 0; customer2Position < tour.Stops.Count; customer2Position++) {
    154                     customer2 = tour.Stops[customer2Position];
    155 
    156                     if (pdp.GetPickupDeliveryLocation(customer1) != customer2) {
    157                       PotvinEncoding result = ReplacePair(individual, customer2, customer1, allowInfeasible);
    158                       if (result != null) {
    159                         VRPToursParameter.ActualValue = result;
    160                         individual = result;
    161 
    162                         route1 = individual.Tours[selectedIndex];
    163                         performed = true;
    164                         break;
    165                       }
    166                     }
    167                   }
    168                 }
    169 
    170                 if (performed) {
    171                   break;
    172                 }
    173               }
    174 
    175               if (!performed)
    176                 customer1Position++;
    177               else
    178                 break;
    179             }
    180           }
    181         }
     189        PotvinEncoding result = ApplyManipulation(random, individual, pdp, allowInfeasible);
     190        if (result != null) {
     191          VRPToursParameter.ActualValue = result;
     192        }       
    182193      }
    183194    }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r9456 r10538  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2526
    2627namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4142    }
    4243
    43     protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    44       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    45 
    46       int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
     44    public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, bool allowInfeasible) {
     45      int selectedIndex = SelectRandomTourBiasedByLength(random, individual, instance);
    4746      if (selectedIndex >= 0) {
    4847        Tour route1 = individual.Tours[selectedIndex];
     
    6362                route1.Stops.RemoveAt(customer1Position);
    6463
    65                 if (ProblemInstance.TourFeasible(tour, individual)) {
     64                if (instance.TourFeasible(tour, individual)) {
    6665                  int routeIdx, place;
    6766                  if (FindInsertionPlace(individual,
     
    9291      }
    9392    }
     93     
     94
     95    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
     96      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     97
     98      ApplyManipulation(random, individual, ProblemInstance, allowInfeasible);
     99    }
    94100  }
    95101}
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinVehicleAssignmentManipulator.cs

    r9456 r10538  
    6060    }
    6161
    62     public override IOperation Apply() {
     62    public override IOperation InstrumentedApply() {
    6363      IVRPEncoding solution = VRPToursParameter.ActualValue;
    6464      if (!(solution is PotvinEncoding)) {
     
    6666      }
    6767
    68       OperationCollection next = new OperationCollection(base.Apply());
     68      OperationCollection next = new OperationCollection(base.InstrumentedApply());
    6969
    7070      VehicleAssignmentParameter.ActualValue = (VRPToursParameter.ActualValue as PotvinEncoding).VehicleAssignment;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinCustomerRelocationMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDExchange/PotvinPDExchangeMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinPDExchangeMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinPDRearrangeMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinPDShiftMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PotvinMoveGenerator.cs

    r9456 r10538  
    4141    }
    4242
    43     public override IOperation Apply() {
     43    public override IOperation InstrumentedApply() {
    4444      IVRPEncoding solution = VRPToursParameter.ActualValue;
    4545      if (!(solution is PotvinEncoding)) {
     
    4747      }
    4848
    49       return base.Apply();
     49      return base.InstrumentedApply();
    5050    }
    5151  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/TwoOptStar/PotvinTwoOptStarMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinTwoOptStarMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/VehicleAssignment/PotvinVehicleAssignmentMoveGenerator.cs

    r9456 r10538  
    5757    protected abstract PotvinVehicleAssignmentMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance);
    5858
    59     public override IOperation Apply() {
    60       IOperation next = base.Apply();
     59    public override IOperation InstrumentedApply() {
     60      IOperation next = base.InstrumentedApply();
    6161
    6262      PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding;
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/Crossovers/PrinsCrossover.cs

    r9456 r10538  
    5151    protected abstract PrinsEncoding Crossover(IRandom random, PrinsEncoding parent1, PrinsEncoding parent2);
    5252
    53     public override IOperation Apply() {
     53    public override IOperation InstrumentedApply() {
    5454      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    5555      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
     
    6767        Crossover(RandomParameter.ActualValue, parents[0] as PrinsEncoding, parents[1] as PrinsEncoding);
    6868
    69       return base.Apply();
     69      return base.InstrumentedApply();
    7070    }
    7171  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/Manipulators/PrinsManipulator.cs

    r9456 r10538  
    5050    protected abstract void Manipulate(IRandom random, PrinsEncoding individual);
    5151
    52     public override IOperation Apply() {
     52    public override IOperation InstrumentedApply() {
    5353      IVRPEncoding solution = VRPToursParameter.ActualValue;
    5454      if (!(solution is PrinsEncoding)) {
     
    5858      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PrinsEncoding);
    5959
    60       return base.Apply();
     60      return base.InstrumentedApply();
    6161    }
    6262  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs

    r9456 r10538  
    3030  [Item("VRPOperator", "Represents a VRP operator.")]
    3131  [StorableClass]
    32   public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator {
     32  public abstract class VRPOperator : InstrumentedOperator, IVRPOperator {
    3333    public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter {
    3434      get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuCrossover.cs

    r9456 r10538  
    5050    protected abstract ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2);
    5151
    52     public override IOperation Apply() {
     52    public override IOperation InstrumentedApply() {
    5353      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    5454      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
     
    6666        Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncoding, parents[1] as ZhuEncoding);
    6767
    68       return base.Apply();
     68      return base.InstrumentedApply();
    6969    }
    7070  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuManipulator.cs

    r9456 r10538  
    5050    protected abstract void Manipulate(IRandom random, ZhuEncoding individual);
    5151
    52     public override IOperation Apply() {
     52    public override IOperation InstrumentedApply() {
    5353      IVRPEncoding solution = VRPToursParameter.ActualValue;
    5454      if (!(solution is ZhuEncoding)) {
     
    5858      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncoding);
    5959
    60       return base.Apply();
     60      return base.InstrumentedApply();
    6161    }
    6262  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r8894 r10538  
    465465      <Private>False</Private>
    466466    </ProjectReference>
     467    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     468      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
     469      <Name>HeuristicLab.Random-3.3</Name>
     470    </ProjectReference>
    467471  </ItemGroup>
    468472  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Improver/VRPImprovementOperator.cs

    r9456 r10538  
    7575    }
    7676
    77     public override IOperation Apply() {
     77    public override IOperation InstrumentedApply() {
    7878      var solution = SolutionParameter.ActualValue as IVRPEncoding;
    7979      var potvinSolution = solution is PotvinEncoding ? solution as PotvinEncoding : PotvinEncoding.ConvertFrom(solution, ProblemInstance);
     
    8787      LocalEvaluatedSolutions.ActualValue = new IntValue(evaluatedSolutions);
    8888
    89       return base.Apply();
     89      return base.InstrumentedApply();
    9090    }
    9191
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame

    r10037 r10538  
    4141  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    4242  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     43  [PluginDependency("HeuristicLab.Random", "3.3")]
    4344  public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase {
    4445  }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs

    r9456 r10538  
    128128    }
    129129
    130     public override IOperation Apply() {
     130    public override IOperation InstrumentedApply() {
    131131      InitResultParameters();
    132132
     
    140140      QualityParameter.ActualValue = new DoubleValue(evaluation.Quality);
    141141
    142       return base.Apply();
     142      return base.InstrumentedApply();
    143143    }
    144144
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r9456 r10538  
    3939
    4040namespace HeuristicLab.Problems.VehicleRouting {
    41   public interface IVRPInstanceConsumer : 
    42     IProblemInstanceConsumer<CVRPData>, IProblemInstanceConsumer<CVRPTWData>,
    43     IProblemInstanceConsumer<MDCVRPData>, IProblemInstanceConsumer<MDCVRPTWData>,
    44     IProblemInstanceConsumer<PDPTWData> {
    45   }
    46 
    4741  [Item("Vehicle Routing Problem", "Represents a Vehicle Routing Problem.")]
    4842  [Creatable("Problems")]
    4943  [StorableClass]
    50   public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IVRPInstanceConsumer {
     44  public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<VRPData> {
    5145    public string Filename { get; set; }
    5246
     
    143137      AttachEventHandlers();
    144138      AttachProblemInstanceEventHandlers();
     139
     140      EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;
    145141    }
    146142
     
    153149      : base(original, cloner) {
    154150      this.AttachEventHandlers();
     151      this.AttachProblemInstanceEventHandlers();
     152
     153      ProblemInstance.SolutionEvaluator = EvaluatorParameter.Value;
    155154    }
    156155
     
    173172      AttachEventHandlers();
    174173      AttachProblemInstanceEventHandlers();
     174
     175      ProblemInstance.SolutionEvaluator = EvaluatorParameter.Value;
    175176    }
    176177
     
    189190    private void AttachProblemInstanceEventHandlers() {
    190191      if (ProblemInstance != null) {
    191         EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;
    192192        ProblemInstance.EvaluationChanged += new EventHandler(ProblemInstance_EvaluationChanged);
    193193      }
     
    209209
    210210    void ProblemInstance_EvaluationChanged(object sender, EventArgs e) {
    211       EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;
    212211      EvalBestKnownSolution();
    213212    }
     
    216215      InitializeOperators();
    217216      AttachProblemInstanceEventHandlers();
     217
     218      EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;
    218219
    219220      OnSolutionCreatorChanged();
     
    383384      }
    384385    }
    385 
    386     public void Load(CVRPData data) {
    387       Load(data, new CVRPInterpreter());
    388     }
    389 
    390     public void Load(CVRPTWData data) {
    391       Load(data, new CVRPTWInterpreter());
    392     }
    393 
    394     public void Load(MDCVRPData data) {
    395       Load(data, new MDCVRPInterpreter());
    396     }
    397 
    398     public void Load(MDCVRPTWData data) {
    399       Load(data, new MDCVRPTWInterpreter());
    400     }
    401 
    402     public void Load(PDPTWData data) {
    403       Load(data, new PDPTWInterpreter());
     386    #endregion
     387
     388    #region IProblemInstanceConsumer<VRPData> Members
     389
     390    public void Load(VRPData data) {
     391      Type interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(data.GetType());
     392      var interpreters = ApplicationManager.Manager.GetInstances(interpreterType);
     393      IVRPDataInterpreter interpreter = null;
     394      foreach (object i in interpreters) {
     395        var parentInterfaces = i.GetType().BaseType.GetInterfaces();
     396        var interfaces = i.GetType().GetInterfaces().Except(parentInterfaces);
     397        var interpreterInterface = interfaces.First(j => typeof(IVRPDataInterpreter).IsAssignableFrom(j));
     398        var interpreterDataType = interpreterInterface.GetGenericArguments()[0];
     399        if (interpreterDataType == data.GetType()) {
     400          interpreter = i as IVRPDataInterpreter;
     401          break;
     402        }
     403      }
     404
     405      if (interpreter == null)
     406        throw new ArgumentException("No interpreter found for the VRP type");
     407      Load(data, interpreter);
    404408    }
    405409
Note: See TracChangeset for help on using the changeset viewer.