public PolynomialChaosAnalyzer(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IPCCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations, bool shouldFactorizeMatrices) { this.shouldFactorizeMatrices = shouldFactorizeMatrices; this.childAnalyzer = embeddedAnalyzer; this.provider = provider; this.model = model; this.subdomains = subdomains; this.expansionOrder = coefficientsProvider.ExpansionOrder; this.simulations = simulations; this.childAnalyzer.ParentAnalyzer = this; this.matrices = new Dictionary <int, IMatrix2D <double> > [coefficientsProvider.NoOfMatrices + 1]; this.randomNumbers = new double[simulations][]; this.coefficientsProvider = coefficientsProvider; NormalDistribution n = new NormalDistribution(); n.Mu = 0; n.Sigma = 1; string[] randoms = new string[simulations]; for (int i = 0; i < simulations; i++) { randomNumbers[i] = new double[expansionOrder]; for (int j = 0; j < expansionOrder; j++) { randomNumbers[i][j] = n.NextDouble(); } randoms[i] = randomNumbers[i][0].ToString(); } //File.WriteAllLines(String.Format(@"randoms.txt", expansionOrder), randoms); }
//public MonteCarloAnalyzer(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary<int, ISolverSubdomain> subdomains, double[] stochasticDomain, int expansionOrder, int simulations) public MonteCarloAnalyzer(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, GaussianFileStochasticCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations) { this.childAnalyzer = embeddedAnalyzer; this.provider = provider; this.model = model; this.subdomains = subdomains; this.expansionOrder = expansionOrder; this.simulations = simulations; this.childAnalyzer.ParentAnalyzer = this; //this.matrices = new Dictionary<int, IMatrix2D<double>>(subdomains.Count); this.matrices = new Dictionary <int, IMatrix2D <double> > [expansionOrder + 1]; this.randomNumbers = new double[simulations][]; this.coefficientsProvider = coefficientsProvider; //this.stochasticDomain = stochasticDomain; NormalDistribution n = new NormalDistribution(); n.Mu = 0; n.Sigma = 1; string[] randoms = new string[simulations]; for (int i = 0; i < simulations; i++) { randomNumbers[i] = new double[expansionOrder]; for (int j = 0; j < expansionOrder; j++) { randomNumbers[i][j] = n.NextDouble(); } randoms[i] = randomNumbers[i][0].ToString(); } File.WriteAllLines(String.Format(@"randoms.txt", expansionOrder), randoms); }
internal static IEnumerable <Analyzer> GetAnalyzers() { #if AUTOANALYSIS_EXTENSIBILITY // Iterate through all assemblies in the analyzers directory. if (!Directory.Exists(AnalyzersDirectory)) { yield break; } string[] candidateAssemblies = Directory.GetFiles(AnalyzersDirectory, "*.dll", SearchOption.TopDirectoryOnly); foreach (string candidateAssembly in candidateAssemblies) { Assembly assembly = Assembly.LoadFrom(candidateAssembly); if (assembly != null) { AnalyzerProviderAttribute attr = (AnalyzerProviderAttribute)assembly.GetCustomAttribute(typeof(AnalyzerProviderAttribute)); if (attr != null && attr.ProviderType != null) { // Create an instance of the provider. IAnalyzerProvider analyzerProvider = Activator.CreateInstance(attr.ProviderType) as IAnalyzerProvider; if (analyzerProvider != null) { foreach (Analyzer analyzer in analyzerProvider.GetAnalyzers()) { yield return(analyzer); } } } } } #else yield break; #endif }
public MockObjectFactory(ISonarQubeServer server, ITargetsInstaller targetsInstaller, IAnalyzerProvider analyzerProvider, IBuildWrapperInstaller buildWrapperInstaller) { this.server = server; this.targetsInstaller = targetsInstaller; this.analyzerProvider = analyzerProvider; this.buildWrapperInstaller = buildWrapperInstaller; }
public MonteCarloAnalyzerWithStochasticMaterial(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IStochasticMaterialCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations, StiffnessMatrixProductionMode stiffnessMatrixProductionMode, string fileNameForLogging, string stiffnessMatrixPath) : this(model, provider, embeddedAnalyzer, subdomains, coefficientsProvider, expansionOrder, simulations, fileNameForLogging) { this.stiffnessMatrixPath = stiffnessMatrixPath; this.stiffnessMatrixProductionMode = stiffnessMatrixProductionMode; }
public MockObjectFactory(ISonarQubeServer server, ITargetsInstaller targetsInstaller, IAnalyzerProvider analyzerProvider, IRulesetGenerator rulesetGenerator) { this.server = server; this.targetsInstaller = targetsInstaller; this.analyzerProvider = analyzerProvider; this.rulesetGenerator = rulesetGenerator; }
public LinearAnalyzer(IStructuralModel model, ISolver solver, IAnalyzerProvider provider) { this.model = model; this.solver = solver; this.linearSystems = solver.LinearSystems; this.provider = provider; }
/// <summary> /// Searches the specified assembly for Analyzer instances and loads them. /// </summary> /// <param name="analyzerAssembly">The assembly to consume.</param> protected void ConsumeAssembly(Assembly analyzerAssembly) { if (analyzerAssembly == null) { throw new ArgumentNullException(nameof(analyzerAssembly)); } AnalyzerLoadContext loadContext = new AnalyzerLoadContext(); AnalyzerProviderAttribute attr = (AnalyzerProviderAttribute)analyzerAssembly.GetCustomAttribute(typeof(AnalyzerProviderAttribute)); if (attr != null && attr.ProviderType != null) { IAnalyzerProvider analyzerProvider = Activator.CreateInstance(attr.ProviderType) as IAnalyzerProvider; if (analyzerProvider != null) { foreach (Analyzer analyzer in analyzerProvider.GetAnalyzers()) { loadContext.Reset(analyzer); OnAnalyzerLoaded(loadContext); if (loadContext.ShouldRun) { _analyzers.Add(loadContext.Analyzer); } } } } }
public MonteCarloAnalyzerWithStochasticMaterial(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IStochasticMaterialCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations, int blockSize, StiffnessMatrixProductionMode stiffnessMatrixProductionMode, string fileNameForLogging, string stiffnessMatrixPath, string randomsReadFileName, int simulationStartFrom) : this(model, provider, embeddedAnalyzer, subdomains, coefficientsProvider, expansionOrder, simulations, blockSize, stiffnessMatrixProductionMode, fileNameForLogging, stiffnessMatrixPath) { this.randomsReadFileName = randomsReadFileName; this.simulationStartFrom = simulationStartFrom; }
/// <summary> /// Initializes a new instance of <see cref="IndexProvider"/>. /// </summary> /// <param name="settings">The settings.</param> /// <param name="analyzerProvider">The analyzer provider.</param> public IndexProvider(IAnalyzerProvider analyzerProvider, LuceneSettings settings) { Prevent.ParameterNull(analyzerProvider, nameof(analyzerProvider)); Prevent.ParameterNull(settings, nameof(settings)); _analyzerProvider = analyzerProvider; _settings = settings; }
protected NsDepCopDiagnosticAnalyzerBase(ITypeDependencyEnumerator typeDependencyEnumerator) { if (typeDependencyEnumerator == null) { throw new ArgumentNullException(nameof(typeDependencyEnumerator)); } _analyzerProvider = CreateDependencyAnalyzerProvider(typeDependencyEnumerator); _projectFileResolver = CreateProjectFileResolver(); }
public MonteCarloAnalyzerWithStochasticMaterial(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IStochasticMaterialCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations) { this.childAnalyzer = embeddedAnalyzer; this.provider = provider; this.model = model; this.subdomains = subdomains; this.expansionOrder = expansionOrder; this.simulations = simulations; this.childAnalyzer.ParentAnalyzer = this; //this.matrices = new Dictionary<int, IMatrix2D<double>>(subdomains.Count); this.matrices = new Dictionary <int, IMatrix2D <double> > [expansionOrder + 1]; this.coefficientsProvider = coefficientsProvider; //this.stochasticDomain = stochasticDomain; }
private bool FetchArgumentsAndRulesets(ProcessedArgs args, TeamBuildSettings settings, out IDictionary <string, string> serverSettings, out AnalyzerSettings analyzerSettings) { string hostUrl = args.GetSetting(SonarProperties.HostUrl); serverSettings = null; analyzerSettings = null; ISonarQubeServer server = this.factory.CreateSonarQubeServer(args, this.logger); try { this.logger.LogInfo(Resources.MSG_FetchingAnalysisConfiguration); // Respect sonar.branch setting if set string projectBranch = null; args.TryGetSetting(SonarProperties.ProjectBranch, out projectBranch); // Fetch the SonarQube project properties serverSettings = server.GetProperties(args.ProjectKey, projectBranch); // Generate the FxCop rulesets this.logger.LogInfo(Resources.MSG_GeneratingRulesets); GenerateFxCopRuleset(server, args.ProjectKey, projectBranch, "csharp", "cs", "fxcop", Path.Combine(settings.SonarConfigDirectory, FxCopCSharpRuleset)); GenerateFxCopRuleset(server, args.ProjectKey, projectBranch, "vbnet", "vbnet", "fxcop-vbnet", Path.Combine(settings.SonarConfigDirectory, FxCopVBNetRuleset)); IAnalyzerProvider analyzerProvider = this.factory.CreateAnalyzerProvider(this.logger); Debug.Assert(analyzerProvider != null, "Factory should not return null"); analyzerSettings = analyzerProvider.SetupAnalyzers(server, settings, args.ProjectKey, projectBranch); } catch (WebException ex) { if (Utilities.HandleHostUrlWebException(ex, hostUrl, this.logger)) { return(false); } throw; } finally { Utilities.SafeDispose(server); } return(true); }
/// <summary> /// Internal constructor for testing /// </summary> public TeamBuildPreProcessor(ILogger logger, ISonarQubeServerFactory serverFactory, ITargetsInstaller targetInstaller, IAnalyzerProvider analyzerInstaller) { if (logger == null) { throw new ArgumentNullException("logger"); } if (serverFactory == null) { throw new ArgumentNullException("serverFactory"); } if (targetInstaller == null) { throw new ArgumentNullException("targetInstaller"); } if (analyzerInstaller == null) { throw new ArgumentNullException("analyzerProvider"); } this.logger = logger; this.serverFactory = serverFactory; this.targetInstaller = targetInstaller; this.analyzerProvider = analyzerInstaller; }
public CachingAnalyzerProvider(IAnalyzerProvider analyzerProvider, IDateTimeProvider dateTimeProvider, TimeSpan cacheTimeSpan) : base(dateTimeProvider, cacheTimeSpan) { _analyzerProvider = analyzerProvider ?? throw new ArgumentNullException(nameof(analyzerProvider)); }
private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, out IDictionary <string, string> serverSettings, out List <AnalyzerSettings> analyzersSettings) { serverSettings = null; analyzersSettings = new List <AnalyzerSettings>(); try { this.logger.LogInfo(Resources.MSG_FetchingAnalysisConfiguration); // Respect sonar.branch setting if set string projectBranch = null; args.TryGetSetting(SonarProperties.ProjectBranch, out projectBranch); // Fetch the SonarQube project properties serverSettings = server.GetProperties(args.ProjectKey, projectBranch); // Fetch installed plugins IEnumerable <string> availableLanguages = server.GetAllLanguages(); foreach (PluginDefinition plugin in plugins) { if (!availableLanguages.Contains(plugin.Language)) { continue; } // Fetch project quality profile string qualityProfile; if (!server.TryGetQualityProfile(args.ProjectKey, projectBranch, args.Organization, plugin.Language, out qualityProfile)) { this.logger.LogDebug(Resources.RAP_NoQualityProfile, plugin.Language, args.ProjectKey); continue; } // Fetch rules (active and not active) IList <ActiveRule> activeRules = server.GetActiveRules(qualityProfile); if (!activeRules.Any()) { this.logger.LogDebug(Resources.RAP_NoActiveRules, plugin.Language); continue; } IList <string> inactiveRules = server.GetInactiveRules(qualityProfile, plugin.Language); // Generate fxcop rulesets this.logger.LogInfo(Resources.MSG_GeneratingRulesets); string fxCopPath = Path.Combine(settings.SonarConfigDirectory, string.Format(FxCopRulesetName, plugin.Language)); if (plugin.Language.Equals(VBNetLanguage)) { GenerateFxCopRuleset("fxcop-vbnet", activeRules, fxCopPath); } else { GenerateFxCopRuleset("fxcop", activeRules, fxCopPath); } // Generate Roslyn analyzers settings and rulesets IAnalyzerProvider analyzerProvider = this.factory.CreateRoslynAnalyzerProvider(this.logger); Debug.Assert(analyzerProvider != null, "Factory should not return null"); // Will be null if the processing of server settings and active rules resulted in an empty ruleset AnalyzerSettings analyzer = analyzerProvider.SetupAnalyzer(settings, serverSettings, activeRules, inactiveRules, plugin.Language); if (analyzer != null) { analyzersSettings.Add(analyzer); } } } catch (WebException ex) { if (Utilities.HandleHostUrlWebException(ex, args.SonarQubeUrl, this.logger)) { return(false); } throw; } finally { Utilities.SafeDispose(server); } return(true); }
public MonteCarloAnalyzerWithStochasticMaterial(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IStochasticMaterialCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations, string fileNameForLogging) : this(model, provider, embeddedAnalyzer, subdomains, coefficientsProvider, expansionOrder, simulations) { this.fileNameForLogging = fileNameForLogging; }
public VRFMonteCarloAnalyzerWithStochasticMaterial(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, PowerSpectrumTargetEvaluatorCoefficientsProvider coefficientsProvider, IStochasticMaterialCoefficientsProvider approximateCoefficientsProvider, int expansionOrder, int simulations, int blockSize, StiffnessMatrixProductionMode stiffnessMatrixProductionMode, string fileNameForLogging, string stiffnessMatrixPath) : this(model, provider, embeddedAnalyzer, subdomains, coefficientsProvider, approximateCoefficientsProvider, expansionOrder, simulations, stiffnessMatrixProductionMode, fileNameForLogging, stiffnessMatrixPath) { this.blockSize = blockSize; }
public PolynomialChaosAnalyzer(Model model, IAnalyzerProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains, IPCCoefficientsProvider coefficientsProvider, int expansionOrder, int simulations) : this(model, provider, embeddedAnalyzer, subdomains, coefficientsProvider, expansionOrder, simulations, true) { }