Changeset 2635
- Timestamp:
- 01/18/10 10:56:50 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Networks/3.2/NetworkToFunctionTransformer.cs
r2633 r2635 51 51 52 52 var targetVariableEnumerator = targetVariables.Select(x => x.Data).GetEnumerator(); 53 List<IFunctionTree> transformedTrees = new List<IFunctionTree>(Transform(model.FunctionTree, targetVariables.Select(x => x.Data))); 53 54 // create a new sub-scope for each target variable with the transformed expression 54 foreach (IFunctionTree transformedTree in Transform(model.FunctionTree, targetVariables.Select(x => x.Data))) {55 foreach (IFunctionTree transformedTree in transformedTrees) { 55 56 targetVariableEnumerator.MoveNext(); 56 57 Scope exprScope = new Scope(); … … 72 73 // create a new sub-scope for each target variable with the transformed expression 73 74 foreach (var targetVariable in targetVariables) { 74 yield return TransformExpression( boundExpression, targetVariable, targetVariables.Except(new string[] { targetVariable }));75 yield return TransformExpression((IFunctionTree)boundExpression.Clone(), targetVariable, targetVariables.Except(new string[] { targetVariable })); 75 76 } 76 77 } -
trunk/sources/HeuristicLab.GP.Tests/NetworkToFunctionTransformerTest.cs
r2633 r2635 113 113 IFunctionTree t2 = importer.Import("(- (variable 1.0 a 0) (variable 1.0 b 0))"); 114 114 115 CompareTrees(actualTrees , new List<IFunctionTree>() {115 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 116 116 t0, t1, t2 117 117 }); … … 127 127 IFunctionTree t2 = importer.Import("(/ (+ (variable 1.0 a 0) (+ (variable 1.0 b 0) 1.0)) 1.0 )"); 128 128 129 CompareTrees(actualTrees , new List<IFunctionTree>() {129 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 130 130 t0, t1, t2 131 131 }); … … 142 142 143 143 144 CompareTrees(actualTrees , new List<IFunctionTree>() {144 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 145 145 t0, t1, t2 146 146 }); … … 160 160 (exp (variable 1.0 b 0)))"); 161 161 162 CompareTrees(actualTrees , new List<IFunctionTree>() {162 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 163 163 t0, t1, t2 164 164 }); … … 176 176 (exp (exp (variable 1.0 b 0)))) 2.0)"); 177 177 178 CompareTrees(actualTrees , new List<IFunctionTree>() {178 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 179 179 t0, t1, t2 180 180 }); … … 194 194 (/ (variable 1.0 b 0) 2.0)) 2.0)"); 195 195 196 CompareTrees(actualTrees , new List<IFunctionTree>() {196 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 197 197 t0, t1, t2 198 198 }); … … 214 214 215 215 216 CompareTrees(actualTrees , new List<IFunctionTree>() {216 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 217 217 t0, t1, t2 218 218 }); … … 229 229 230 230 231 CompareTrees(actualTrees , new List<IFunctionTree>() {231 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 232 232 t0, t1, t2 233 233 }); … … 244 244 245 245 246 CompareTrees(actualTrees , new List<IFunctionTree>() {246 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 247 247 t0, t1, t2 248 248 }); … … 259 259 260 260 261 CompareTrees(actualTrees , new List<IFunctionTree>() {261 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 262 262 t0, t1, t2 263 263 }); … … 274 274 275 275 276 CompareTrees(actualTrees , new List<IFunctionTree>() {276 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 277 277 t0, t1, t2 278 278 }); … … 290 290 291 291 292 CompareTrees(actualTrees , new List<IFunctionTree>() {293 t0, t1, t2 294 }); 295 } 296 } 297 298 private void CompareTrees( IEnumerable<IFunctionTree> actual, IEnumerable<IFunctionTree> expected) {299 var expectedEnumerator = expected.GetEnumerator(); 292 CompareTrees(actualTrees.ToList(), new List<IFunctionTree>() { 293 t0, t1, t2 294 }); 295 } 296 } 297 298 private void CompareTrees(List<IFunctionTree> actual, List<IFunctionTree> expected) { 299 var expectedEnumerator = expected.GetEnumerator(); 300 300 foreach (var actualTree in actual) { 301 301 if (!expectedEnumerator.MoveNext()) Assert.Fail();
Note: See TracChangeset
for help on using the changeset viewer.