Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17620


Ignore:
Timestamp:
06/22/20 03:45:41 (4 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
Files:
4 added
21 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs

    r17612 r17620  
    7676    }
    7777
    78     protected override void OnEncodingChanged() {
    79       base.OnEncodingChanged();
     78    protected override void ParameterizeOperators() {
     79      base.ParameterizeOperators();
    8080      Parameterize();
    8181    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r17612 r17620  
    6767
    6868      Operators.Add(new HammingSimilarityCalculator());
     69      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
    6970      Operators.Add(new QualitySimilarityCalculator());
    7071      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     
    8182    }
    8283
     84    protected override void ParameterizeOperators() {
     85      base.ParameterizeOperators();
     86      Parameterize();
     87    }
     88
    8389    private void Parameterize() {
     90      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    8491      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    8592        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj

    r16876 r17620  
    146146    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterManipulator.cs" />
    147147    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterOperator.cs" />
     148    <Compile Include="Interfaces\IIntegerVectorLocalImprovementOperator.cs" />
     149    <Compile Include="Interfaces\IIntegerVectorSolutionOperator.cs" />
     150    <Compile Include="Interfaces\IIntegerVectorSolutionsOperator.cs" />
    148151    <Compile Include="Manipulators\UniformSomePositionsManipulator.cs" />
    149152    <Compile Include="Manipulators\RoundedNormalAllPositionsManipulator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs

    r17614 r17620  
    120120        typeof (IIntegerVectorStdDevStrategyParameterOperator),
    121121        typeof (IIntegerVectorMultiNeighborhoodShakingOperator),
     122        typeof (IIntegerVectorLocalImprovementOperator),
     123        typeof (IIntegerVectorSolutionOperator),
     124        typeof (IIntegerVectorSolutionsOperator)
    122125      };
    123126    }
     
    142145      ConfigureShakingOperators(operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>());
    143146      ConfigureStrategyVectorOperator(operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>());
     147      ConfigureLocalImprovementOperators(operators.OfType<IIntegerVectorLocalImprovementOperator>());
     148      ConfigureSolutionOperators(operators.OfType<IIntegerVectorSolutionOperator>());
     149      ConfigureSolutionsOperators(operators.OfType<IIntegerVectorSolutionsOperator>());
    144150    }
    145151
     
    217223      }
    218224    }
     225    private void ConfigureLocalImprovementOperators(IEnumerable<IIntegerVectorLocalImprovementOperator> localImprovementOperators) {
     226      // IIntegerVectorLocalImprovementOperator does not contain additional parameters (already contained in IIntegerVectorSolutionOperator)
     227    }
     228    private void ConfigureSolutionOperators(IEnumerable<IIntegerVectorSolutionOperator> solutionOperators) {
     229      foreach (var solutionOperator in solutionOperators) {
     230        solutionOperator.IntegerVectorParameter.ActualName = Name;
     231      }
     232    }
     233    private void ConfigureSolutionsOperators(IEnumerable<IIntegerVectorSolutionsOperator> solutionsOperators) {
     234      foreach (var solutionsOperator in solutionsOperators) {
     235        solutionsOperator.IntegerVectorsParameter.ActualName = Name;
     236      }
     237    }
    219238    #endregion
    220239
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs

    r17612 r17620  
    8686    }
    8787
    88     protected override void OnEncodingChanged() {
    89       base.OnEncodingChanged();
     88    protected override void ParameterizeOperators() {
     89      base.ParameterizeOperators();
    9090      Parameterize();
    9191    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs

    r17612 r17620  
    7272
    7373      Operators.Add(new HammingSimilarityCalculator());
     74      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
    7475      Operators.Add(new QualitySimilarityCalculator());
    7576      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     
    8687    }
    8788
    88     protected override void OnEncodingChanged() {
    89       base.OnEncodingChanged();
     89    protected override void ParameterizeOperators() {
     90      base.ParameterizeOperators();
    9091      Parameterize();
    9192    }
    9293
    9394    private void Parameterize() {
     95      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    9496      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    9597        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Interfaces/IIntegerVectorMultiNeighborhoodShakingOperator.cs

    r17226 r17620  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    23 using HEAL.Attic;
     24using HeuristicLab.Optimization;
    2425
    2526namespace HeuristicLab.Encodings.IntegerVectorEncoding {
    2627  [StorableType("2b21442c-735f-4df3-a163-4e3147cd11a5")]
    27   public interface IIntegerVectorMultiNeighborhoodShakingOperator : IIntegerVectorOperator {
     28  public interface IIntegerVectorMultiNeighborhoodShakingOperator : IIntegerVectorOperator, IMultiNeighborhoodShakingOperator {
    2829    ILookupParameter<IntegerVector> IntegerVectorParameter { get; }
    2930  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageMultiObjectiveProblem.cs

    r17587 r17620  
    7676    }
    7777
    78     protected override void OnEncodingChanged() {
    79       base.OnEncodingChanged();
     78    protected override void ParameterizeOperators() {
     79      base.ParameterizeOperators();
    8080      Parameterize();
    8181    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs

    r17587 r17620  
    6161
    6262      Operators.Add(new HammingSimilarityCalculator());
     63      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
    6364      Operators.Add(new QualitySimilarityCalculator());
    6465      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     
    7576    }
    7677
    77     protected override void OnEncodingChanged() {
    78       base.OnEncodingChanged();
     78    protected override void ParameterizeOperators() {
     79      base.ParameterizeOperators();
    7980      Parameterize();
    8081    }
    8182
    8283    private void Parameterize() {
     84      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    8385      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    8486        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationMultiObjectiveProblem.cs

    r17587 r17620  
    8282    }
    8383
    84     protected override void OnEncodingChanged() {
    85       base.OnEncodingChanged();
     84    protected override void ParameterizeOperators() {
     85      base.ParameterizeOperators();
    8686      Parameterize();
    8787    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationProblem.cs

    r17587 r17620  
    6767      Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the permutation problem.", Encoding.LengthParameter));
    6868      Parameters.Add(PermutationTypeRefParameter = new ReferenceParameter<EnumValue<PermutationTypes>>("Type", "The type of the permutation.", Encoding.PermutationTypeParameter));
     69     
    6970      Operators.Add(new HammingSimilarityCalculator());
     71      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
    7072      Operators.Add(new QualitySimilarityCalculator());
    7173      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     
    8183    }
    8284
    83     protected override void OnEncodingChanged() {
    84       base.OnEncodingChanged();
     85    protected override void ParameterizeOperators() {
     86      base.ParameterizeOperators();
    8587      Parameterize();
    8688    }
    8789
    8890    private void Parameterize() {
     91      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    8992      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    9093        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs

    r17587 r17620  
    8383    }
    8484
    85     protected override void OnEncodingChanged() {
    86       base.OnEncodingChanged();
     85    protected override void ParameterizeOperators() {
     86      base.ParameterizeOperators();
    8787      Parameterize();
    8888    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorProblem.cs

    r17587 r17620  
    6969
    7070      Operators.Add(new HammingSimilarityCalculator());
     71
     72      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
    7173      Operators.Add(new QualitySimilarityCalculator());
    7274      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     
    8385    }
    8486
    85     protected override void OnEncodingChanged() {
    86       base.OnEncodingChanged();
     87    protected override void ParameterizeOperators() {
     88      base.ParameterizeOperators();
    8789      Parameterize();
    8890    }
    8991
    9092    private void Parameterize() {
     93      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    9194      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    9295        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeMultiObjectiveProblem.cs

    r17614 r17620  
    9191    }
    9292
     93    protected override void ParameterizeOperators() {
     94      base.ParameterizeOperators();
     95      Parameterize();
     96    }
     97
    9398    private void Parameterize() {
    9499      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs

    r17614 r17620  
    2525using System.Linq;
    2626using HEAL.Attic;
     27using HeuristicLab.Analysis;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Data;
    3031using HeuristicLab.Optimization;
     32using HeuristicLab.Optimization.Operators;
    3133using HeuristicLab.Parameters;
    3234
     
    7779      Parameters.Add(TreeDepthRefParameter = new ReferenceParameter<IntValue>("TreeDepth", "The maximum depth of the tree.", Encoding.TreeDepthParameter));
    7880      Parameters.Add(GrammarRefParameter = new ReferenceParameter<ISymbolicExpressionGrammar>("Grammar", "The grammar that describes a valid tree.", Encoding.GrammarParameter));
     81     
     82      // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there)
     83      Operators.Add(new QualitySimilarityCalculator());
     84      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7985
    8086      Parameterize();
     
    103109    }
    104110
     111    protected override void ParameterizeOperators() {
     112      base.ParameterizeOperators();
     113      Parameterize();
     114    }
     115
    105116    private void Parameterize() {
     117      // TODO: this is done in base class as well (but operators are added at this level of the hierarchy)
    106118      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    107119        similarityCalculator.SolutionVariableName = Encoding.Name;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r17610 r17620  
    161161    }
    162162
    163     private void ParameterizeOperators() {
     163    protected override void ParameterizeOperators() {
     164      base.ParameterizeOperators();
     165      Parameterize();
     166    }
     167
     168    private void Parameterize() {
    164169      foreach (var op in Operators.OfType<IMultiObjectiveEvaluationOperator<TEncodedSolution>>())
    165170        op.EvaluateFunc = Evaluate;
  • 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.