Changeset 17620
- Timestamp:
- 06/22/20 03:45:41 (4 years ago)
- 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 76 76 } 77 77 78 protected override void OnEncodingChanged() {79 base. OnEncodingChanged();78 protected override void ParameterizeOperators() { 79 base.ParameterizeOperators(); 80 80 Parameterize(); 81 81 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
r17612 r17620 67 67 68 68 Operators.Add(new HammingSimilarityCalculator()); 69 // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there) 69 70 Operators.Add(new QualitySimilarityCalculator()); 70 71 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); … … 81 82 } 82 83 84 protected override void ParameterizeOperators() { 85 base.ParameterizeOperators(); 86 Parameterize(); 87 } 88 83 89 private void Parameterize() { 90 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 84 91 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 85 92 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj
r16876 r17620 146 146 <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterManipulator.cs" /> 147 147 <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterOperator.cs" /> 148 <Compile Include="Interfaces\IIntegerVectorLocalImprovementOperator.cs" /> 149 <Compile Include="Interfaces\IIntegerVectorSolutionOperator.cs" /> 150 <Compile Include="Interfaces\IIntegerVectorSolutionsOperator.cs" /> 148 151 <Compile Include="Manipulators\UniformSomePositionsManipulator.cs" /> 149 152 <Compile Include="Manipulators\RoundedNormalAllPositionsManipulator.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs
r17614 r17620 120 120 typeof (IIntegerVectorStdDevStrategyParameterOperator), 121 121 typeof (IIntegerVectorMultiNeighborhoodShakingOperator), 122 typeof (IIntegerVectorLocalImprovementOperator), 123 typeof (IIntegerVectorSolutionOperator), 124 typeof (IIntegerVectorSolutionsOperator) 122 125 }; 123 126 } … … 142 145 ConfigureShakingOperators(operators.OfType<IIntegerVectorMultiNeighborhoodShakingOperator>()); 143 146 ConfigureStrategyVectorOperator(operators.OfType<IIntegerVectorStdDevStrategyParameterOperator>()); 147 ConfigureLocalImprovementOperators(operators.OfType<IIntegerVectorLocalImprovementOperator>()); 148 ConfigureSolutionOperators(operators.OfType<IIntegerVectorSolutionOperator>()); 149 ConfigureSolutionsOperators(operators.OfType<IIntegerVectorSolutionsOperator>()); 144 150 } 145 151 … … 217 223 } 218 224 } 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 } 219 238 #endregion 220 239 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs
r17612 r17620 86 86 } 87 87 88 protected override void OnEncodingChanged() {89 base. OnEncodingChanged();88 protected override void ParameterizeOperators() { 89 base.ParameterizeOperators(); 90 90 Parameterize(); 91 91 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs
r17612 r17620 72 72 73 73 Operators.Add(new HammingSimilarityCalculator()); 74 // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there) 74 75 Operators.Add(new QualitySimilarityCalculator()); 75 76 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); … … 86 87 } 87 88 88 protected override void OnEncodingChanged() {89 base. OnEncodingChanged();89 protected override void ParameterizeOperators() { 90 base.ParameterizeOperators(); 90 91 Parameterize(); 91 92 } 92 93 93 94 private void Parameterize() { 95 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 94 96 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 95 97 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Interfaces/IIntegerVectorMultiNeighborhoodShakingOperator.cs
r17226 r17620 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Core; 23 using H EAL.Attic;24 using HeuristicLab.Optimization; 24 25 25 26 namespace HeuristicLab.Encodings.IntegerVectorEncoding { 26 27 [StorableType("2b21442c-735f-4df3-a163-4e3147cd11a5")] 27 public interface IIntegerVectorMultiNeighborhoodShakingOperator : IIntegerVectorOperator {28 public interface IIntegerVectorMultiNeighborhoodShakingOperator : IIntegerVectorOperator, IMultiNeighborhoodShakingOperator { 28 29 ILookupParameter<IntegerVector> IntegerVectorParameter { get; } 29 30 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageMultiObjectiveProblem.cs
r17587 r17620 76 76 } 77 77 78 protected override void OnEncodingChanged() {79 base. OnEncodingChanged();78 protected override void ParameterizeOperators() { 79 base.ParameterizeOperators(); 80 80 Parameterize(); 81 81 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs
r17587 r17620 61 61 62 62 Operators.Add(new HammingSimilarityCalculator()); 63 // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there) 63 64 Operators.Add(new QualitySimilarityCalculator()); 64 65 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); … … 75 76 } 76 77 77 protected override void OnEncodingChanged() {78 base. OnEncodingChanged();78 protected override void ParameterizeOperators() { 79 base.ParameterizeOperators(); 79 80 Parameterize(); 80 81 } 81 82 82 83 private void Parameterize() { 84 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 83 85 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 84 86 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationMultiObjectiveProblem.cs
r17587 r17620 82 82 } 83 83 84 protected override void OnEncodingChanged() {85 base. OnEncodingChanged();84 protected override void ParameterizeOperators() { 85 base.ParameterizeOperators(); 86 86 Parameterize(); 87 87 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationProblem.cs
r17587 r17620 67 67 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the permutation problem.", Encoding.LengthParameter)); 68 68 Parameters.Add(PermutationTypeRefParameter = new ReferenceParameter<EnumValue<PermutationTypes>>("Type", "The type of the permutation.", Encoding.PermutationTypeParameter)); 69 69 70 Operators.Add(new HammingSimilarityCalculator()); 71 // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there) 70 72 Operators.Add(new QualitySimilarityCalculator()); 71 73 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); … … 81 83 } 82 84 83 protected override void OnEncodingChanged() {84 base. OnEncodingChanged();85 protected override void ParameterizeOperators() { 86 base.ParameterizeOperators(); 85 87 Parameterize(); 86 88 } 87 89 88 90 private void Parameterize() { 91 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 89 92 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 90 93 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs
r17587 r17620 83 83 } 84 84 85 protected override void OnEncodingChanged() {86 base. OnEncodingChanged();85 protected override void ParameterizeOperators() { 86 base.ParameterizeOperators(); 87 87 Parameterize(); 88 88 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorProblem.cs
r17587 r17620 69 69 70 70 Operators.Add(new HammingSimilarityCalculator()); 71 72 // TODO: These should be added in the SingleObjectiveProblem base class (if they were accessible from there) 71 73 Operators.Add(new QualitySimilarityCalculator()); 72 74 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); … … 83 85 } 84 86 85 protected override void OnEncodingChanged() {86 base. OnEncodingChanged();87 protected override void ParameterizeOperators() { 88 base.ParameterizeOperators(); 87 89 Parameterize(); 88 90 } 89 91 90 92 private void Parameterize() { 93 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 91 94 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 92 95 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeMultiObjectiveProblem.cs
r17614 r17620 91 91 } 92 92 93 protected override void ParameterizeOperators() { 94 base.ParameterizeOperators(); 95 Parameterize(); 96 } 97 93 98 private void Parameterize() { 94 99 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs
r17614 r17620 25 25 using System.Linq; 26 26 using HEAL.Attic; 27 using HeuristicLab.Analysis; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Core; 29 30 using HeuristicLab.Data; 30 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Optimization.Operators; 31 33 using HeuristicLab.Parameters; 32 34 … … 77 79 Parameters.Add(TreeDepthRefParameter = new ReferenceParameter<IntValue>("TreeDepth", "The maximum depth of the tree.", Encoding.TreeDepthParameter)); 78 80 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>())); 79 85 80 86 Parameterize(); … … 103 109 } 104 110 111 protected override void ParameterizeOperators() { 112 base.ParameterizeOperators(); 113 Parameterize(); 114 } 115 105 116 private void Parameterize() { 117 // TODO: this is done in base class as well (but operators are added at this level of the hierarchy) 106 118 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 107 119 similarityCalculator.SolutionVariableName = Encoding.Name; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r17610 r17620 161 161 } 162 162 163 private void ParameterizeOperators() { 163 protected override void ParameterizeOperators() { 164 base.ParameterizeOperators(); 165 Parameterize(); 166 } 167 168 private void Parameterize() { 164 169 foreach (var op in Operators.OfType<IMultiObjectiveEvaluationOperator<TEncodedSolution>>()) 165 170 op.EvaluateFunc = Evaluate; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj
r17526 r17620 91 91 <Compile Include="Creators\GreedyOrienteeringTourCreator.cs" /> 92 92 <Compile Include="Improvers\OrienteeringLocalImprovementOperator.cs" /> 93 <Compile Include="Interfaces\IOrienteeringOperator.cs" /> 93 94 <Compile Include="Interfaces\IOrienteeringSolutionCreator.cs" /> 94 95 <Compile Include="OrienteeringProblemData.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Improvers/OrienteeringLocalImprovementOperator.cs
r17533 r17620 39 39 [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.")] 40 40 [StorableType("92FA69B3-F243-4D12-A67A-AA1D7EBCD302")] 41 public sealed class OrienteeringLocalImprovementOperator : SingleSuccessorOperator, I LocalImprovementOperator {41 public sealed class OrienteeringLocalImprovementOperator : SingleSuccessorOperator, IOrienteeringOperator, IIntegerVectorLocalImprovementOperator { 42 42 43 43 #region Parameter Properties -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Interfaces/IOrienteeringSolutionCreator.cs
r17525 r17620 21 21 22 22 using HEAL.Attic; 23 using HeuristicLab.Core;24 23 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 24 26 25 namespace HeuristicLab.Problems.Orienteering { 27 26 [StorableType("7E0D4527-4D8C-4FBA-BB3A-26F20B6463ED")] 28 public interface IOrienteeringSolutionCreator : IIntegerVectorCreator { 29 ILookupParameter<IOrienteeringProblemData> OrienteeringProblemDataParameter { get; } 27 public interface IOrienteeringSolutionCreator : IIntegerVectorCreator, IOrienteeringOperator { 30 28 } 31 29 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r17614 r17620 26 26 using System.Threading; 27 27 using HEAL.Attic; 28 using HeuristicLab.Analysis;29 28 using HeuristicLab.Common; 30 29 using HeuristicLab.Core; 31 30 using HeuristicLab.Encodings.IntegerVectorEncoding; 32 31 using HeuristicLab.Optimization; 33 using HeuristicLab.Optimization.Operators;34 32 using HeuristicLab.Parameters; 35 33 using HeuristicLab.Problems.Instances; … … 65 63 BestKnownSolutionParameter = cloner.Clone(original.BestKnownSolutionParameter); 66 64 BestOrienteeringSolutionParameter = cloner.Clone(original.BestOrienteeringSolutionParameter); 65 RegisterEventHandlers(); 67 66 } 68 67 public override IDeepCloneable Clone(Cloner cloner) { … … 76 75 Maximization = true; 77 76 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(); 80 91 } 81 92 … … 152 163 private void OrienteeringProblemDataParameterOnValueChanged(object sender, EventArgs e) { 153 164 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 160 168 protected override void DimensionOnChanged() { 161 169 base.DimensionOnChanged(); 162 if (Dimension != OrienteeringProblemData.Cities) 170 if (Dimension != OrienteeringProblemData.Cities) { 163 171 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>()) 188 183 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; 197 187 } 198 188 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/Shakers/OrienteeringShakingOperator.cs
r17533 r17620 49 49 [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.")] 50 50 [StorableType("D6654BD1-63CD-4057-89C8-36D1EE6EA7DF")] 51 public sealed class OrienteeringShakingOperator : SingleSuccessorOperator, I MultiNeighborhoodShakingOperator, IStochasticOperator {51 public sealed class OrienteeringShakingOperator : SingleSuccessorOperator, IOrienteeringOperator, IIntegerVectorMultiNeighborhoodShakingOperator, IStochasticOperator { 52 52 53 53 #region Shaking Parameter Properties
Note: See TracChangeset
for help on using the changeset viewer.