Changeset 8206 for branches/GP-MoveOperators/HeuristicLab.Tests
- Timestamp:
- 07/03/12 16:46:35 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:mergeinfo changed
/trunk/sources merged: 8084,8088-8090,8092-8100,8102-8113,8115,8117-8132,8134-8146,8148-8156,8158-8160,8163-8170,8173-8176,8178-8190,8192-8205
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Tests merged: 8088,8092,8121,8123,8132,8154,8164,8195
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/PluginDependenciesTest.cs
r7948 r8206 35 35 private static Dictionary<string, string> pluginNames; 36 36 private static Dictionary<string, Assembly> pluginFilesToPluginLookup = new Dictionary<string, Assembly>(); 37 //private static Dictionary<string, string> pluginToPluginFilesLookup = new Dictionary<string, string>();38 37 39 38 // Use ClassInitialize to run code before running the first test in the class … … 91 90 92 91 var referencedNonPluginAssemblies = pluginAssembly.GetReferencedAssemblies().Where(a => !IsPluginAssemblyName(a)); 93 bool found = (from referencedNonPluginAssembl iein referencedNonPluginAssemblies94 select referencedNonPluginAssembl ie.Name into assemblyName92 bool found = (from referencedNonPluginAssembly in referencedNonPluginAssemblies 93 select referencedNonPluginAssembly.Name into assemblyName 95 94 where pluginFilesToPluginLookup.ContainsKey(assemblyName) 96 95 select GetPluginFromAssembly(pluginFilesToPluginLookup[assemblyName]) into pluginType -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/SamplesTest.cs
r7915 r8206 44 44 using HeuristicLab.Problems.DataAnalysis.Symbolic.Classification; 45 45 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 46 using HeuristicLab.Problems.Instances; 46 47 using HeuristicLab.Problems.Instances.DataAnalysis; 47 48 using HeuristicLab.Problems.Instances.TSPLIB; 49 using HeuristicLab.Problems.Instances.VehicleRouting; 48 50 using HeuristicLab.Problems.Knapsack; 49 51 using HeuristicLab.Problems.TestFunctions; … … 51 53 using HeuristicLab.Problems.VehicleRouting; 52 54 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 53 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;54 55 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 55 56 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 56 57 using HeuristicLab.Selection; 57 58 using Microsoft.VisualStudio.TestTools.UnitTesting; 58 using HeuristicLab.Problems.Instances.VehicleRouting;59 using HeuristicLab.Problems.Instances;60 59 61 60 … … 133 132 134 133 SolomonFormatInstanceProvider instanceProvider = new SolomonInstanceProvider(); 135 IVRPData data = instanceProvider. LoadData("C101.txt", "C101.opt.txt");134 IVRPData data = instanceProvider.Import("C101.txt", "C101.opt.txt"); 136 135 vrpProblem.Load(data); 137 136 vrpProblem.Name = "C101 VRP (imported from Solomon)"; … … 439 438 } 440 439 #endregion 440 #region LawnMower 441 [TestMethod] 442 public void RunGpLawnMowerSampleTest() { 443 var ga = CreateGpLawnMowerSample(); 444 ga.SetSeedRandomly.Value = false; 445 RunAlgorithm(ga); 446 } 447 448 public GeneticAlgorithm CreateGpLawnMowerSample() { 449 GeneticAlgorithm ga = new GeneticAlgorithm(); 450 #region Problem Configuration 451 var problem = new HeuristicLab.Problems.LawnMower.Problem(); 452 #endregion 453 #region Algorithm Configuration 454 ga.Name = "Genetic Programming - Lawn Mower"; 455 ga.Description = "A standard genetic programming algorithm to solve the lawn mower problem"; 456 ga.Problem = problem; 457 ConfigureGeneticAlgorithmParameters<TournamentSelector, SubtreeCrossover, MultiSymbolicExpressionTreeArchitectureManipulator>( 458 ga, 1000, 1, 50, 0.25, 5); 459 var mutator = (MultiSymbolicExpressionTreeArchitectureManipulator)ga.Mutator; 460 mutator.Operators.SetItemCheckedState(mutator.Operators 461 .OfType<OnePointShaker>() 462 .Single(), false); 463 #endregion 464 return ga; 465 } 466 #endregion 441 467 #endregion 442 468 -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs
r7915 r8206 20 20 #endregion 21 21 22 using System; 22 23 using System.Linq; 23 24 using HeuristicLab.Core; … … 29 30 public class ToStringTest { 30 31 32 private TestContext testContextInstance; 33 /// <summary> 34 ///Gets or sets the test context which provides 35 ///information about and functionality for the current test run. 36 ///</summary> 37 public TestContext TestContext { 38 get { 39 return testContextInstance; 40 } 41 set { 42 testContextInstance = value; 43 } 44 } 45 31 46 // Use ClassInitialize to run code before running the first test in the class 32 47 [ClassInitialize] … … 37 52 [TestMethod] 38 53 public void TestToString() { 54 bool success = true; 39 55 // just test for all IItems that the ToString method doesn't throw an exception 40 56 foreach (object item in ApplicationManager.Manager.GetInstances(typeof(IItem))) { 41 item.ToString(); 57 try { 58 item.ToString(); 59 } 60 catch (Exception e) { 61 TestContext.WriteLine(item.GetType() + " throws a " + e.GetType() + " in the ToString method."); 62 success = false; 63 } 42 64 } 65 Assert.IsTrue(success, "There are potential errors in the ToString methods of objects."); 43 66 } 44 67 } -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r8085 r8206 365 365 Evaluate(interpreter, ds, "(lag -1.0 (* (lagVariable 1.0 a 1) (lagVariable 1.0 b 2)))", 1, ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 2)); 366 366 Evaluate(interpreter, ds, "(lag -2.0 3.0)", 1, 3.0); 367 368 { 369 // special functions 370 Action<double> checkAiry = (x) => { 371 double ai, aip, bi, bip; 372 alglib.airy(x, out ai, out aip, out bi, out bip); 373 Evaluate(interpreter, ds, "(airya " + x + ")", 0, ai); 374 Evaluate(interpreter, ds, "(airyb " + x + ")", 0, bi); 375 }; 376 377 Action<double> checkBessel = (x) => { 378 Evaluate(interpreter, ds, "(bessel " + x + ")", 0, alglib.besseli0(x)); 379 }; 380 381 Action<double> checkSinCosIntegrals = (x) => { 382 double si, ci; 383 alglib.sinecosineintegrals(x, out si, out ci); 384 Evaluate(interpreter, ds, "(cosint " + x + ")", 0, ci); 385 Evaluate(interpreter, ds, "(sinint " + x + ")", 0, si); 386 }; 387 Action<double> checkHypSinCosIntegrals = (x) => { 388 double shi, chi; 389 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 390 Evaluate(interpreter, ds, "(hypcosint " + x + ")", 0, chi); 391 Evaluate(interpreter, ds, "(hypsinint " + x + ")", 0, shi); 392 }; 393 Action<double> checkFresnelSinCosIntegrals = (x) => { 394 double c = 0, s = 0; 395 alglib.fresnelintegral(x, ref c, ref s); 396 Evaluate(interpreter, ds, "(fresnelcosint " + x + ")", 0, c); 397 Evaluate(interpreter, ds, "(fresnelsinint " + x + ")", 0, s); 398 }; 399 Action<double> checkNormErf = (x) => { 400 Evaluate(interpreter, ds, "(norm " + x + ")", 0, alglib.normaldistribution(x)); 401 Evaluate(interpreter, ds, "(erf " + x + ")", 0, alglib.errorfunction(x)); 402 }; 403 404 Action<double> checkGamma = (x) => { 405 Evaluate(interpreter, ds, "(gamma " + x + ")", 0, alglib.gammafunction(x)); 406 }; 407 Action<double> checkPsi = (x) => { 408 try { 409 Evaluate(interpreter, ds, "(psi " + x + ")", 0, alglib.psi(x)); 410 } 411 catch (alglib.alglibexception) { // ignore cases where alglib throws an exception 412 } 413 }; 414 Action<double> checkDawson = (x) => { 415 Evaluate(interpreter, ds, "(dawson " + x + ")", 0, alglib.dawsonintegral(x)); 416 }; 417 Action<double> checkExpInt = (x) => { 418 Evaluate(interpreter, ds, "(expint " + x + ")", 0, alglib.exponentialintegralei(x)); 419 }; 420 421 422 423 foreach (var e in new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }) { 424 checkAiry(e); 425 checkBessel(e); 426 checkSinCosIntegrals(e); 427 checkGamma(e); 428 checkExpInt(e); 429 checkDawson(e); 430 checkPsi(e); 431 checkNormErf(e); 432 checkFresnelSinCosIntegrals(e); 433 checkHypSinCosIntegrals(e); 434 } 435 } 367 436 } 368 437 -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionImporter.cs
r8085 r8206 49 49 {"COS", new Cosine()}, 50 50 {"TAN", new Tangent()}, 51 {"AIRYA", new AiryA()}, 52 {"AIRYB", new AiryB()}, 53 {"BESSEL", new Bessel()}, 54 {"COSINT", new CosineIntegral()}, 55 {"SININT", new SineIntegral()}, 56 {"HYPCOSINT", new HyperbolicCosineIntegral()}, 57 {"HYPSININT", new HyperbolicSineIntegral()}, 58 {"FRESNELSININT", new FresnelSineIntegral()}, 59 {"FRESNELCOSINT", new FresnelCosineIntegral()}, 60 {"NORM", new Norm()}, 61 {"ERF", new Erf()}, 62 {"GAMMA", new Gamma()}, 63 {"PSI", new Psi()}, 64 {"DAWSON", new Dawson()}, 65 {"EXPINT", new ExponentialIntegralEi()}, 51 66 {"MEAN", new Average()}, 52 67 {"IF", new IfThenElse()}, -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs
r8085 r8206 168 168 { "wil100", 273038 } 169 169 }; 170 private static Dictionary<string, double> lowerBounds = new Dictionary<string, double>() { 171 { "bur26a", 5315200 }, 172 { "bur26f", 3706888 }, 173 { "chr25a", 2765 }, 174 { "els19", 11971949 }, 175 { "esc32a", 35 }, 176 { "esc32e", 0 }, 177 { "had20", 6166 }, 178 { "kra32", 67390 }, 179 { "lipa50a", 62020 }, 180 { "lipa50b", 1210244 }, 181 { "nug30", 4539 }, 182 { "scr20", 86766 }, 183 { "sko42", 11311 }, 184 { "tai35a", 1951207 }, 185 { "tai35b", 30866283 }, 186 { "tai100a", 15824355 } 187 }; 170 188 #endregion 171 189 … … 204 222 failedInstances.AppendLine(instance.Name + ": " + qap.BestKnownQuality.Value.ToString() + " vs " + qaplibInstances[instance.Name]); 205 223 } 206 Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious quality: " + Environment.NewLine + failedInstances.ToString()); 224 Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious best quality: " + Environment.NewLine + failedInstances.ToString()); 225 } 226 227 [TestMethod] 228 public void TestQAPLIBLowerBounds() { 229 var provider = new QAPLIBInstanceProvider(); 230 var qap = new QuadraticAssignmentProblem(); 231 var failedInstances = new StringBuilder(); 232 233 var instances = provider.GetDataDescriptors(); 234 Assert.IsTrue(instances.Any(), "No instances could be found."); 235 236 foreach (var instance in instances) { 237 if (lowerBounds.ContainsKey(instance.Name)) { 238 qap.Load(provider.LoadData(instance)); 239 if (qap.LowerBound.Value != lowerBounds[instance.Name]) 240 failedInstances.AppendLine(instance.Name + ": The Gilmore-Lawler lower bound is not valid."); 241 } 242 } 243 Assert.IsTrue(failedInstances.Length == 0, "Following instances failed for the GLB calculation: " + Environment.NewLine + failedInstances.ToString()); 207 244 } 208 245 } -
branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r8085 r8206 225 225 <HintPath>..\bin\HeuristicLab.Problems.Knapsack-3.3.dll</HintPath> 226 226 </Reference> 227 <Reference Include="HeuristicLab.Problems.LawnMower-3.3"> 228 <HintPath>..\bin\HeuristicLab.Problems.LawnMower-3.3.dll</HintPath> 229 </Reference> 227 230 <Reference Include="HeuristicLab.Problems.LinearAssignment-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 228 231 <HintPath>..\bin\HeuristicLab.Problems.LinearAssignment-3.3.dll</HintPath> … … 275 278 <Compile Include="HeuristicLab-3.3\CollectObjectGraphTest.cs" /> 276 279 <Compile Include="HeuristicLab-3.3\ContentViewTests.cs" /> 280 <Compile Include="HeuristicLab-3.3\ParameterVisibilityTest.cs" /> 277 281 <Compile Include="HeuristicLab-3.3\DeepCloneableCloningTest.cs" /> 278 282 <Compile Include="HeuristicLab-3.3\GeneticAlgorithmTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.