Changeset 3746
- Timestamp:
- 05/10/10 16:34:35 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r3705 r3746 7 7 ..\documentation\License\gpl-3.0.txt = ..\documentation\License\gpl-3.0.txt 8 8 HeuristicLab 3.3.vsmdi = HeuristicLab 3.3.vsmdi 9 HeuristicLab 3.31.vsmdi = HeuristicLab 3.31.vsmdi 9 10 LocalTestRun.testrunconfig = LocalTestRun.testrunconfig 10 11 PreBuildEvent.cmd = PreBuildEvent.cmd … … 244 245 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.OneMax.Views-3.3", "HeuristicLab.Problems.OneMax.Views\3.3\HeuristicLab.Problems.OneMax.Views-3.3.csproj", "{4FE983A1-AAF8-4977-B9E2-52B3224510CB}" 245 246 EndProject 247 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Tests-3.3", "HeuristicLab.Problems.DataAnalysis\3.3\Tests\HeuristicLab.Problems.DataAnalysis.Tests-3.3.csproj", "{5A4679EF-A8F3-4647-B722-441A36B3BA6B}" 248 EndProject 246 249 Global 250 GlobalSection(TestCaseManagementSettings) = postSolution 251 CategoryFile = HeuristicLab 3.31.vsmdi 252 EndGlobalSection 247 253 GlobalSection(SolutionConfigurationPlatforms) = preSolution 248 254 Debug|Any CPU = Debug|Any CPU … … 1343 1349 {4FE983A1-AAF8-4977-B9E2-52B3224510CB}.Services|x64.ActiveCfg = Release|x64 1344 1350 {4FE983A1-AAF8-4977-B9E2-52B3224510CB}.Services|x86.ActiveCfg = Release|x86 1351 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1352 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Debug|Any CPU.Build.0 = Debug|Any CPU 1353 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Debug|x64.ActiveCfg = Debug|Any CPU 1354 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Debug|x86.ActiveCfg = Debug|Any CPU 1355 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Release|Any CPU.ActiveCfg = Release|Any CPU 1356 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Release|Any CPU.Build.0 = Release|Any CPU 1357 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Release|x64.ActiveCfg = Release|Any CPU 1358 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Release|x86.ActiveCfg = Release|Any CPU 1359 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|Any CPU.ActiveCfg = Release|Any CPU 1360 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|Any CPU.Build.0 = Release|Any CPU 1361 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|x64.ActiveCfg = Release|Any CPU 1362 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|x86.ActiveCfg = Release|Any CPU 1345 1363 EndGlobalSection 1346 1364 GlobalSection(SolutionProperties) = preSolution -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/SimpleArithmeticExpressionInterpreterTest.cs
r3733 r3746 89 89 public void SimpleArithmeticExpressionInterpreterEvaluateTest() { 90 90 91 Dataset ds = new Dataset(new string[] { " y", "a", "b" }, new double[,] {91 Dataset ds = new Dataset(new string[] { "Y", "A", "B" }, new double[,] { 92 92 { 1.0, 1.0, 1.0 }, 93 93 { 2.0, 2.0, 2.0 }, … … 133 133 Evaluate(interpreter, ds, "(/ 8.0 2.0 2.0)", 0, 2.0); 134 134 135 // TODO ADF 135 // ADF 136 Evaluate(interpreter, ds, @"(PROG 137 (MAIN 138 (CALL ADF0)) 139 (defun ADF0 1.0))", 1, 1.0); 140 Evaluate(interpreter, ds, @"(PROG 141 (MAIN 142 (* (CALL ADF0) (CALL ADF0))) 143 (defun ADF0 2.0))", 1, 4.0); 144 Evaluate(interpreter, ds, @"(PROG 145 (MAIN 146 (CALL ADF0 2.0 3.0)) 147 (defun ADF0 148 (+ (ARG 0) (ARG 1))))", 1, 5.0); 149 Evaluate(interpreter, ds, @"(PROG 150 (MAIN (CALL ADF1 2.0 3.0)) 151 (defun ADF0 152 (- (ARG 1) (ARG 0))) 153 (defun ADF1 154 (+ (CALL ADF0 (ARG 1) (ARG 0)) 155 (CALL ADF0 (ARG 0) (ARG 1)))))", 1, 0.0); 156 Evaluate(interpreter, ds, @"(PROG 157 (MAIN (CALL ADF1 (variable 2.0 a) 3.0)) 158 (defun ADF0 159 (- (ARG 1) (ARG 0))) 160 (defun ADF1 161 (CALL ADF0 (ARG 1) (ARG 0))))", 1, 1.0); 162 Evaluate(interpreter, ds, @"(PROG 163 (MAIN (CALL ADF1 (variable 2.0 a) 3.0)) 164 (defun ADF0 165 (- (ARG 1) (ARG 0))) 166 (defun ADF1 167 (+ (CALL ADF0 (ARG 1) (ARG 0)) 168 (CALL ADF0 (ARG 0) (ARG 1)))))", 1, 0.0); 136 169 } 137 170 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/SymbolicExpressionImporter.cs
r3733 r3746 32 32 namespace HeuristicLab.Problems.DataAnalysis.Tests { 33 33 internal class SymbolicExpressionImporter { 34 private const string VARSTART = "var"; 34 private const string VARSTART = "VAR"; 35 private const string DEFUNSTART = "DEFUN"; 36 private const string ARGSTART = "ARG"; 37 private const string INVOKESTART = "CALL"; 35 38 private Dictionary<string, Symbol> knownSymbols = new Dictionary<string, Symbol>() 36 39 { … … 39 42 {"*", new Multiplication()}, 40 43 {"-", new Subtraction()}, 44 {"PROG", new ProgramRootSymbol()}, 45 {"MAIN", new StartSymbol()} 46 }; 41 47 42 };43 48 Constant constant = new Constant(); 44 49 Variable variable = new Variable(); 50 Defun defun = new Defun(); 51 45 52 ProgramRootSymbol programRootSymbol = new ProgramRootSymbol(); 46 53 StartSymbol startSymbol = new StartSymbol(); … … 54 61 SymbolicExpressionTreeNode start = startSymbol.CreateTreeNode(); 55 62 SymbolicExpressionTreeNode mainBranch = ParseSexp(new Queue<Token>(GetTokenStream(str))); 56 root.AddSubTree(start); 57 start.AddSubTree(mainBranch); 63 if (mainBranch.Symbol is ProgramRootSymbol) { 64 // when a root symbol was parsed => use main branch as root 65 root = mainBranch; 66 } else { 67 // only a main branch was given => insert the main branch into the default tree template 68 root.AddSubTree(start); 69 start.AddSubTree(mainBranch); 70 } 58 71 return new SymbolicExpressionTree(root); 59 72 } … … 73 86 if (tokens.Peek().StringValue.StartsWith(VARSTART)) { 74 87 tree = ParseVariable(tokens); 88 } else if (tokens.Peek().StringValue.StartsWith(DEFUNSTART)) { 89 tree = ParseDefun(tokens); 90 while (!tokens.Peek().Equals(Token.RPAR)) { 91 tree.AddSubTree(ParseSexp(tokens)); 92 } 93 } else if (tokens.Peek().StringValue.StartsWith(ARGSTART)) { 94 tree = ParseArgument(tokens); 95 } else if (tokens.Peek().StringValue.StartsWith(INVOKESTART)) { 96 tree = ParseInvoke(tokens); 97 while (!tokens.Peek().Equals(Token.RPAR)) { 98 tree.AddSubTree(ParseSexp(tokens)); 99 } 75 100 } else { 76 101 Token curToken = tokens.Dequeue(); … … 89 114 } 90 115 116 private SymbolicExpressionTreeNode ParseInvoke(Queue<Token> tokens) { 117 Token invokeTok = tokens.Dequeue(); 118 Debug.Assert(invokeTok.StringValue == "CALL"); 119 InvokeFunction invokeSym = new InvokeFunction(tokens.Dequeue().StringValue); 120 SymbolicExpressionTreeNode invokeNode = invokeSym.CreateTreeNode(); 121 return invokeNode; 122 } 123 124 private SymbolicExpressionTreeNode ParseArgument(Queue<Token> tokens) { 125 Token argTok = tokens.Dequeue(); 126 Debug.Assert(argTok.StringValue == "ARG"); 127 Argument argument = new Argument((int)tokens.Dequeue().DoubleValue); 128 SymbolicExpressionTreeNode argNode = argument.CreateTreeNode(); 129 return argNode; 130 } 131 132 private SymbolicExpressionTreeNode ParseDefun(Queue<Token> tokens) { 133 Token defTok = tokens.Dequeue(); 134 Debug.Assert(defTok.StringValue == "DEFUN"); 135 DefunTreeNode t = (DefunTreeNode)defun.CreateTreeNode(); 136 t.FunctionName = tokens.Dequeue().StringValue; 137 return t; 138 } 139 91 140 private SymbolicExpressionTreeNode ParseVariable(Queue<Token> tokens) { 92 141 Token varTok = tokens.Dequeue(); 93 Debug.Assert(varTok.StringValue == " variable");142 Debug.Assert(varTok.StringValue == "VARIABLE"); 94 143 VariableTreeNode t = (VariableTreeNode)variable.CreateTreeNode(); 95 144 t.Weight = tokens.Dequeue().DoubleValue; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/Token.cs
r3733 r3746 62 62 } else { 63 63 t.Symbol = TokenSymbol.SYMB; 64 t.StringValue = t.StringValue.ToUpper(); 64 65 } 65 66 return t;
Note: See TracChangeset
for help on using the changeset viewer.