- Timestamp:
- 11/19/21 16:16:54 (3 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/PluginDependenciesTest.cs
r17226 r18087 34 34 private static Dictionary<Assembly, Type> loadedPlugins; 35 35 private static Dictionary<string, string> pluginNames; 36 private static Dictionary<string, Version> pluginVersions; 36 37 private static Dictionary<string, Assembly> pluginFilesToPluginLookup = new Dictionary<string, Assembly>(); 37 38 … … 39 40 [ClassInitialize] 40 41 public static void MyClassInitialize(TestContext testContext) { 41 loadedPlugins = PluginLoader.Assemblies.Where(PluginLoader.IsPluginAssembly).ToDictionary(a => a, GetPluginFromAssembly); 42 try { 43 loadedPlugins = PluginLoader.Assemblies.Where(PluginLoader.IsPluginAssembly).ToDictionary(a => a, GetPluginFromAssembly); 44 } catch (BadImageFormatException e) { 45 var message = string.Join(Environment.NewLine, "Could not load all types. Check if test process architecture is set to x64.", string.Empty, "Exception:", e); 46 Assert.Fail(message); 47 } 48 42 49 pluginNames = loadedPlugins.ToDictionary(a => a.Key.GetName().FullName, a => GetPluginName(a.Value)); 50 pluginVersions = loadedPlugins.ToDictionary(a => a.Key.GetName().FullName, a => GetPluginVersion(a.Value)); 43 51 44 52 foreach (Assembly pluginAssembly in loadedPlugins.Keys) { … … 65 73 var referencedAssemblies = pluginAssemblies.SelectMany(a => a.GetReferencedAssemblies()).ToList(); 66 74 67 Dictionary<string, PluginDependencyAttribute> pluginDependencies = Attribute.GetCustomAttributes(plugin, false).OfType<PluginDependencyAttribute>().ToDictionary(a => a.Dependency); 75 var pluginDependencies = Attribute.GetCustomAttributes(plugin, false).OfType<PluginDependencyAttribute>().ToArray(); 76 77 bool versionLessThan(Version a, Version b) => a.Major < b.Major || ((a.Major == b.Major) && (a.Minor <= b.Minor)); 78 79 bool compatiblePluginAvailable(string referencedAssemblyName) => pluginDependencies.Any(pd => pd.Dependency == pluginNames[referencedAssemblyName] && versionLessThan(pd.Version, pluginVersions[referencedAssemblyName])); 68 80 69 81 foreach (AssemblyName referencedAssemblyName in referencedAssemblies) { 70 82 if (IsPluginAssemblyName(referencedAssemblyName)) { 71 if (! pluginDependencies.ContainsKey(pluginNames[referencedAssemblyName.FullName]))72 errorMessage.AppendLine("Missing dependency in plugin " + plugin + " to referenced plugin " + pluginNames[referencedAssemblyName.FullName] + " .");83 if (!compatiblePluginAvailable(referencedAssemblyName.FullName)) 84 errorMessage.AppendLine("Missing dependency in plugin " + plugin + " to referenced plugin " + pluginNames[referencedAssemblyName.FullName] + " in version >= " + pluginVersions[referencedAssemblyName.FullName] + "."); 73 85 } else { //no plugin assembly => test if the assembly is delivered by another plugin 74 86 if (pluginFilesToPluginLookup.ContainsKey(referencedAssemblyName.Name)) { 75 87 string containingPluginFullName = pluginFilesToPluginLookup[referencedAssemblyName.Name].FullName; 76 if (containingPluginFullName != pluginAssembly.FullName && ! pluginDependencies.ContainsKey(pluginNames[containingPluginFullName]))77 errorMessage.AppendLine("Missing dependency in plugin " + plugin + " to plugin " + pluginNames[containingPluginFullName] + " due to a reference to " + referencedAssemblyName.FullName + ".");88 if (containingPluginFullName != pluginAssembly.FullName && !compatiblePluginAvailable(containingPluginFullName)) 89 errorMessage.AppendLine("Missing dependency in plugin " + plugin + " to plugin " + pluginNames[containingPluginFullName] + " in version >= " + pluginVersions[containingPluginFullName] + " due to a reference to " + referencedAssemblyName.FullName + "."); 78 90 } 79 91 } … … 130 142 } 131 143 144 private static Version GetPluginVersion(Type plugin) { 145 var version = new Version(); 146 PluginAttribute pluginAttribute = (PluginAttribute)Attribute.GetCustomAttribute(plugin, typeof(PluginAttribute)); 147 if (pluginAttribute != null) { 148 version = pluginAttribute.Version; 149 } 150 return version; 151 } 152 132 153 private static bool IsPluginAssemblyName(AssemblyName assemblyName) { 133 154 return pluginNames.ContainsKey(assemblyName.FullName); -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleWithOSTest.cs
r17695 r18087 69 69 // been able to identify the real cause. Presumably, execution on a Xeon and a Core i7 processor 70 70 // leads to different results. 71 Assert.AreEqual(0.99 174959007940156, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8, Environment.NewLine + "Best Quality differs.");72 Assert.AreEqual(0.9 836083751914968, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8, Environment.NewLine + "Current Average Quality differs.");73 Assert.AreEqual(0. 98298394717065463, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8, Environment.NewLine + "Current Worst Quality differs.");74 Assert.AreEqual(10 100, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"), Environment.NewLine + "Evaluated Solutions differ.");75 Assert.AreEqual(0.99 174959007940156, bestTrainingSolution.TrainingRSquared, 1E-8, Environment.NewLine + "Best Training Solution Training R² differs.");76 Assert.AreEqual(0. 8962902319942232, bestTrainingSolution.TestRSquared, 1E-8, Environment.NewLine + "Best Training Solution Test R² differs.");71 Assert.AreEqual(0.996270926227739, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8, Environment.NewLine + "Best Quality differs."); 72 Assert.AreEqual(0.95742113235788184, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8, Environment.NewLine + "Current Average Quality differs."); 73 Assert.AreEqual(0.83998301518760388, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8, Environment.NewLine + "Current Worst Quality differs."); 74 Assert.AreEqual(10600, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"), Environment.NewLine + "Evaluated Solutions differ."); 75 Assert.AreEqual(0.996270926227739, bestTrainingSolution.TrainingRSquared, 1E-8, Environment.NewLine + "Best Training Solution Training R² differs."); 76 Assert.AreEqual(0.9963422035282139, bestTrainingSolution.TestRSquared, 1E-8, Environment.NewLine + "Best Training Solution Test R² differs."); 77 77 } else { 78 Assert.AreEqual(0.9 971536312165723, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8, Environment.NewLine + "Best Qualitiy differs.");79 Assert.AreEqual(0. 98382832370544937, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8, Environment.NewLine + "Current Average Quality differs.");80 Assert.AreEqual(0. 960805603777699, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8, Environment.NewLine + "Current Worst Quality differs.");81 Assert.AreEqual(10 500, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"), Environment.NewLine + "Evaluated Solutions differ.");82 Assert.AreEqual(0.9 971536312165723, bestTrainingSolution.TrainingRSquared, 1E-8, Environment.NewLine + "Best Training Solution Training R² differs.");83 Assert.AreEqual(0.0 10190137960908724, bestTrainingSolution.TestRSquared, 1E-8, Environment.NewLine + "Best Training Solution Test R² differs.");78 Assert.AreEqual(0.9784573626949189, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8, Environment.NewLine + "Best Quality differs."); 79 Assert.AreEqual(0.82804701987417961, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8, Environment.NewLine + "Current Average Quality differs."); 80 Assert.AreEqual(0.700208975867862, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8, Environment.NewLine + "Current Worst Quality differs."); 81 Assert.AreEqual(10300, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"), Environment.NewLine + "Evaluated Solutions differ."); 82 Assert.AreEqual(0.9784573626949189, bestTrainingSolution.TrainingRSquared, 1E-8, Environment.NewLine + "Best Training Solution Training R² differs."); 83 Assert.AreEqual(0.0014620645328474451, bestTrainingSolution.TestRSquared, 1E-8, Environment.NewLine + "Best Training Solution Test R² differs."); 84 84 } 85 85 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GaussianProcessRegressionSampleTest.cs
r17526 r18087 52 52 gpr.Seed = 1618551877; 53 53 SamplesUtils.RunAlgorithm(gpr); 54 Assert.AreEqual(-9 40.70700288855619, SamplesUtils.GetDoubleResult(gpr, "NegativeLogLikelihood"));55 Assert.AreEqual(0.995 63390794061979, SamplesUtils.GetDoubleResult(gpr, "Training R²"));54 Assert.AreEqual(-992.445399028808, SamplesUtils.GetDoubleResult(gpr, "NegativeLogLikelihood"), 1e-8); 55 Assert.AreEqual(0.99559260785271853, SamplesUtils.GetDoubleResult(gpr, "Training R²"), 1e-8); 56 56 } 57 57 -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs
r16692 r18087 21 21 a.Prepare(); 22 22 a.Start(); 23 Assert.IsNull(ex );23 Assert.IsNull(ex, ex?.ToString()); 24 24 } 25 25
Note: See TracChangeset
for help on using the changeset viewer.