- Timestamp:
- 10/12/11 15:45:04 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/Calculator.cs
r6902 r6908 25 25 26 26 private static readonly Regex TokenRegex = 27 new Regex(@" [a-zA-Z0-9._]+|""([^""]|\\"")*""|'([^']|\\')*'|[-+*/<>^]|dup|swap|drop|log|true|false|if|==|not|isnull|null|ismatch|rename");27 new Regex(@"""(\\""|[^""])*""|'(\\'|[^'])*'|[^\s]+"); 28 28 29 29 #endregion … … 61 61 stack.Push(d); 62 62 } else if (token.StartsWith("\"")) { 63 stack.Push(GetVariableValue(variables, token.Substring(1, token.Length - 2).Replace( @"\""", @"""")));63 stack.Push(GetVariableValue(variables, token.Substring(1, token.Length - 2).Replace("\\\"", "\""))); 64 64 } else if (token.StartsWith("'")) { 65 stack.Push(token.Substring(1, token.Length-2).Replace("\ '", "'"));65 stack.Push(token.Substring(1, token.Length-2).Replace("\\'", "'")); 66 66 } else { 67 67 Apply(token, stack, variables); … … 70 70 } catch (Exception x) { 71 71 throw new Exception(string.Format( 72 "Calculation Failed at token #{1}: '{2}' {0}current stack is: {0}{3}", Environment.NewLine, 73 i, tokens[i], string.Join(Environment.NewLine, stack.Select(AsString))), 72 "Calculation of '{1}'{0}failed at token #{2}: '{3}' {0}current stack is: {0}{4}", Environment.NewLine, 73 Formula, i, tokens[i], 74 string.Join(Environment.NewLine, stack.Select(AsString))), 74 75 x); 75 76 } 76 if (stack.Count != 1) throw new Exception(string.Format("Invalid final evaluation stack size {0} (should be 1)", stack.Count)); 77 if (stack.Count != 1) 78 throw new Exception( 79 string.Format("Invalid final evaluation stack size {0} (should be 1) in formula '{1}'", 80 stack.Count, Formula)); 77 81 var result = stack.Pop(); 78 82 if (result is string) return new StringValue((string)result); -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionDiscretizer.cs
r6903 r6908 10 10 11 11 namespace HeuristicLab.Optimization { 12 [Item("RunCollection Discretizer", "Creates several levels from the distribution of a certain result accross a run collection and assignes a discretized value.")] 12 [Item("RunCollection Discretizer", 13 "Creates several levels from the distribution of a certain result accross a run collection and " + 14 "assigns a discretized value. Non-existing numbers as well as NaN and infinities are excluded from the caluclation.")] 13 15 [StorableClass] 14 16 public class RunCollectionDiscretizer : ParameterizedNamedItem, IRunCollectionModifier { … … 139 141 variables.TryGetValue(Source, out value); 140 142 var intValue = value as IntValue; 141 if (intValue != null) {143 if (intValue != null) 142 144 return intValue.Value; 143 } else { 144 var doubleValue = value as DoubleValue; 145 if (doubleValue != null) 146 return doubleValue.Value; 147 } 145 var doubleValue = value as DoubleValue; 146 if (doubleValue != null) 147 return doubleValue.Value; 148 148 return null; 149 149 }
Note: See TracChangeset
for help on using the changeset viewer.