Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/22/20 03:45:41 (5 years ago)
Author:
abeham
Message:

#2521:

  • Fixed orienteering problem
  • Corrected ParameterizeOperators in all encoding-specific problem base classes
  • Added new interfaces and wiring code to IntegerVectorEncoding
Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r17526 r17620  
    9191    <Compile Include="Creators\GreedyOrienteeringTourCreator.cs" />
    9292    <Compile Include="Improvers\OrienteeringLocalImprovementOperator.cs" />
     93    <Compile Include="Interfaces\IOrienteeringOperator.cs" />
    9394    <Compile Include="Interfaces\IOrienteeringSolutionCreator.cs" />
    9495    <Compile Include="OrienteeringProblemData.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Improvers/OrienteeringLocalImprovementOperator.cs

    r17533 r17620  
    3939  [Item("OrienteeringLocalImprovementOperator", @"Implements the iterative improvement procedure described in Schilde M., Doerner K.F., Hartl R.F., Kiechle G. 2009. Metaheuristics for the bi-objective orienteering problem. Swarm Intelligence, Volume 3, Issue 3, pp 179-201.")]
    4040  [StorableType("92FA69B3-F243-4D12-A67A-AA1D7EBCD302")]
    41   public sealed class OrienteeringLocalImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator {
     41  public sealed class OrienteeringLocalImprovementOperator : SingleSuccessorOperator, IOrienteeringOperator, IIntegerVectorLocalImprovementOperator {
    4242
    4343    #region Parameter Properties
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Interfaces/IOrienteeringSolutionCreator.cs

    r17525 r17620  
    2121
    2222using HEAL.Attic;
    23 using HeuristicLab.Core;
    2423using HeuristicLab.Encodings.IntegerVectorEncoding;
    2524
    2625namespace HeuristicLab.Problems.Orienteering {
    2726  [StorableType("7E0D4527-4D8C-4FBA-BB3A-26F20B6463ED")]
    28   public interface IOrienteeringSolutionCreator : IIntegerVectorCreator {
    29     ILookupParameter<IOrienteeringProblemData> OrienteeringProblemDataParameter { get; }
     27  public interface IOrienteeringSolutionCreator : IIntegerVectorCreator, IOrienteeringOperator {
    3028  }
    3129}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r17614 r17620  
    2626using System.Threading;
    2727using HEAL.Attic;
    28 using HeuristicLab.Analysis;
    2928using HeuristicLab.Common;
    3029using HeuristicLab.Core;
    3130using HeuristicLab.Encodings.IntegerVectorEncoding;
    3231using HeuristicLab.Optimization;
    33 using HeuristicLab.Optimization.Operators;
    3432using HeuristicLab.Parameters;
    3533using HeuristicLab.Problems.Instances;
     
    6563      BestKnownSolutionParameter = cloner.Clone(original.BestKnownSolutionParameter);
    6664      BestOrienteeringSolutionParameter = cloner.Clone(original.BestOrienteeringSolutionParameter);
     65      RegisterEventHandlers();
    6766    }
    6867    public override IDeepCloneable Clone(Cloner cloner) {
     
    7675      Maximization = true;
    7776      Dimension = OrienteeringProblemData.Cities;
    78 
    79       InitializeOperators();
     77      Bounds = new Data.IntMatrix(new[,] { { 0, Dimension } }, @readonly: true);
     78
     79      var creator = new GreedyOrienteeringTourCreator();
     80      Operators.AddRange(new IItem[] { creator, new OrienteeringLocalImprovementOperator(), new OrienteeringShakingOperator() });
     81      SolutionCreatorParameter.Value = creator;
     82
     83      Parameterize();
     84      RegisterEventHandlers();
     85    }
     86
     87
     88    [StorableHook(HookType.AfterDeserialization)]
     89    private void AfterDeserialization() {
     90      RegisterEventHandlers();
    8091    }
    8192
     
    152163    private void OrienteeringProblemDataParameterOnValueChanged(object sender, EventArgs e) {
    153164      Dimension = OrienteeringProblemData.Cities;
    154     }
    155 
    156     protected override void OnEvaluatorChanged() {
    157       base.OnEvaluatorChanged();
    158       ParameterizeOperators();
    159     }
     165      Bounds = new Data.IntMatrix(new[,] { { 0, Dimension } }, @readonly: true);
     166    }
     167
    160168    protected override void DimensionOnChanged() {
    161169      base.DimensionOnChanged();
    162       if (Dimension != OrienteeringProblemData.Cities)
     170      if (Dimension != OrienteeringProblemData.Cities) {
    163171        Dimension = OrienteeringProblemData.Cities;
    164     }
    165 
    166     private void InitializeOperators() {
    167       ISolutionCreator creator;
    168       SolutionCreatorParameter.ValidValues.Add(creator = new GreedyOrienteeringTourCreator() {
    169         OrienteeringProblemDataParameter = { ActualName = OrienteeringProblemDataParameter.Name }
    170       });
    171       SolutionCreatorParameter.Value = creator;
    172 
    173       Operators.Add(new OrienteeringLocalImprovementOperator() {
    174         OrienteeringProblemDataParameter = { ActualName = OrienteeringProblemDataParameter.Name }
    175       });
    176       Operators.Add(new OrienteeringShakingOperator() {
    177         OrienteeringProblemDataParameter = { ActualName = OrienteeringProblemDataParameter.Name }
    178       });
    179       Operators.Add(new QualitySimilarityCalculator());
    180       Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    181 
    182       ParameterizeOperators();
    183     }
    184 
    185     private void ParameterizeOperators() {
    186       foreach (var op in Operators.OfType<OrienteeringLocalImprovementOperator>()) {
    187         op.IntegerVectorParameter.ActualName = Encoding.Name;
     172        Bounds = new Data.IntMatrix(new [,] { { 0, Dimension } }, @readonly: true);
     173      }
     174    }
     175
     176    protected override void ParameterizeOperators() {
     177      base.ParameterizeOperators();
     178      Parameterize();
     179    }
     180
     181    private void Parameterize() {
     182      foreach (var op in Operators.OfType<OrienteeringLocalImprovementOperator>())
    188183        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    189       }
    190       foreach (var op in Operators.OfType<OrienteeringShakingOperator>()) {
    191         op.IntegerVectorParameter.ActualName = Encoding.Name;
    192       }
    193       foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    194         similarityCalculator.SolutionVariableName = Encoding.Name;
    195         similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
    196       }
     184
     185      foreach (var op in Operators.OfType<IOrienteeringOperator>())
     186        op.OrienteeringProblemDataParameter.ActualName = OrienteeringProblemDataParameter.Name;
    197187    }
    198188
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Shakers/OrienteeringShakingOperator.cs

    r17533 r17620  
    4949  [Item("OrienteeringShakingOperator", @"Implements the shaking procedure described in Schilde M., Doerner K.F., Hartl R.F., Kiechle G. 2009. Metaheuristics for the bi-objective orienteering problem. Swarm Intelligence, Volume 3, Issue 3, pp 179-201.")]
    5050  [StorableType("D6654BD1-63CD-4057-89C8-36D1EE6EA7DF")]
    51   public sealed class OrienteeringShakingOperator : SingleSuccessorOperator, IMultiNeighborhoodShakingOperator, IStochasticOperator {
     51  public sealed class OrienteeringShakingOperator : SingleSuccessorOperator, IOrienteeringOperator, IIntegerVectorMultiNeighborhoodShakingOperator, IStochasticOperator {
    5252
    5353    #region Shaking Parameter Properties
Note: See TracChangeset for help on using the changeset viewer.