- Timestamp:
- 01/14/10 19:42:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Tests/NetworkToFunctionTransformerTest.cs
r2625 r2627 6 6 using System.Linq; 7 7 using System.Collections.Generic; 8 using HeuristicLab.Random; 9 using HeuristicLab.DataAnalysis; 8 10 9 11 namespace HeuristicLab.GP.Test { … … 197 199 } 198 200 { 199 IFunctionTree tree = importer.Import(@"( cycle (open-+200 201 202 203 204 205 201 IFunctionTree tree = importer.Import(@"(open-+ 202 (flip (f1-+ 203 (flip (f1-- 204 (flip (f1-/ 205 (open-param - 0) 4.0)) 3.0)) 2.0)) 206 (open-param - 0) 207 (open-param - 0)))"); 206 208 // -3*4-2 x 207 209 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 208 210 209 IFunctionTree t0 = importer.Import("(+ (/ ( -(+ (variable 1.0 b 0) (variable 1.0 c 0)) 3.0) 4.0) 2.0)");211 IFunctionTree t0 = importer.Import("(+ (/ (+ (+ (variable 1.0 b 0) (variable 1.0 c 0)) 3.0) 4.0) 2.0)"); 210 212 IFunctionTree t1 = importer.Import("(- (- (* (- (variable 1.0 a 0) 2.0) 4.0) 3.0) (variable 1.0 c 0))"); 211 213 IFunctionTree t2 = importer.Import("(- (- (* (- (variable 1.0 a 0) 2.0) 4.0) 3.0) (variable 1.0 b 0))"); … … 216 218 }); 217 219 } 218 220 { 221 // constant expression 222 IFunctionTree tree = importer.Import(@"(* (variable 1.0 d 0) (variable 1.0 d 0))"); 223 224 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 225 226 IFunctionTree t0 = importer.Import("(* (variable 1.0 d 0) (variable 1.0 d 0))"); 227 IFunctionTree t1 = importer.Import("(* (variable 1.0 d 0) (variable 1.0 d 0))"); 228 IFunctionTree t2 = importer.Import("(* (variable 1.0 d 0) (variable 1.0 d 0))"); 229 230 231 CompareTrees(actualTrees, new List<IFunctionTree>() { 232 t0, t1, t2 233 }); 234 } 235 { 236 // expression with one parameter 237 IFunctionTree tree = importer.Import(@"(f1-* (variable 1.0 a 0) (variable 1.0 d 0))"); 238 239 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 240 241 IFunctionTree t0 = importer.Import("(/ (variable 1.0 b 0) (variable 1.0 d 0))"); 242 IFunctionTree t1 = importer.Import("(* (variable 1.0 a 0) (variable 1.0 d 0))"); 243 IFunctionTree t2 = importer.Import("(* (variable 1.0 a 0) (variable 1.0 d 0))"); 244 245 246 CompareTrees(actualTrees, new List<IFunctionTree>() { 247 t0, t1, t2 248 }); 249 } 250 { 251 // expression with one parameter 252 IFunctionTree tree = importer.Import(@"(open-log (variable 1.0 a 0))"); 253 254 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 255 256 IFunctionTree t0 = importer.Import("(exp (variable 1.0 b 0))"); 257 IFunctionTree t1 = importer.Import("(log (variable 1.0 a 0))"); 258 IFunctionTree t2 = importer.Import("(log (variable 1.0 a 0))"); 259 260 261 CompareTrees(actualTrees, new List<IFunctionTree>() { 262 t0, t1, t2 263 }); 264 } 265 { 266 // expression with flip and one parameter 267 IFunctionTree tree = importer.Import(@"(flip (open-log (variable 1.0 a 0)))"); 268 269 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 270 271 IFunctionTree t0 = importer.Import("(log (variable 1.0 b 0))"); 272 IFunctionTree t1 = importer.Import("(exp (variable 1.0 a 0))"); 273 IFunctionTree t2 = importer.Import("(exp (variable 1.0 a 0))"); 274 275 276 CompareTrees(actualTrees, new List<IFunctionTree>() { 277 t0, t1, t2 278 }); 279 } 219 280 } 220 281 … … 245 306 } 246 307 } 308 309 [TestMethod()] 310 [DeploymentItem("HeuristicLab.GP.StructureIdentification.Networks-3.2.dll")] 311 public void TransformRandomTreesTest() { 312 313 MersenneTwister twister = new MersenneTwister(); 314 Dataset ds = Util.CreateRandomDataset(twister, 1, 20); 315 IFunctionTree[] randomTrees = Util.CreateRandomTrees(twister, ds, FunctionLibraryInjector.Create(false, 0, 0), 1000, 1, 100); 316 foreach (var tree in randomTrees) { 317 IEnumerable<IFunctionTree> actualTrees = NetworkToFunctionTransformer_Accessor.Transform(tree, new List<string>() { "a", "b", "c" }); 318 actualTrees.ToList(); 319 } 320 } 247 321 } 248 322 }
Note: See TracChangeset
for help on using the changeset viewer.