Changeset 3303 for trunk/sources
- Timestamp:
- 04/12/10 01:29:35 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r3280 r3303 283 283 private void InitializeSelectors() { 284 284 selectors = new List<ISelector>(); 285 if (ApplicationManager.Manager != null)selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name));285 selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)); 286 286 ParameterizeSelectors(); 287 287 } … … 300 300 } 301 301 private void UpdateSelectors() { 302 if (ApplicationManager.Manager != null) { 303 ISelector oldSelector = SelectorParameter.Value; 304 SelectorParameter.ValidValues.Clear(); 305 foreach (ISelector selector in Selectors.OrderBy(x => x.Name)) 306 SelectorParameter.ValidValues.Add(selector); 307 if (oldSelector != null) { 308 ISelector selector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType()); 309 if (selector != null) SelectorParameter.Value = selector; 310 } 302 ISelector oldSelector = SelectorParameter.Value; 303 SelectorParameter.ValidValues.Clear(); 304 foreach (ISelector selector in Selectors.OrderBy(x => x.Name)) 305 SelectorParameter.ValidValues.Add(selector); 306 if (oldSelector != null) { 307 ISelector selector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType()); 308 if (selector != null) SelectorParameter.Value = selector; 311 309 } 312 310 } 313 311 private void UpdateCrossovers() { 314 if (ApplicationManager.Manager != null) { 315 ICrossover oldCrossover = CrossoverParameter.Value; 316 CrossoverParameter.ValidValues.Clear(); 317 foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) 318 CrossoverParameter.ValidValues.Add(crossover); 319 if (oldCrossover != null) { 320 ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType()); 321 if (crossover != null) CrossoverParameter.Value = crossover; 322 } 312 ICrossover oldCrossover = CrossoverParameter.Value; 313 CrossoverParameter.ValidValues.Clear(); 314 foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) 315 CrossoverParameter.ValidValues.Add(crossover); 316 if (oldCrossover != null) { 317 ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType()); 318 if (crossover != null) CrossoverParameter.Value = crossover; 323 319 } 324 320 } 325 321 private void UpdateMutators() { 326 if (ApplicationManager.Manager != null) { 327 IManipulator oldMutator = MutatorParameter.Value; 328 MutatorParameter.ValidValues.Clear(); 329 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 330 MutatorParameter.ValidValues.Add(mutator); 331 if (oldMutator != null) { 332 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 333 if (mutator != null) MutatorParameter.Value = mutator; 334 } 322 IManipulator oldMutator = MutatorParameter.Value; 323 MutatorParameter.ValidValues.Clear(); 324 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 325 MutatorParameter.ValidValues.Add(mutator); 326 if (oldMutator != null) { 327 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 328 if (mutator != null) MutatorParameter.Value = mutator; 335 329 } 336 330 } -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/Tests/UnitTest.cs
r3265 r3303 23 23 using System.Threading; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Optimization; 26 27 using HeuristicLab.Persistence.Default.Xml; … … 90 91 trigger.WaitOne(); 91 92 TestContext.WriteLine("Runtime: {0}", ga.ExecutionTime.ToString()); 93 94 double expectedBestQuality = 12332.0; 95 double expectedAverageQuality = 13123.2; 96 double expectedWorstQuality = 14538.0; 97 double bestQuality = (ga.Results["Current Best Quality"].Value as DoubleValue).Value; 98 double averageQuality = (ga.Results["Current Average Quality"].Value as DoubleValue).Value; 99 double worstQuality = (ga.Results["Current Worst Quality"].Value as DoubleValue).Value; 100 101 TestContext.WriteLine(""); 102 TestContext.WriteLine("Current Best Quality: {0} (should be {1})", bestQuality, expectedBestQuality); 103 TestContext.WriteLine("Current Average Quality: {0} (should be {1})", averageQuality, expectedAverageQuality); 104 TestContext.WriteLine("Current Worst Quality: {0} (should be {1})", worstQuality, expectedWorstQuality); 105 106 Assert.AreEqual(bestQuality, expectedBestQuality); 107 Assert.AreEqual(averageQuality, expectedAverageQuality); 108 Assert.AreEqual(worstQuality, expectedWorstQuality); 109 92 110 if (ex != null) throw ex; 93 111 } -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r3280 r3303 279 279 private void InitializeAnnealingOperators() { 280 280 annealingOperators = new List<IDiscreteDoubleValueModifier>(); 281 if (ApplicationManager.Manager != null) { 282 annealingOperators.AddRange(ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)); 283 ParameterizeAnnealingOperators(); 284 } 281 annealingOperators.AddRange(ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)); 282 ParameterizeAnnealingOperators(); 285 283 AnnealingOperatorParameter.ValidValues.Clear(); 286 284 foreach (IDiscreteDoubleValueModifier op in annealingOperators) -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
r3234 r3303 198 198 var locationTable = assemblies.ToDictionary(a => a.Location, a => a); 199 199 200 if (ApplicationManager.Manager != null) { 201 foreach (var plugin in ApplicationManager.Manager.Plugins) { 202 var aList = new List<Assembly>(); 203 foreach (var aName in from file in plugin.Files 204 where file.Type == PluginFileType.Assembly 205 select file.Name) { 206 Assembly a; 207 locationTable.TryGetValue(aName, out a); 208 if (a != null) { 209 aList.Add(a); 210 locationTable.Remove(aName); 211 } 200 foreach (var plugin in ApplicationManager.Manager.Plugins) { 201 var aList = new List<Assembly>(); 202 foreach (var aName in from file in plugin.Files 203 where file.Type == PluginFileType.Assembly 204 select file.Name) { 205 Assembly a; 206 locationTable.TryGetValue(aName, out a); 207 if (a != null) { 208 aList.Add(a); 209 locationTable.Remove(aName); 212 210 } 213 plugins[plugin.Name] = aList;214 }211 } 212 plugins[plugin.Name] = aList; 215 213 } 216 214 -
trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
r3286 r3303 118 118 private void Initialize() { 119 119 operatorGraph.InitialOperatorChanged += new EventHandler(OperatorGraph_InitialOperatorChanged); 120 if ( (engine == null) && (ApplicationManager.Manager != null)) {120 if (engine == null) { 121 121 var types = ApplicationManager.Manager.GetTypes(typeof(IEngine)); 122 122 Type t = types.FirstOrDefault(x => x.Name.Equals("SequentialEngine")); -
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r3166 r3303 298 298 private void InitializeOperators() { 299 299 operators = new List<IBinaryVectorOperator>(); 300 if (ApplicationManager.Manager != null) { 301 foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 302 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IKnapsackMoveEvaluator)) { 303 operators.Add(op); 304 } 300 foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 301 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IKnapsackMoveEvaluator)) { 302 operators.Add(op); 305 303 } 306 ParameterizeOperators(); 307 } 308 304 } 305 ParameterizeOperators(); 309 306 InitializeMoveGenerators(); 310 307 } -
trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs
r3164 r3303 227 227 private void InitializeOperators() { 228 228 operators = new List<IBinaryVectorOperator>(); 229 if (ApplicationManager.Manager != null) { 230 foreach(IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 231 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IOneMaxMoveEvaluator)) { 232 operators.Add(op); 233 } 229 foreach(IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { 230 if (!(op is ISingleObjectiveMoveEvaluator) || (op is IOneMaxMoveEvaluator)) { 231 operators.Add(op); 234 232 } 235 ParameterizeOperators(); 236 } 237 233 } 234 ParameterizeOperators(); 238 235 InitializeMoveGenerators(); 239 236 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3221 r3303 252 252 private void InitializeOperators() { 253 253 operators = new List<IOperator>(); 254 if (ApplicationManager.Manager != null)operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());254 operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>()); 255 255 UpdateMoveEvaluators(); 256 256 ParameterizeOperators(); … … 265 265 } 266 266 private void UpdateMoveEvaluators() { 267 if (ApplicationManager.Manager != null) { 268 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList()) 269 operators.Remove(op); 270 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>()) 271 if (op.EvaluatorType == Evaluator.GetType()) { 272 operators.Add(op); 273 } 274 ParameterizeOperators(); 275 OnOperatorsChanged(); 276 } 267 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList()) 268 operators.Remove(op); 269 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>()) 270 if (op.EvaluatorType == Evaluator.GetType()) { 271 operators.Add(op); 272 } 273 ParameterizeOperators(); 274 OnOperatorsChanged(); 277 275 } 278 276 private void ParameterizeSolutionCreator() { -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r3232 r3303 295 295 private void InitializeOperators() { 296 296 operators = new List<IPermutationOperator>(); 297 if (ApplicationManager.Manager != null)operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>());297 operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>()); 298 298 ParameterizeOperators(); 299 299 UpdateMoveEvaluators(); … … 313 313 } 314 314 private void UpdateMoveEvaluators() { 315 if (ApplicationManager.Manager != null) { 316 foreach (ITSPPathMoveEvaluator op in Operators.OfType<ITSPPathMoveEvaluator>().ToList()) 317 operators.Remove(op); 318 foreach (ITSPPathMoveEvaluator op in ApplicationManager.Manager.GetInstances<ITSPPathMoveEvaluator>()) 319 if (op.EvaluatorType == Evaluator.GetType()) { 320 operators.Add(op); 321 } 322 ParameterizeOperators(); 323 OnOperatorsChanged(); 324 } 315 foreach (ITSPPathMoveEvaluator op in Operators.OfType<ITSPPathMoveEvaluator>().ToList()) 316 operators.Remove(op); 317 foreach (ITSPPathMoveEvaluator op in ApplicationManager.Manager.GetInstances<ITSPPathMoveEvaluator>()) 318 if (op.EvaluatorType == Evaluator.GetType()) { 319 operators.Add(op); 320 } 321 ParameterizeOperators(); 322 OnOperatorsChanged(); 325 323 } 326 324 private void ParameterizeSolutionCreator() {
Note: See TracChangeset
for help on using the changeset viewer.