Example #1
0
        public bool InitRandomPopulation(List <string> selectedTraces)
        {
            ConfigurationGenerator cg = new ConfigurationGenerator();

            for (int i = 0; i < populationSize; i++)
            {
                population.Add(cg.RandomConfig(individualID.ToString()));
            }
            allConfigurations.AddRange(population);

            var results = sim.Run(population, selectedTraces);

            for (int i = 0; i < population.Count; i++)
            {
                population[i] = new GeneticIndividual(population[i], 0.0, 0.0, 0.0);

                for (int j = 0; j < selectedTraces.Count; j++)
                {
                    ((GeneticIndividual)population[i]).Ipc    += 1.0 / results[i + population.Count * j].ipc;
                    ((GeneticIndividual)population[i]).Power  += results[i + population.Count * j].power;
                    ((GeneticIndividual)population[i]).Energy += results[i + population.Count * j].energy;
                }
                if (selectedTraces.Count > 1)
                {
                    ((GeneticIndividual)population[i]).Ipc    /= selectedTraces.Count;
                    ((GeneticIndividual)population[i]).Power  /= selectedTraces.Count;
                    ((GeneticIndividual)population[i]).Energy /= selectedTraces.Count;
                }
                nsgaPopulation.Add(new GeneticIndividual(population[i], ((GeneticIndividual)population[i]).Ipc, ((GeneticIndividual)population[i]).Power, ((GeneticIndividual)population[i]).Energy));
            }
            return(true);
        }
        public void GenerateProjectConfiguration()
        {
            if (this.SelectedProjectHasUnsavedChanges)
            {
                // first save project if there are unsaved changes
                this.SaveProject(out bool successfullySaved, true);

                // break if the project could not be saved => do not generate config
                if (successfullySaved == false)
                {
                    return;
                }
            }

            // create copy of selected project and start generation of configs
            var copyOfSelectedProject = (ProjectModel)SelectedProject.Clone();

            try
            {
                ConfigurationGenerator.GenerateAllConfigs(copyOfSelectedProject.Layers, copyOfSelectedProject.Name.ToLowerInvariant());
                this.uiService.DisplayBottomMessage(MessageSeverity.Success, $"All Configs were generated successfully.");
            }
            catch (Exception ex)
            {
                this.uiService.DisplayBottomMessage(MessageSeverity.Error, $"Configs could not be generated: {ex}");
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var config = ConfigurationGenerator.GenerateBasicSystemConfiguration();

            config.AddBme280Config();
            config.AddBme680Config();
        }
Example #4
0
        private List <Configuration> CreateRandomConfigurations(int count)
        {
            int configurationIndex = 0;
            ConfigurationGenerator configurationGenerator = new ConfigurationGenerator();
            var result = new List <Configuration>();

            for (int i = 0; i < count; i++)
            {
                result.Add(configurationGenerator.RandomConfig(string.Format("configuration-{0}", configurationIndex++)));
            }
            return(result);
        }
Example #5
0
        public Configuration Mutate(Configuration child)
        {
            ConfigurationGenerator cg = new ConfigurationGenerator();

            for (int i = 0; i < child.Parameters.Count; i++)
            {
                if (r.NextDouble() < mutationRate)
                {
                    cg.RandomizeParameter(i, child);
                }
            }
            return(child);
        }
        public void ShouldFailIfElementForUnspecifiedEnvironment()
        {
            XElement config = new XElement("stuff",
                new XAttribute(Console.BuildConfigForAttribute, "live,nosystest"),
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement("speed", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, "systest"), "some text")));

            try {
                var confgen = new ConfigurationGenerator(config);
                confgen.ConfigForEnvironment("live");
                Assert.Fail("expected configuration exception");
            } catch (NoSuchEnvironmentException) {
            }
        }
        public void ShouldExtractEnvironmentsForGeneration()
        {
            XElement config = new XElement("stuff",
                new XAttribute(Console.BuildConfigForAttribute, "dev, systest1, systest2"),
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement("speed", "some text")));

            var confgen = new ConfigurationGenerator(config);
            var environments = confgen.Environments;

            Assert.IsTrue(environments.Contains("dev"));
            Assert.IsTrue(environments.Contains("systest1"));
            Assert.IsTrue(environments.Contains("systest2"));
        }
        public void ShouldIncludeElementsForCurrentEnvironment()
        {
            XElement config = new XElement("stuff",
                new XAttribute(Console.BuildConfigForAttribute, "live,systest"),
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement("speed", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, "systest"), "some text")));

            var confgen = new ConfigurationGenerator(config);
            XElement generated = confgen.ConfigForEnvironment("systest");

            XElement expected = new XElement("stuff",
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement("speed", "some text")));
            Assert.AreEqual(expected.ToString(), generated.ToString());
        }
        public void ShouldGenerateIdenticalXml()
        {
            XElement config = new XElement("stuff",
                new XAttribute(Console.BuildConfigForAttribute, "dev, systest1, systest2"),
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement ("speed", "some text")));

            XElement expectedConfig = new XElement("stuff",
                new XElement("dome", new XAttribute("name", "7")),
                new XElement("hill", new XElement ("speed", "some text")));

            var confgen = new ConfigurationGenerator(config);
            XElement generated = confgen.ConfigForEnvironment("someenv");

            Assert.AreEqual(expectedConfig.ToString(), generated.ToString());
        }
        private void AssertOutputForInput(string input, string env, string output)
        {
            XElement config = XElement.Parse(input);

            var confgen = new ConfigurationGenerator(config);
            var generated = confgen.ConfigForEnvironment(env);

            XElement expected = XElement.Parse(output);

            Assert.That(generated.ToString(), Is.EqualTo(expected.ToString()));
        }
        public void VariablesShouldBeSetOnlyForEnvironment()
        {
            var xml =
            @"<stuff xmlns:conf=""http://schemas.refractalize.org/confgen"" conf:with-vars=""true"" conf:environments=""dev,live"">
            <conf:var name=""host"" conf:for=""dev"">localhost</conf:var>
            <conf:var name=""host"" conf:for=""live"">example.com</conf:var>
            <host value=""{host}""/>
            </stuff>";

            XElement config = XElement.Parse(xml);

            var confgen = new ConfigurationGenerator(config);
            var devGenerated = confgen.ConfigForEnvironment("dev");
            var liveGenerated = confgen.ConfigForEnvironment("live");

            var devXml =
            @"<stuff>
            <host value=""localhost""/>
            </stuff>";
            var liveXml =
            @"<stuff>
            <host value=""example.com""/>
            </stuff>";

            Assert.That(devGenerated.ToString(), Is.EqualTo(XElement.Parse(devXml).ToString()));
            Assert.That(liveGenerated.ToString(), Is.EqualTo(XElement.Parse(liveXml).ToString()));
        }
