Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17704 for branches


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

#2521: worked on VRP

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

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaEncoding.cs

    r17699 r17704  
    2828using HeuristicLab.Optimization;
    2929using HeuristicLab.PluginInfrastructure;
     30using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3031
    3132namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    5455    static AlbaEncoding() {
    5556      encodingSpecificOperatorTypes = new List<Type>() {
    56           typeof (IAlbaOperator)
     57          typeof (IAlbaOperator),
     58          typeof (IVRPCreator),
     59          typeof (IMultiVRPOperator)
    5760      };
    5861    }
     
    6366      var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList();
    6467
     68      foreach (var op in newOperators.OfType<IMultiVRPOperator>().ToList()) {
     69        op.SetOperators(Operators.Concat(newOperators));
     70        if (!op.Operators.Any()) newOperators.Remove(op);
     71      }
     72      foreach (var op in Operators.OfType<IMultiVRPOperator>()) {
     73        op.SetOperators(newOperators);
     74      }
    6575      ConfigureOperators(newOperators);
    6676      foreach (var @operator in newOperators)
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs

    r17698 r17704  
    2020#endregion
    2121
     22using HEAL.Attic;
     23using HeuristicLab.Common;
     24using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2226using HeuristicLab.Optimization;
    23 using HeuristicLab.Core;
    24 using HEAL.Attic;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Common;
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Problems.VehicleRouting.Interfaces;
     
    3131  [Item("AlbaLambdaInterchangeLocalImprovementOperator", "Takes a solution and finds the local optimum with respect to the lambda interchange neighborhood by decending along the steepest gradient.")]
    3232  [StorableType("84981F03-B886-4ADD-8DB5-C12628404335")]
    33   public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator, ISingleObjectiveOperator {
     33  public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator, ISingleObjectiveOperator, IAlbaOperator {
    3434
    3535    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IMultiVRPOperator.cs

    r17226 r17704  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
    2727  [StorableType("4ED07F1F-AC5F-4771-8916-AF7DD576C581")]
    28   interface IMultiVRPOperator : IVRPOperator {
     28  interface IMultiVRPOperator : IVRPOperator, IMultiOperator {
    2929    void SetOperators(IEnumerable<IOperator> operators);
    3030  }
  • 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.