Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/10 15:43:21 (14 years ago)
Author:
svonolfe
Message:

Merged changes from trunk into branch (#1177)

File:
1 edited

Legend:

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

    r4752 r4860  
    6262    }
    6363
     64    public LookupParameter<DoubleValue> BestKnownQualityParameter {
     65      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     66    }
     67    public LookupParameter<VRPSolution> BestKnownSolutionParameter {
     68      get { return (LookupParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
     69    }
     70
    6471    [StorableConstructor]
    6572    private BestVRPSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     
    6976        Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    7077        Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("VRPTours", "The VRP tours which should be evaluated."));
     78
     79        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     80        Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
    7181
    7282        Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
     
    8696    }
    8797
     98    [StorableHook(HookType.AfterDeserialization)]
     99    private void AfterDeserializationHook() {
     100      #region Backwards Compatibility
     101      if (!Parameters.ContainsKey("BestKnownQuality")) {
     102        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     103      }
     104      if (!Parameters.ContainsKey("BestKnownSolution")) {
     105        Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
     106      }
     107      #endregion
     108    }
     109
    88110    public override IOperation Apply() {
    89111      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
     
    96118
    97119      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
     120
     121      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
    98122
    99123      IVRPEncoding best = solutions[i].Clone() as IVRPEncoding;
     
    116140      }
    117141
     142      if (bestKnownQuality == null ||
     143          qualities[i].Value < bestKnownQuality.Value) {
     144        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
     145        BestKnownSolutionParameter.ActualValue = (VRPSolution)solution.Clone();
     146      }
     147
    118148      return base.Apply();
    119149    }
Note: See TracChangeset for help on using the changeset viewer.