Free cookie consent management tool by TermsFeed Policy Generator

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

Implemented review comments (#1236)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.