Changeset 11396 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveEvaluator.cs
- Timestamp:
- 09/27/14 18:30:43 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveEvaluator.cs
r11393 r11396 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.BinaryVectorEncoding;28 using HeuristicLab.Encodings.IntegerVectorEncoding;29 using HeuristicLab.Encodings.PermutationEncoding;30 using HeuristicLab.Encodings.RealVectorEncoding;31 26 using HeuristicLab.Operators; 32 27 using HeuristicLab.Optimization; … … 74 69 if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile."); 75 70 var config = ConfigurationParameter.ActualValue; 76 var binDict = new Dictionary<string, BinaryVector>(); 77 var intDict = new Dictionary<string, IntegerVector>(); 78 var realDict = new Dictionary<string, RealVector>(); 79 var permDict = new Dictionary<string, Permutation>(); 80 foreach (var param in config.Parameters) { 81 var binConfig = param.Value as BinaryParameterConfiguration; 82 if (binConfig != null) { 83 binDict.Add(param.Key, (BinaryVector)ExecutionContext.Scope.Variables[param.Key].Value); 84 continue; 85 } 86 var intConfig = param.Value as IntegerParameterConfiguration; 87 if (intConfig != null) { 88 intDict.Add(param.Key, (IntegerVector)ExecutionContext.Scope.Variables[param.Key].Value); 89 continue; 90 } 91 var realConfig = param.Value as RealParameterConfiguration; 92 if (realConfig != null) { 93 realDict.Add(param.Key, (RealVector)ExecutionContext.Scope.Variables[param.Key].Value); 94 continue; 95 } 96 var permConfig = param.Value as PermutationParameterConfiguration; 97 if (permConfig != null) { 98 permDict.Add(param.Key, (Permutation)ExecutionContext.Scope.Variables[param.Key].Value); 99 continue; 100 } 101 throw new InvalidOperationException("Parameter " + param.Key + " not found."); 102 } 103 var vector = new ParameterVector( 104 binaryVectors: binDict.Count > 0 ? binDict : null, 105 integerVectors: intDict.Count > 0 ? intDict : null, 106 realVectors: realDict.Count > 0 ? realDict : null, 107 permutations: permDict.Count > 0 ? permDict : null); 71 var vector = Helper.Extract(ExecutionContext.Scope, config); 108 72 QualityParameter.ActualValue = new DoubleValue(host.Instance.Evaluate(random, vector)); 109 73 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.