Example #12
0
 public static Contracts.IConfigurationGenerator GetConfigurationGenerator(string solutionName, string contractsFilePath)
 {
     return(ConfigurationGenerator.Create(SolutionProperties.Create(solutionName, contractsFilePath)));
 }
        private static ISessionFactory CreateSessionFactory()
        {
            ConfigurationGenerator configurationGenerator = new ConfigurationGenerator(new AutoMapGenerator());

            return(configurationGenerator.Generate().BuildSessionFactory());
        }
Example #14
0
        private async Task <int> OnExecuteAsync(CancellationToken cancellationToken)
        {
            IDisposable appium = null;

            Logger.Level = LogLevel;

            if (Directory.Exists(BaseWorkingDirectory))
            {
                Directory.Delete(BaseWorkingDirectory, true);
            }

            Directory.CreateDirectory(BaseWorkingDirectory);
            Logger.SetWorkingDirectory(BaseWorkingDirectory);

            try
            {
                if (!Node.IsInstalled)
                {
                    throw new Exception("Your environment does not appear to have Node installed. This is required to run Appium");
                }

                Logger.WriteLine($"Build and Test artifacts will be stored at {BaseWorkingDirectory}", LogLevel.Detailed);

                ValidatePaths();

                var headBin   = Path.Combine(BaseWorkingDirectory, "bin", "device");
                var uiTestBin = Path.Combine(BaseWorkingDirectory, "bin", "uitest");

                Directory.CreateDirectory(headBin);
                Directory.CreateDirectory(uiTestBin);

                // HACK: The iOS SDK will mess up the generated app output if a Separator is not at the end of the path.
                headBin   += Path.DirectorySeparatorChar;
                uiTestBin += Path.DirectorySeparatorChar;

                var appProject = CSProjFile.Load(DeviceProjectPathInfo, new DirectoryInfo(headBin), Platform);
                if (!await appProject.IsSupported())
                {
                    throw new PlatformNotSupportedException($"{appProject.Platform} is not supported on this machine. Please check that you have the correct build dependencies.");
                }

                await appProject.Build(Configuration, cancellationToken).ConfigureAwait(false);

                var uitestProj = CSProjFile.Load(UITestProjectPathInfo, new DirectoryInfo(uiTestBin), string.Empty);
                await uitestProj.Build(Configuration, cancellationToken).ConfigureAwait(false);

                if (cancellationToken.IsCancellationRequested)
                {
                    return(0);
                }

                await ConfigurationGenerator.GenerateTestConfig(headBin, uiTestBin, appProject.Platform, ConfigurationPath, BaseWorkingDirectory, AndroidSdk, DisplayGeneratedConfig, cancellationToken);

                if (!await Appium.Install(cancellationToken))
                {
                    return(0);
                }

                appium = await Appium.Run(BaseWorkingDirectory).ConfigureAwait(false);

                await DotNetTool.Test(UITestProjectPathInfo.FullName, uiTestBin, Configuration?.Trim(), Path.Combine(BaseWorkingDirectory, "results"), cancellationToken)
                .ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.Message);
                return(1);
            }
            finally
            {
                appium?.Dispose();

                var binDir = Path.Combine(BaseWorkingDirectory, "bin");
                if (Directory.Exists(binDir))
                {
                    Directory.Delete(binDir, true);
                }
            }

            return(Logger.HasErrors ? 1 : 0);
        }