Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/20 15:50:59 (4 years ago)
Author:
abeham
Message:

#2521: working on VRP

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/BestVRPSolutionAnalyzer.cs

    r17709 r17710  
    2727using HeuristicLab.Optimization;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2930using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031
     
    3334  /// An operator for analyzing the best solution of Vehicle Routing Problems.
    3435  /// </summary>
     36  //TODO: remove this operator -> part of VRP problem analyze
    3537  [Item("BestVRPSolutionAnalyzer", "An operator for analyzing the best solution of Vehicle Routing Problems.")]
    3638  [StorableType("3e1bb409-0b8f-4324-826c-2190aa5fb2b6")]
    3739  public sealed class BestVRPSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator {
     40
     41    [Storable] private ILookupParameter<IVRPProblemInstance> problemInstanceParameter;
     42    public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter => problemInstanceParameter;
     43    [Storable] private IScopeTreeLookupParameter<IVRPEncodedSolution> vrpToursParameter;
     44    public IScopeTreeLookupParameter<IVRPEncodedSolution> VRPToursParameter => vrpToursParameter;
    3845
    3946    [Storable] private IScopeTreeLookupParameter<VRPEvaluation> evaluationParameter;
     
    4350    public ILookupParameter<VRPSolution> BestSolutionParameter => bestSolutionParameter;
    4451
    45     [Storable] private IResultParameter<VRPEvaluation> bestEvaluationParameter;
    46     public IResultParameter<VRPEvaluation> BestSolutionEvaluationParameter => bestEvaluationParameter;
     52    [Storable] private ILookupParameter<VRPSolution> bestFeasibleSolutionParameter;
     53    public ILookupParameter<VRPSolution> BestFeasibleSolutionParameter => bestFeasibleSolutionParameter;
     54
     55    [Storable] private IResultParameter<VRPEvaluation> bestEvaluationResult;
     56    public IResultParameter<VRPEvaluation> BestSolutionEvaluationResult => bestEvaluationResult;
     57    [Storable] private IResultParameter<VRPEvaluation> bestFeasibleEvaluationResult;
     58    public IResultParameter<VRPEvaluation> BestFeasibleSolutionEvaluationResult => bestFeasibleEvaluationResult;
     59    [Storable] private IResultParameter<VRPSolution> bestSolutionResult;
     60    public IResultParameter<VRPSolution> BestSolutionResult => bestSolutionResult;
     61    [Storable] private IResultParameter<VRPSolution> bestFeasibleSolutionResult;
     62    public IResultParameter<VRPSolution> BestFeasibleSolutionResult => bestFeasibleSolutionResult;
    4763
    4864    public bool EnabledByDefault {
     
    5470    private BestVRPSolutionAnalyzer(BestVRPSolutionAnalyzer original, Cloner cloner)
    5571      : base(original, cloner) {
     72      problemInstanceParameter = cloner.Clone(original.problemInstanceParameter);
     73      vrpToursParameter = cloner.Clone(original.vrpToursParameter);
    5674      evaluationParameter = cloner.Clone(original.evaluationParameter);
    5775      bestSolutionParameter = cloner.Clone(original.bestSolutionParameter);
    58       bestEvaluationParameter = cloner.Clone(original.bestEvaluationParameter);
     76      bestFeasibleSolutionParameter = cloner.Clone(original.bestFeasibleSolutionParameter);
     77      bestEvaluationResult = cloner.Clone(original.bestEvaluationResult);
     78      bestFeasibleEvaluationResult = cloner.Clone(original.bestFeasibleEvaluationResult);
     79      bestSolutionResult = cloner.Clone(original.bestSolutionResult);
     80      bestFeasibleSolutionResult = cloner.Clone(original.bestFeasibleSolutionResult);
    5981    }
    6082    public BestVRPSolutionAnalyzer()
    6183      : base() {
     84      Parameters.Add(problemInstanceParameter = new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance."));
     85      Parameters.Add(vrpToursParameter = new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP encoded solution."));
    6286      Parameters.Add(evaluationParameter = new ScopeTreeLookupParameter<VRPEvaluation>("EvaluationResult", "The qualities of the VRP solutions which should be analyzed."));
    6387      Parameters.Add(bestSolutionParameter = new LookupParameter<VRPSolution>("BestSolution", "The best-so-far solution."));
    64       Parameters.Add(bestEvaluationParameter = new ResultParameter<VRPEvaluation>("Best VRP Evaluation", "The best VRP evaluation.", "Results"));
     88      Parameters.Add(bestFeasibleSolutionParameter = new LookupParameter<VRPSolution>("BestFeasibleSolution", "The best-so-far feasible solution."));
     89      Parameters.Add(bestEvaluationResult = new ResultParameter<VRPEvaluation>("Best VRP Solution Evaluation", "The best VRP evaluation.", "Results"));
     90      Parameters.Add(bestFeasibleEvaluationResult = new ResultParameter<VRPEvaluation>("Best Feasible VRP Solution Evaluation", "The best feasible VRP evaluation.", "Results"));
     91      Parameters.Add(bestSolutionResult = new ResultParameter<VRPSolution>("Best VRP Solution", "The best-so-far VRP solution."));
     92      Parameters.Add(bestFeasibleSolutionResult = new ResultParameter<VRPSolution>("Best feasible VRP Solution", "The best-so-far feasible VRP solution."));
    6593    }
    6694
     
    72100      var evaluations = EvaluationParameter.ActualValue;
    73101
    74       int i = evaluations.Select((x, index) => new { index, Eval = x }).OrderBy(x => x.Eval.Quality).First().index;
     102      var bestInPop = evaluations.Select((x, index) => new { index, Eval = x }).OrderBy(x => x.Eval.Quality).First();
     103      var bestFeasibleInPop = evaluations.Select((x, index) => new { index, Eval = x }).Where(x => x.Eval.IsFeasible).OrderBy(x => x.Eval.Quality).FirstOrDefault();
    75104
    76       var bestEvaluation = BestSolutionEvaluationParameter.ActualValue;
     105      var bestEvaluation = BestSolutionEvaluationResult.ActualValue;
    77106     
    78107      var bestSolution = BestSolutionParameter.ActualValue;
    79       if (bestSolution == null || evaluations[i].Quality <= bestSolution.Quality.Value) {
    80         BestSolutionEvaluationParameter.ActualValue = (VRPEvaluation)evaluations[i].Clone();
     108      if (bestSolution == null || bestInPop.Eval.Quality < bestSolution.Evaluation.Quality) {
     109        var best = new VRPSolution(ProblemInstanceParameter.ActualValue,
     110          VRPToursParameter.ActualValue[bestInPop.index], (VRPEvaluation)bestInPop.Eval.Clone());
     111        BestSolutionParameter.ActualValue = best;
     112        BestSolutionResult.ActualValue = best;
     113        BestSolutionEvaluationResult.ActualValue = (VRPEvaluation)bestInPop.Eval.Clone();
     114      };
     115
     116      if (bestFeasibleInPop != null) {
     117        var bestFeasibleSolution = BestFeasibleSolutionParameter.ActualValue;
     118        if (bestFeasibleSolution == null || bestFeasibleInPop.Eval.Quality < bestFeasibleSolution.Evaluation.Quality) {
     119          var bestFeasible = new VRPSolution(ProblemInstanceParameter.ActualValue,
     120          VRPToursParameter.ActualValue[bestFeasibleInPop.index], (VRPEvaluation)bestFeasibleInPop.Eval.Clone());
     121          BestFeasibleSolutionParameter.ActualValue = bestFeasible;
     122          bestFeasibleSolutionResult.ActualValue = bestFeasible;
     123          BestFeasibleSolutionEvaluationResult.ActualValue = (VRPEvaluation)bestFeasibleInPop.Eval.Clone();
     124        }
    81125      }
    82126
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/Capacitated/CapacityRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<DoubleValue> OverloadParameter {
    50       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Overload"]; }
     46    public ScopeTreeLookupParameter<CVRPEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<DoubleValue> overloads = OverloadParameter.ActualValue;
     110      ItemArray<CVRPEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= overloads[j].Value * cvrp.OverloadPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].Overload * cvrp.OverloadPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (overloads[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].Overload == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = cvrp.OverloadPenalty.Value / (1 + sigma);
     
    142136        cvrp.CurrentOverloadPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += overloads[j].Value * cvrp.CurrentOverloadPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].Overload * cvrp.CurrentOverloadPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Overload Penalty")) {
    149         results.Add(new Result("Current Overload Penalty", new DoubleValue(cvrp.CurrentOverloadPenalty.Value)));
     142      if (!results.TryGetValue("Current Overload Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Overload Penalty", new DoubleValue(cvrp.CurrentOverloadPenalty.Value));
    150144      } else {
    151         (results["Current Overload Penalty"].Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value;
     145        (res.Value as DoubleValue).Value = cvrp.CurrentOverloadPenalty.Value;
    152146      }
    153147
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<IntValue> PickupViolationsParameter {
    50       get { return (ScopeTreeLookupParameter<IntValue>)Parameters["PickupViolations"]; }
     46    public ScopeTreeLookupParameter<CVRPPDTWEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPPDTWEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<IntValue>("PickupViolations", "The pickup violation of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPPDTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<IntValue> pickupViolations = PickupViolationsParameter.ActualValue;
     110      ItemArray<CVRPPDTWEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= pickupViolations[j].Value * pdp.PickupViolationPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].PickupViolations * pdp.PickupViolationPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (pickupViolations[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].PickupViolations == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = pdp.PickupViolationPenalty.Value / (1 + sigma);
     
    142136        pdp.CurrentPickupViolationPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += pickupViolations[j].Value * pdp.CurrentPickupViolationPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].PickupViolations * pdp.CurrentPickupViolationPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Pickup Violation Penalty")) {
    149         results.Add(new Result("Current Pickup Violation Penalty", new DoubleValue(pdp.CurrentPickupViolationPenalty.Value)));
     142      if (!results.TryGetValue("Current Pickup Violation Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Pickup Violation Penalty", new DoubleValue(pdp.CurrentPickupViolationPenalty.Value));
    150144      } else {
    151         (results["Current Pickup Violation Penalty"].Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value;
     145        (res.Value as DoubleValue).Value = pdp.CurrentPickupViolationPenalty.Value;
    152146      }
    153147
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs

    r17698 r17710  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.VehicleRouting.Interfaces;
     30using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3031using HeuristicLab.Problems.VehicleRouting.Variants;
    3132
     
    4344      get { return (ScopeTreeLookupParameter<IVRPEncodedSolution>)Parameters["VRPTours"]; }
    4445    }
    45     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    46       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    47     }
    48 
    49     public ScopeTreeLookupParameter<DoubleValue> TardinessParameter {
    50       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Tardiness"]; }
     46    public ScopeTreeLookupParameter<CVRPTWEvaluation> EvaluationParameter {
     47      get { return (ScopeTreeLookupParameter<CVRPTWEvaluation>)Parameters["EvaluationResult"]; }
    5148    }
    5249
     
    7976      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    8077      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncodedSolution>("VRPTours", "The VRP tours which should be evaluated."));
    81       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    82 
    83       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed."));
     78      Parameters.Add(new ScopeTreeLookupParameter<CVRPTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
    8479
    8580      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     
    113108      ResultCollection results = ResultsParameter.ActualValue;
    114109
    115       ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    116       ItemArray<DoubleValue> tardiness = TardinessParameter.ActualValue;
     110      ItemArray<CVRPTWEvaluation> evaluations = EvaluationParameter.ActualValue;
    117111
    118112      double sigma = SigmaParameter.Value.Value;
     
    121115      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    122116
    123       for (int j = 0; j < qualities.Length; j++) {
    124         qualities[j].Value -= tardiness[j].Value * vrptw.TardinessPenalty.Value;
     117      for (int j = 0; j < evaluations.Length; j++) {
     118        evaluations[j].Quality -= evaluations[j].Tardiness * vrptw.TardinessPenalty.Value;
    125119      }
    126120
    127121      int validCount = 0;
    128       for (int j = 0; j < qualities.Length; j++) {
    129         if (tardiness[j].Value == 0)
     122      for (int j = 0; j < evaluations.Length; j++) {
     123        if (evaluations[j].Tardiness == 0)
    130124          validCount++;
    131125      }
    132126
    133       double factor = 1.0 - ((double)validCount / (double)qualities.Length);
     127      double factor = 1.0 - ((double)validCount / (double)evaluations.Length);
    134128
    135129      double min = vrptw.TardinessPenalty.Value / (1 + sigma);
     
    142136        vrptw.CurrentTardinessPenalty.Value = maxPenalty;
    143137
    144       for (int j = 0; j < qualities.Length; j++) {
    145         qualities[j].Value += tardiness[j].Value * vrptw.CurrentTardinessPenalty.Value;
     138      for (int j = 0; j < evaluations.Length; j++) {
     139        evaluations[j].Quality += evaluations[j].Tardiness * vrptw.CurrentTardinessPenalty.Value;
    146140      }
    147141
    148       if (!results.ContainsKey("Current Tardiness Penalty")) {
    149         results.Add(new Result("Current Tardiness Penalty", new DoubleValue(vrptw.CurrentTardinessPenalty.Value)));
     142      if (!results.TryGetValue("Current Tardiness Penalty", out IResult res) || !(res.Value is DoubleValue)) {
     143        results.AddOrUpdateResult("Current Tardiness Penalty", new DoubleValue(vrptw.CurrentTardinessPenalty.Value));
    150144      } else {
    151         (results["Current Tardiness Penalty"].Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value;
     145        (res.Value as DoubleValue).Value = vrptw.CurrentTardinessPenalty.Value;
    152146      }
    153147
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/VRPSolution.cs

    r17698 r17710  
    2222using System;
    2323using System.Drawing;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    27 using HEAL.Attic;
    2827using HeuristicLab.Problems.VehicleRouting.Interfaces;
     28using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    2929
    3030namespace HeuristicLab.Problems.VehicleRouting {
     
    6666    }
    6767    [Storable]
    68     private DoubleValue quality;
    69     public DoubleValue Quality {
    70       get { return quality; }
     68    private VRPEvaluation evaluation;
     69    public VRPEvaluation Evaluation {
     70      get { return evaluation; }
    7171      set {
    72         if (quality != value) {
    73           if (quality != null) DeregisterQualityEvents();
    74           quality = value;
    75           if (quality != null) RegisterQualityEvents();
    76           OnQualityChanged();
     72        if (evaluation != value) {
     73          //if (evaluation != null) DeregisterQualityEvents();
     74          evaluation = value;
     75          //if (evaluation != null) RegisterQualityEvents();
     76          OnEvaluationChanged();
    7777        }
    7878      }
     
    8181    public VRPSolution() : base() { }
    8282
    83     public VRPSolution(IVRPProblemInstance problemInstance, IVRPEncodedSolution solution, DoubleValue quality)
     83    public VRPSolution(IVRPProblemInstance problemInstance, IVRPEncodedSolution solution, VRPEvaluation evaluation)
    8484      : base() {
    8585      this.problemInstance = problemInstance;
    8686      this.solution = solution;
    87       this.quality = quality;
     87      this.evaluation = evaluation;
    8888
    8989      Initialize();
     
    9696      if (problemInstance != null) RegisterProblemInstanceEvents();
    9797      if (solution != null) RegisterSolutionEvents();
    98       if (quality != null) RegisterQualityEvents();
     98      // TODO if (evaluation != null) RegisterQualityEvents();
    9999    }
    100100
     
    106106    private VRPSolution(VRPSolution original, Cloner cloner)
    107107      : base(original, cloner) {
    108       this.solution = (IVRPEncodedSolution)cloner.Clone(original.solution);
    109       this.quality = (DoubleValue)cloner.Clone(original.quality);
     108      this.solution = cloner.Clone(original.solution);
     109      this.evaluation = cloner.Clone(original.evaluation);
    110110
     111      // TODO: this seems very strange
    111112      if (original.ProblemInstance != null && cloner.ClonedObjectRegistered(original.ProblemInstance))
    112         this.ProblemInstance = (IVRPProblemInstance)cloner.Clone(original.ProblemInstance);
     113        this.ProblemInstance = cloner.Clone(original.ProblemInstance);
    113114      else
    114115        this.ProblemInstance = original.ProblemInstance;
     
    130131        changed(this, EventArgs.Empty);
    131132    }
    132     public event EventHandler QualityChanged;
    133     private void OnQualityChanged() {
    134       var changed = QualityChanged;
     133    public event EventHandler EvaluationChanged;
     134    private void OnEvaluationChanged() {
     135      var changed = EvaluationChanged;
    135136      if (changed != null)
    136137        changed(this, EventArgs.Empty);
     
    149150      Solution.ToStringChanged -= new EventHandler(Solution_ToStringChanged);
    150151    }
    151     private void RegisterQualityEvents() {
    152       Quality.ValueChanged += new EventHandler(Quality_ValueChanged);
    153     }
    154     private void DeregisterQualityEvents() {
    155       Quality.ValueChanged -= new EventHandler(Quality_ValueChanged);
    156     }
     152    //private void RegisterQualityEvents() {
     153    //  Quality.ValueChanged += new EventHandler(Quality_ValueChanged);
     154    //}
     155    //private void DeregisterQualityEvents() {
     156    //  Quality.ValueChanged -= new EventHandler(Quality_ValueChanged);
     157    //}
    157158
    158159    private void ProblemInstance_ToStringChanged(object sender, EventArgs e) {
     
    162163      OnSolutionChanged();
    163164    }
    164     private void Quality_ValueChanged(object sender, EventArgs e) {
    165       OnQualityChanged();
    166     }
     165    //private void Quality_ValueChanged(object sender, EventArgs e) {
     166    //  OnQualityChanged();
     167    //}
    167168    #endregion
    168169  }
Note: See TracChangeset for help on using the changeset viewer.