Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4851


Ignore:
Timestamp:
11/19/10 13:54:50 (14 years ago)
Author:
svonolfe
Message:

Implemented review comments (#1236)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPImportDialog.cs

    r4847 r4851  
    5757        okButton.Enabled = true;
    5858
     59        tourFileTextBox.Text = string.Empty;
     60        tourFileName = string.Empty;
     61
    5962        format = (VRPFormat)(openVRPFileDialog.FilterIndex);
    6063      }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4847 r4851  
    109109        vrpSolutionView.Content = new VRPSolution(Content.Coordinates);
    110110      else {
    111         //call evaluator
    112         IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix",
    113           Content.DistanceMatrix);
    114 
    115         TourEvaluation eval = VRPEvaluator.Evaluate(
    116           Content.BestKnownSolution,
    117           Content.Vehicles,
    118           Content.DueTime,
    119           Content.ServiceTime,
    120           Content.ReadyTime,
    121           Content.Demand,
    122           Content.Capacity,
    123           Content.FleetUsageFactorParameter.Value,
    124           Content.TimeFactorParameter.Value,
    125           Content.DistanceFactorParameter.Value,
    126           Content.OverloadPenaltyParameter.Value,
    127           Content.TardinessPenaltyParameter.Value,
    128           Content.Coordinates,
    129           distMatrix,
    130           Content.UseDistanceMatrix);
    131 
    132         Content.DistanceMatrix = distMatrix.Value;
    133 
    134         vrpSolutionView.Content = new VRPSolution(Content.Coordinates,
    135           Content.BestKnownSolution,
    136           new DoubleValue(eval.Quality),
    137           new DoubleValue(eval.Distance),
    138           new DoubleValue(eval.Overload),
    139           new DoubleValue(eval.Tardiness),
    140           new DoubleValue(eval.TravelTime),
    141           new DoubleValue(eval.VehcilesUtilized),
    142           Content.DistanceMatrix,
    143           Content.UseDistanceMatrix,
    144           Content.ReadyTime,
    145           Content.DueTime,
    146           Content.ServiceTime);
     111        vrpSolutionView.Content = Content.BestKnownSolution;
    147112      }
    148113    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestVRPSolutionAnalyzer.cs

    r4722 r4851  
    8181      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    8282    }
     83    public LookupParameter<DoubleValue> BestKnownQualityParameter {
     84      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     85    }
     86    public LookupParameter<VRPSolution> BestKnownSolutionParameter {
     87      get { return (LookupParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
     88    }
    8389
    8490    [StorableConstructor]
     
    97103      Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
    98104
     105      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     106      Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
     107
    99108      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
    100109      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Distance", "The distances of the VRP solutions which should be analyzed."));
     
    111120    }
    112121
     122    [StorableHook(HookType.AfterDeserialization)]
     123    private void AfterDeserializationHook() {
     124      #region Backwards Compatibility
     125      if (!Parameters.ContainsKey("BestKnownQuality")) {
     126        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     127      }
     128      if (!Parameters.ContainsKey("BestKnownSolution")) {
     129        Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
     130      }
     131      #endregion
     132    }
     133
    113134    public override IOperation Apply() {
    114135      DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
     
    121142      ItemArray<DoubleValue> travelTimes = TravelTimeParameter.ActualValue;
    122143      ItemArray<DoubleValue> vehiclesUtilizations = VehiclesUtilizedParameter.ActualValue;
     144
     145      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
    123146
    124147      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
     
    159182      }
    160183
     184      if (bestKnownQuality == null ||
     185          qualities[i].Value < bestKnownQuality.Value) {
     186        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
     187        BestKnownSolutionParameter.ActualValue = (VRPSolution)solution.Clone();
     188      }
     189
    161190      return base.Apply();
    162191    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4847 r4851  
    114114      get { return BestKnownQualityParameter; }
    115115    }
    116     public OptionalValueParameter<IVRPEncoding> BestKnownSolutionParameter {
    117       get { return (OptionalValueParameter<IVRPEncoding>)Parameters["BestKnownSolution"]; }
     116    public OptionalValueParameter<VRPSolution> BestKnownSolutionParameter {
     117      get { return (OptionalValueParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
    118118    }
    119119    #endregion
     
    160160      set { BestKnownQualityParameter.Value = value; }
    161161    }
    162     public IVRPEncoding BestKnownSolution {
     162    public VRPSolution BestKnownSolution {
    163163      get { return BestKnownSolutionParameter.Value; }
    164164      set { BestKnownSolutionParameter.Value = value; }
     
    219219      Parameters.Add(new ValueParameter<DoubleArray>("ServiceTime", "The service time of each customer.", new DoubleArray()));
    220220      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
    221       Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this TSP instance."));
     221      Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
    222222      Parameters.Add(new ValueParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation.", new DoubleValue(100)));
    223223      Parameters.Add(new ValueParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation.", new DoubleValue(0)));
     
    440440      #region Backwards Compatibility
    441441      if (!Parameters.ContainsKey("BestKnownSolution")) {
    442         Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this TSP instance."));
     442        Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this TSP instance."));
    443443      }
    444444      #endregion
     
    673673      if (BestKnownSolution != null) {
    674674        //call evaluator
    675         IValueParameter<DoubleMatrix> distMatrix = new ValueParameter<DoubleMatrix>("DistMatrix",
     675        IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix",
    676676          DistanceMatrix);
    677677
    678678        TourEvaluation eval = VRPEvaluator.Evaluate(
    679           BestKnownSolution,
     679          BestKnownSolution.Solution,
    680680          Vehicles,
    681681          DueTime,
     
    695695        DistanceMatrix = distMatrix.Value;
    696696
     697        BestKnownSolution.DistanceMatrix = DistanceMatrix;
     698        BestKnownSolution.Distance = new DoubleValue(eval.Distance);
     699        BestKnownSolution.Overload = new DoubleValue(eval.Overload);
     700        BestKnownSolution.Quality = new DoubleValue(eval.Quality);
     701        BestKnownSolution.Tardiness = new DoubleValue(eval.Tardiness);
     702        BestKnownSolution.TravelTime = new DoubleValue(eval.TravelTime);
     703        BestKnownSolution.VehicleUtilization = new DoubleValue(eval.VehcilesUtilized);
     704
    697705        BestKnownQuality = new DoubleValue(eval.Quality);
    698706      } else {
     
    717725
    718726      if (cities != Coordinates.Rows - 1)
    719         ErrorHandling.ShowErrorDialog(new Exception("Invalid solution"));
    720       else
    721         BestKnownSolutionParameter.Value = encoding;
     727        ErrorHandling.ShowErrorDialog(new Exception("The optimal solution does not seem to correspond  with the problem data."));
     728      else {
     729        VRPSolution solution = new VRPSolution();
     730        solution.Solution = encoding;
     731        solution.Coordinates = Coordinates;
     732        solution.DistanceMatrix = DistanceMatrix;
     733        solution.ReadyTime = ReadyTime;
     734        solution.DueTime = DueTime;
     735        solution.ServiceTime = ServiceTime;
     736        solution.UseDistanceMatrix = UseDistanceMatrix;
     737
     738        BestKnownSolutionParameter.Value = solution;
     739      }
    722740    }
    723741
Note: See TracChangeset for help on using the changeset viewer.