Changeset 12102
- Timestamp:
- 03/02/15 16:11:20 (10 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 4 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs
r12069 r12102 103 103 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 104 104 } 105 public IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {106 get { return (IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }105 public IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 106 get { return (IConstrainedValueParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 107 107 } 108 108 #endregion … … 173 173 set { MaximumGenerationsParameter.Value = value; } 174 174 } 175 public IS ingleObjectiveSolutionSimilarityCalculator SimilarityCalculator {175 public ISolutionSimilarityCalculator SimilarityCalculator { 176 176 get { return SimilarityCalculatorParameter.Value; } 177 177 set { SimilarityCalculatorParameter.Value = value; } … … 204 204 if (!Parameters.ContainsKey("ReevaluateElites")) { 205 205 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 206 } 207 if (Parameters.ContainsKey("SimilarityCalculator")) { 208 var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; 209 Parameters.Remove(oldParameter); 210 var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues)); 211 var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType()); 212 newParameter.Value = selectedSimilarityCalculator; 213 Parameters.Add(newParameter); 206 214 } 207 215 #endregion … … 234 242 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 235 243 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 236 Parameters.Add(new ConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));244 Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 237 245 238 246 RandomCreator randomCreator = new RandomCreator(); … … 448 456 } 449 457 private void ParameterizeSimilarityCalculators() { 450 foreach (IS ingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {458 foreach (ISolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 451 459 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 452 460 } … … 493 501 } 494 502 private void UpdateSimilarityCalculators() { 495 IS ingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;503 ISolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 496 504 SimilarityCalculatorParameter.ValidValues.Clear(); 497 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 498 499 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 500 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator()); 501 502 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 505 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 506 507 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 503 508 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 504 509 505 510 if (oldSimilarityCalculator != null) { 506 IS ingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());511 ISolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 507 512 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 508 513 else oldSimilarityCalculator = null; -
trunk/sources/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs
r12069 r12102 88 88 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 89 89 } 90 public IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {91 get { return (IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }90 public IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 91 get { return (IConstrainedValueParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 92 92 } 93 93 #endregion … … 138 138 set { SetSeedRandomlyParameter.Value = value; } 139 139 } 140 public IS ingleObjectiveSolutionSimilarityCalculator SimilarityCalculator {140 public ISolutionSimilarityCalculator SimilarityCalculator { 141 141 get { return SimilarityCalculatorParameter.Value; } 142 142 set { SimilarityCalculatorParameter.Value = value; } … … 160 160 [StorableHook(HookType.AfterDeserialization)] 161 161 private void AfterDeserialization() { 162 // BackwardsCompatibility3.3 163 #region Backwards compatible code, remove with 3.4 164 if (Parameters.ContainsKey("SimilarityCalculator")) { 165 var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; 166 Parameters.Remove(oldParameter); 167 var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues)); 168 var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType()); 169 newParameter.Value = selectedSimilarityCalculator; 170 Parameters.Add(newParameter); 171 } 172 #endregion 162 173 Initialize(); 163 174 } … … 184 195 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 185 196 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 186 Parameters.Add(new ConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));197 Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 187 198 #endregion 188 199 … … 390 401 } 391 402 private void UpdateSimilarityCalculators() { 392 IS ingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;403 ISolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 393 404 SimilarityCalculatorParameter.ValidValues.Clear(); 394 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 395 396 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 397 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 398 399 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 405 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 406 407 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 400 408 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 401 409 402 410 if (oldSimilarityCalculator != null) { 403 IS ingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());411 ISolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 404 412 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 405 413 else oldSimilarityCalculator = null; … … 447 455 } 448 456 private void ParameterizeSimilarityCalculators() { 449 foreach (IS ingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {457 foreach (ISolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 450 458 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 451 459 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r11963 r12102 148 148 <DependentUpon>CreateNewSingleEncodingDialog.cs</DependentUpon> 149 149 </Compile> 150 <Compile Include="IS ingleObjectiveSolutionSimilarityCalculatorView.cs">151 <SubType>UserControl</SubType> 152 </Compile> 153 <Compile Include="IS ingleObjectiveSolutionSimilarityCalculatorView.Designer.cs">154 <DependentUpon>IS ingleObjectiveSolutionSimilarityCalculatorView.cs</DependentUpon>150 <Compile Include="ISolutionSimilarityCalculatorView.cs"> 151 <SubType>UserControl</SubType> 152 </Compile> 153 <Compile Include="ISolutionSimilarityCalculatorView.Designer.cs"> 154 <DependentUpon>ISolutionSimilarityCalculatorView.cs</DependentUpon> 155 155 </Compile> 156 156 <Compile Include="ExperimentListView.cs"> … … 159 159 <Compile Include="ExperimentListView.Designer.cs"> 160 160 <DependentUpon>ExperimentListView.cs</DependentUpon> 161 </Compile>162 <Compile Include="ISimilarityCalculatorView.cs">163 <SubType>UserControl</SubType>164 </Compile>165 <Compile Include="ISimilarityCalculatorView.Designer.cs">166 <DependentUpon>ISimilarityCalculatorView.cs</DependentUpon>167 161 </Compile> 168 162 <Compile Include="MultiEncodingView.cs"> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ISingleObjectiveSolutionSimilarityCalculator.cs
r12085 r12102 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.Optimization { 25 // use HeuristicLab.Optimization.ISolutionSimilarityCalculator instead 26 // BackwardsCompatibility3.3 27 #region Backwards compatible code, remove with 3.4 23 28 /// <summary> 24 29 /// An interface which represents an operator for similarity calculation between single objective solutions. 25 30 /// </summary> 31 [Obsolete("use HeuristicLab.Optimization.ISolutionSimilarityCalculator instead")] 26 32 public interface ISingleObjectiveSolutionSimilarityCalculator : ISolutionSimilarityCalculator, ISingleObjectiveOperator { 27 33 28 34 } 35 #endregion 29 36 } -
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r12087 r12102 29 29 using HeuristicLab.Encodings.BinaryVectorEncoding; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 251 252 Operators.Add(new KnapsackSimultaneousPathRelinker()); 252 253 Operators.Add(new KnapsackSimilarityCalculator()); 254 Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.BinaryVectorParameter.ActualName }); 255 Operators.Add(new NoSimilarityCalculator()); 253 256 254 257 Operators.Add(new BestKnapsackSolutionAnalyzer()); -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r12087 r12102 29 29 using HeuristicLab.Encodings.RealVectorEncoding; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 260 261 Operators.Add(new SingleObjectiveTestFunctionPathRelinker()); 261 262 Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator()); 263 Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.RealVectorParameter.ActualName }); 264 Operators.Add(new NoSimilarityCalculator()); 262 265 263 266 Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer()); … … 315 318 try { 316 319 BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value); 317 } catch (ArgumentException e) { 320 } 321 catch (ArgumentException e) { 318 322 ErrorHandling.ShowErrorDialog(e); 319 323 ProblemSize.Value = Evaluator.MinimumProblemSize; -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r12087 r12102 30 30 using HeuristicLab.Encodings.PermutationEncoding; 31 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Optimization.Operators; 32 33 using HeuristicLab.Parameters; 33 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 233 234 Operators.Add(new TSPSimultaneousPathRelinker()); 234 235 Operators.Add(new TSPSimilarityCalculator()); 236 Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.PermutationParameter.ActualName }); 237 Operators.Add(new NoSimilarityCalculator()); 235 238 236 239 Operators.Add(new BestTSPSolutionAnalyzer()); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r12087 r12102 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 253 254 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); 254 255 Operators.Add(new VRPSimilarityCalculator()); 256 Operators.Add(new QualitySimilarityCalculator()); 257 Operators.Add(new NoSimilarityCalculator()); 255 258 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 256 259 … … 284 287 op.ParentsParameter.Hidden = true; 285 288 } 286 foreach ( VRPSimilarityCalculator op in Operators.OfType<VRPSimilarityCalculator>()) {289 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 287 290 op.SolutionVariableName = SolutionCreator.VRPToursParameter.ActualName; 288 291 op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 289 op.ProblemInstance = ProblemInstance; 292 var calc = op as VRPSimilarityCalculator; 293 if (calc != null) calc.ProblemInstance = ProblemInstance; 290 294 } 291 295 }
Note: See TracChangeset
for help on using the changeset viewer.