Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/20 23:36:25 (4 years ago)
Author:
abeham
Message:

#2521: worked on VRP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r17699 r17704  
    3939using HeuristicLab.Problems.VehicleRouting.Interpreters;
    4040using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    41 using HeuristicLab.Problems.VehicleRouting.Variants;
    4241
    4342namespace HeuristicLab.Problems.VehicleRouting {
     
    151150
    152151    void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) {
    153       InitializeOperators();
    154       AttachProblemInstanceEventHandlers();
    155 
    156       OnOperatorsChanged();
     152      //InitializeOperators();
     153      AttachProblemInstanceEventHandlers();
     154
     155      //OnOperatorsChanged();
    157156    }
    158157
     
    167166
    168167    private void InitializeOperators() {
    169       Operators.Clear();
    170 
    171       if (ProblemInstance != null) {
    172         Operators.AddRange(
    173         ProblemInstance.Operators.Concat(
    174           ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name));
    175         Operators.Add(new VRPSimilarityCalculator());
    176         Operators.Add(new QualitySimilarityCalculator());
    177         Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    178 
    179         IVRPCreator defaultCreator = null;
    180         /*foreach (IVRPCreator creator in Operators.Where(o => o is IVRPCreator)) {
    181           solutionCreatorParameter.ValidValues.Add(creator);
    182           if (creator is Encodings.Alba.RandomCreator)
    183             defaultCreator = creator;
    184         }*/
    185         Operators.Add(new AlbaLambdaInterchangeLocalImprovementOperator());
    186         /*if (defaultCreator != null)
    187           solutionCreatorParameter.Value = defaultCreator;*/
    188       }
    189 
    190       Parameterize();
     168      Operators.Add(new VRPSimilarityCalculator());
     169      Operators.Add(new QualitySimilarityCalculator());
     170      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    191171    }
    192172
     
    197177
    198178    private void Parameterize() {
    199       foreach (IOperator op in Operators.OfType<IOperator>()) {
    200         if (op is IMultiVRPOperator) {
    201           (op as IMultiVRPOperator).SetOperators(Operators.OfType<IOperator>());
    202         }
    203       }
    204       if (Parameters.ContainsKey("ProblemInstance") && ProblemInstance != null) {
    205         foreach (ISingleObjectiveImprovementOperator op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
    206           //op.SolutionParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
    207           op.SolutionParameter.Hidden = true;
    208         }
    209         foreach (ISingleObjectivePathRelinker op in Operators.OfType<ISingleObjectivePathRelinker>()) {
    210           //op.ParentsParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
    211           op.ParentsParameter.Hidden = true;
    212         }
    213         foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) {
    214           //op.SolutionVariableName = SolutionCreator.VRPToursParameter.ActualName;
    215           op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
    216           var calc = op as VRPSimilarityCalculator;
    217           if (calc != null) calc.ProblemInstance = ProblemInstance;
    218         }
     179      foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) {
     180        op.SolutionVariableName = Encoding.Name;
     181        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
     182        var calc = op as VRPSimilarityCalculator;
     183        if (calc != null) calc.ProblemInstance = ProblemInstance;
    219184      }
    220185    }
Note: See TracChangeset for help on using the changeset viewer.