- Timestamp:
- 06/22/20 03:45:41 (5 years ago)
- 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 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.