public void FindsSimpleSolution() { var random = new SystemRandom(42); var factory = new SimpleGenomeFactory(random); var selection = new BinaryTournamentSelection(random); Environment environment = new SimpleEnvironment(); Ranking ranking = new CrowdingDistanceRanking(1); var evolution = new Evolution(100, 0.4, 0.4, factory, selection); var genomes = evolution.Initialize(); double score = 0; for (int i = 0; i < 100; i++) { // evaluate var population = genomes.Select(environment.Evaluate).ToList(); // rank ranking.Rank(population); // keep score var best = population[0]; Console.WriteLine(best); score = best.GetScore(0); // evolve genomes = evolution.Evolve(population, random); } Assert.Greater(score, 30); }
public void RollOne([Values(0.1f, 0.35f, 0.5f, 0.6f, 0.8f, 1f)] float chance) { var dependentRandom = DependentRandom.Create(); var systemRandom = new SystemRandom(12323542); var dependentRandomLongestRow = 0; var systemRandomLongestRow = 0; var iterationCount = 1000000; var key = "someEventKey" + chance; var dependentInfo = new RollInfo(); var systemInfo = new RollInfo(); for (var i = 0; i < iterationCount; i++) { dependentInfo.Update(dependentRandom.Roll(key, chance)); systemInfo.Update(systemRandom.GetValue() < chance); } Assert.AreEqual(chance, dependentInfo.GetChance(), Delta); Assert.AreEqual(chance, systemInfo.GetChance(), Delta); Console.WriteLine(string.Format("Dependent random chance = {0}, max row = {1}", dependentInfo.GetChance(), dependentInfo.MaxRow)); Console.WriteLine(string.Format("System random chance = {0}, max row = {1}", systemInfo.GetChance(), systemInfo.MaxRow)); }
public void HalfClosedFloatUnitTenBucketDistribution(int sampleSizePercentage) { ValidateHalfClosedFloatUnitBucketDistribution(SystemRandom.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(SplitMix64.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XorShift128Plus.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XoroShiro128Plus.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XorShift1024Star.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); }
public void ClosedDoubleUnitThousandBucketDistribution(int sampleSizePercentage) { ValidateClosedDoubleUnitBucketDistribution(SystemRandom.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(SplitMix64.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XorShift128Plus.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XoroShiro128Plus.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XorShift1024Star.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); }
public void ClosedDoubleUnitRange(int sampleSizePercentage) { ValidateClosedDoubleUnitRange(10000, SystemRandom.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, SplitMix64.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XorShift128Plus.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XoroShiro128Plus.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XorShift1024Star.Create(seed), sampleSizePercentage); }
public void RollTestSystemRandom() { var generator = new SystemRandom(); var die = new Die(generator, DieShape.D6); die.Roll(); Assert.True(die.FaceValue >= 1 && die.FaceValue <= (int)DieShape.D6); }
public ElitistEvolution(int populationSize, int archiveSize, GenomeFactory factory, Environment environment, int numAttributes, TextWriter writer) { var random = new SystemRandom(42); var selection = new BinaryTournamentSelection(random); this.numAttributes = numAttributes; this.archiveSize = archiveSize; this.evolution = new Evolution(populationSize, 0.5, 0.4, factory, selection); this.environment = environment; this.ranking = new CrowdingDistanceRanking(numAttributes); this.writer = writer; }
private void DoSend(MoneyTransfer moneyTransfer) { try { // I didn't want to introduce an actual external bank, so that's why you see this nice construct :) _moneyTransferOptions[SystemRandom.Next(0, 9)](moneyTransfer); } catch (Exception) { CompensatingActionBecauseOfFailedMoneyTransfer(moneyTransfer); } }
public BenchmarkBVH() { Scene scene = new Scene(); Mesh mesh = new(@"C:\Users\MMXXXVIII\Things\CodingStuff\C#\EchoRenderer\EchoRenderer\Assets\Models\BlenderBMW\BlenderBMW.obj"); scene.children.Add(new MeshObject(mesh, new Matte())); traceQueries = new TraceQuery[65536]; occludeQueries = new OccludeQuery[65536]; IRandom random = new SystemRandom(42); const float Radius = 9f; const float Height = 5f; for (int i = 0; i < traceQueries.Length; i++) { Float2 point = new Float2(MathF.Sqrt(random.Next1()) * Radius, random.Next1() * Height); Float3 position = point.X_Y.RotateXZ(random.Next1() * 360f); Float3 target = Float3.CreateY(0.6f) + random.NextInSphere(0.25f); if (random.Next1() < 0.01f) { Float3 offset = (target - position) / 2f; target = position; position += offset; } Ray ray = new Ray(position, (target - position).Normalized); traceQueries[i] = ray; occludeQueries[i] = ray; } Pairs = new[] { new Pair(new PreparedScene(scene, new ScenePrepareProfile { AggregatorProfile = new AggregatorProfile { AggregatorType = typeof(BoundingVolumeHierarchy) } }), "Regular"), new Pair(new PreparedScene(scene, new ScenePrepareProfile { AggregatorProfile = new AggregatorProfile { AggregatorType = typeof(QuadBoundingVolumeHierarchy) } }), "Quad") }; }
public NonRegisteredTransactorUpgradeSender(IKeychain keychain, AbstractLogger logger, string localStorageDirPath, string guestControllerHostUrl, string guestControllerSpoofedIpAddress, string oneIdClientId, ICoroutineManager coroutineManager) { SystemStopwatchFactory stopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, stopwatchFactory, wwwFactory); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator directoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); SystemRandom random = new SystemRandom(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, localStorageDirPath); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, directoryCreator, documentCollectionFactory, databaseCorruptionHandler); GuestControllerClient guestControllerClient = new GuestControllerClient(wwwCallFactory, guestControllerSpoofedIpAddress, database, "NoSWID", guestControllerHostUrl, oneIdClientId, logger); nrtUpgradeSender = new NrtUpgradeSender(logger, guestControllerClient); }
public NewAccountValidator(IKeychain keychain, AbstractLogger logger, string localStorageDirPath, string guestControllerHostUrl, string guestControllerSpoofedIpAddress, string oneIdClientId, ICoroutineManager coroutineManager) { this.logger = logger; SystemStopwatchFactory stopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, stopwatchFactory, wwwFactory); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator directoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); SystemRandom random = new SystemRandom(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, localStorageDirPath); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, directoryCreator, documentCollectionFactory, databaseCorruptionHandler); guestControllerClient = new GuestControllerClient(wwwCallFactory, guestControllerSpoofedIpAddress, database, string.Empty, guestControllerHostUrl, oneIdClientId, logger); }
public void GivenChromosome_WithOneSection_WhenReplaceOneGene_ThenShouldReturnNull() { var random = new SystemRandom(Environment.TickCount); var parameterSet = new ParameterSet(); var chromosome = new SortedSubsetChromosome(new List <ICollection <int> >() { new int[] { 1, 2, 3, 4, 5, 6 } }); var conflictDetectors = new List <INeighborhoodConflictDetector>() { AllRightConflictDetector.Instance }; var mutation = new ReplaceOneGeneMutation(random, parameterSet, conflictDetectors); var result = mutation.Mutate(chromosome); result.Should().BeNull(); }
public void TestEvolution() { Profiler.Reset(); var random = new SystemRandom(42); var configuration = new ZeldaConfiguration(random); var factory = new ZeldaGenomeFactory(configuration); var initialVariables = new VariableAssignment(); var environment = new ZeldaEnvironment(new[] { initialVariables }, 10000); var writer = File.CreateText("stats.csv"); var evolution = new ElitistEvolution(200, 100, factory, environment, ZeldaIndividual.NumAttributes, writer); var genomes = evolution.Initialize(); // TODO Jonas: replace fixed weight multirank optimization by dynamic randomized weighting // i.e. in some generations prefer some attribute over others // evolve for (int i = 0; i < 1000; i++) { Profiler.BeginFrame(); Console.WriteLine("gen " + i); genomes = evolution.Evolve(genomes, random); Profiler.EndFrame(); } writer.Close(); var best = (ZeldaIndividual)evolution.GetBest(new TestComparer()); Console.WriteLine(best); var crawler = best.Crawler; var builder = new DotBuilder(); crawler.Express(builder); // TODO: output genome to puzzle unit test (puzzle building statements) Profiler.ExportToUnityProfileAnalyzer("w:\\EvolutionTest-TestEvolution.pdata"); }
public void CreateIndividual() { Profiler.Reset(); Profiler.BeginFrame(); var random = new SystemRandom(42); var configuration = new ZeldaConfiguration(random); var factory = new ZeldaGenomeFactory(configuration); var initialVariables = new VariableAssignment(); var environment = new ZeldaEnvironment(new[] { initialVariables }, 10000); var example = factory.CreateGenome(); var individual = environment.Evaluate(example); Console.WriteLine("test: " + individual); Profiler.EndFrame(); Profiler.ExportToUnityProfileAnalyzer("w:\\EvolutionTest-CreateIndividual.pdata"); }
public GeolocationGetter(AbstractLogger logger, ICoroutineManager coroutineManager, string mixApiHostUrl, string mixClientToken, string localStorageDirPath, IKeychain keychain) { SystemStopwatchFactory stopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, stopwatchFactory, wwwFactory); JsonWebCallEncryptor webCallEncryptor = new JsonWebCallEncryptor(); MixWebCallQueue webCallQueue = new MixWebCallQueue(); NoOpSessionRefresher sessionRefresher = new NoOpSessionRefresher(); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator databaseDirectoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); string sdkDatabasesDirectory = databaseDirectoryCreator.GetSdkDatabasesDirectory(); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, sdkDatabasesDirectory); SystemRandom random = new SystemRandom(); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, databaseDirectoryCreator, documentCollectionFactory, databaseCorruptionHandler); MixWebCallFactory mixWebCallFactory = new MixWebCallFactory(logger, mixApiHostUrl, wwwCallFactory, webCallEncryptor, string.Empty, string.Empty, mixClientToken, webCallQueue, sessionRefresher, epochTime, database); geolocationGetter = new Disney.Mix.SDK.Internal.GeolocationGetter(logger, mixWebCallFactory); }
private static void CreateDependencies(string guestControllerHostUrl, string guestControllerSpoofedIpAddress, string mixApiHostUrl, string oneIdClientId, string mixClientToken, string clientVersion, ICoroutineManager coroutineManager, IKeychain keychain, AbstractLogger logger, string localStorageDirPath, string languageCode, out ISessionLogin sessionLogin, out ISessionRegister sessionRegister, out ISessionRestorer sessionRestorer, out ISessionReuser sessionReuser, out IOfflineSessionCreator offlineSessionCreator) { SystemStopwatchFactory systemStopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, systemStopwatchFactory, wwwFactory); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator databaseDirectoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); string sdkDatabasesDirectory = databaseDirectoryCreator.GetSdkDatabasesDirectory(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, sdkDatabasesDirectory); SystemRandom random = new SystemRandom(); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, databaseDirectoryCreator, documentCollectionFactory, databaseCorruptionHandler); MixWebCallQueue webCallQueue = new MixWebCallQueue(); MixSessionStartWebCallEncryptor sessionStartEncryptor = new MixSessionStartWebCallEncryptor(); MixWebCallFactoryFactory mixWebCallFactoryFactory = new MixWebCallFactoryFactory(logger, mixApiHostUrl, mixClientToken, wwwCallFactory, webCallQueue, epochTime, database); NotificationDispatcher notificationDispatcher = new NotificationDispatcher(); NotificationQueue notificationQueue = new NotificationQueue(notificationDispatcher); SessionStatus sessionStatus = new SessionStatus(isPaused: true); NoOpSessionRefresher sessionRefresher = new NoOpSessionRefresher(); JsonWebCallEncryptor webCallEncryptor = new JsonWebCallEncryptor(); IMixWebCallFactory webCallFactory = mixWebCallFactoryFactory.Create(webCallEncryptor, string.Empty, string.Empty, sessionRefresher); RsaEncryptor rsaEncryptor = new RsaEncryptor(); MixEncryptor encryptor = new MixEncryptor(); MixWebCallEncryptorFactory webCallEncryptorFactory = new MixWebCallEncryptorFactory(encryptor); SessionRefresherFactory sessionRefresherFactory = new SessionRefresherFactory(webCallQueue); MixSessionStarter mixSessionStarter = new MixSessionStarter(logger, rsaEncryptor, database, webCallEncryptorFactory, sessionStartEncryptor, mixWebCallFactoryFactory, keychain, coroutineManager, sessionRefresherFactory); IStopwatch pollCountdownStopwatch = systemStopwatchFactory.Create(); GuestControllerClientFactory guestControllerClientFactory = new GuestControllerClientFactory(wwwCallFactory, guestControllerSpoofedIpAddress, database, guestControllerHostUrl, oneIdClientId, logger); SessionFactory sessionFactory = new SessionFactory(logger, coroutineManager, pollCountdownStopwatch, epochTime, databaseCorruptionHandler, notificationQueue, notificationDispatcher, sessionStatus, mixWebCallFactoryFactory, webCallEncryptorFactory, mixSessionStarter, keychain, sessionRefresherFactory, guestControllerClientFactory, random, encryptor, fileSystem, wwwCallFactory, localStorageDirPath, clientVersion, databaseDirectoryCreator, documentCollectionFactory, database); AgeBandBuilder ageBandBuilder = new AgeBandBuilder(logger, webCallFactory); Disney.Mix.SDK.Internal.RegistrationConfigurationGetter registrationConfigurationGetter = new Disney.Mix.SDK.Internal.RegistrationConfigurationGetter(logger, guestControllerClientFactory, ageBandBuilder); LegalMarketingErrorsBuilder legalMarketingErrorsBuilder = new LegalMarketingErrorsBuilder(registrationConfigurationGetter, languageCode, epochTime); sessionLogin = new SessionLogin(logger, guestControllerClientFactory, mixSessionStarter, database, legalMarketingErrorsBuilder, sessionFactory); sessionRegister = new SessionRegister(logger, guestControllerClientFactory, database, mixSessionStarter, sessionFactory); sessionRestorer = new SessionRestorer(logger, guestControllerClientFactory, database, sessionFactory); sessionReuser = new SessionReuser(logger, database, mixSessionStarter, sessionFactory); offlineSessionCreator = new OfflineSessionCreator(logger, sessionFactory, database); }
public RegistrationConfigurationGetter(IKeychain keychain, AbstractLogger logger, string localStorageDirPath, string guestControllerHostUrl, string guestControllerSpoofedIpAddress, string oneIdClientId, ICoroutineManager coroutineManager, string mixApiHostUrl, string mixClientToken) { SystemStopwatchFactory stopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, stopwatchFactory, wwwFactory); JsonWebCallEncryptor webCallEncryptor = new JsonWebCallEncryptor(); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator directoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); SystemRandom random = new SystemRandom(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, localStorageDirPath); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, directoryCreator, documentCollectionFactory, databaseCorruptionHandler); MixWebCallQueue webCallQueue = new MixWebCallQueue(); NoOpSessionRefresher sessionRefresher = new NoOpSessionRefresher(); MixWebCallFactory webCallFactory = new MixWebCallFactory(logger, mixApiHostUrl, wwwCallFactory, webCallEncryptor, string.Empty, string.Empty, mixClientToken, webCallQueue, sessionRefresher, epochTime, database); AgeBandBuilder ageBandBuilder = new AgeBandBuilder(logger, webCallFactory); GuestControllerClientFactory guestControllerClientFactory = new GuestControllerClientFactory(wwwCallFactory, guestControllerSpoofedIpAddress, database, guestControllerHostUrl, oneIdClientId, logger); registrationConfigurationGetter = new Disney.Mix.SDK.Internal.RegistrationConfigurationGetter(logger, guestControllerClientFactory, ageBandBuilder); }
public void FindsSimpleSolution() { var random = new SystemRandom(42); var factory = new SimpleGenomeFactory(random); var selection = new BinaryTournamentSelection(random); Environment environment = new SimpleEnvironment(); Ranking ranking = new CrowdingDistanceRanking(1); var writer = File.CreateText("stats.csv"); var evolution = new ElitistEvolution(100, 20, factory, environment, 1, writer); var genomes = evolution.Initialize(); double score = 0; for (int i = 0; i < 100; i++) { genomes = evolution.Evolve(genomes, random); } writer.Close(); Assert.Greater(score, 30); }
public IRandom GetRandom() { switch (seedSource) { case SeedSource.SystemTime: switch (randomType) { case RandomType.System: return(SystemRandom.Create()); case RandomType.Unity: return(UnityRandom.Create()); case RandomType.SplitMix64: return(SplitMix64.Create()); case RandomType.XorShift128Plus: return(XorShift128Plus.Create()); case RandomType.XorShift1024Star: return(XorShift1024Star.Create()); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create()); default: throw new NotImplementedException(); } case SeedSource.Numerical: switch (randomType) { case RandomType.System: return(SystemRandom.Create(seedNumber)); case RandomType.Unity: return(UnityRandom.Create(seedNumber)); case RandomType.SplitMix64: return(SplitMix64.Create(seedNumber)); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(seedNumber)); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(seedNumber)); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(seedNumber)); default: throw new NotImplementedException(); } case SeedSource.Textual: switch (randomType) { case RandomType.System: return(SystemRandom.Create(seedText)); case RandomType.Unity: return(UnityRandom.Create(seedText)); case RandomType.SplitMix64: return(SplitMix64.Create(seedText)); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(seedText)); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(seedText)); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(seedText)); default: throw new NotImplementedException(); } case SeedSource.Random: switch (randomType) { case RandomType.System: return(SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.Unity: return(UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.SplitMix64: return(SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>())); default: throw new NotImplementedException(); } case SeedSource.RandomAndSystemTime: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } default: throw new NotImplementedException(); } case SeedSource.RandomAndNumerical: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } default: throw new NotImplementedException(); } case SeedSource.RandomAndTextual: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } default: throw new NotImplementedException(); } default: throw new NotImplementedException(); } }
protected override void Finally() { SystemTimer.Reset(); SystemRandom.Reset(); }
public void GivenSystemRandom_WhenGetIntWithMinMax_ThenShouldReturnProper(int minValue, int maxValue) { var random = new SystemRandom(Environment.TickCount); TestRandomGetInt(random, minValue, maxValue); }
public void GivenSystemRandom_WhenGetDoubleWithMinMax_ThenShouldReturnProper(double minValue, double maxValue) { var random = new SystemRandom(Environment.TickCount); TestRandomGetDouble(random, minValue, maxValue); }
private static void Main2(string[] args) { NLogConfigManager.CreateFileConfig(); Logger = NLog.LogManager.GetCurrentClassLogger(); if (args.Length != 1) { throw new InvalidUserParamsException( "RandoopBare takes exactly one argument but was " + "given the following arguments:" + System.Environment.NewLine + Util.PrintArray(args));; } // Parse XML file with generation parameters. string configFileName = ConfigFileName.Parse(args[0]); RandoopConfiguration config = LoadConfigFile(configFileName); // Set the random number generator. if (config.randomSource == RandomSource.SystemRandom) { Logger.Debug("Randoom seed = " + config.randomseed); SystemRandom random = new SystemRandom(); random.Init(config.randomseed); Enviroment.Random = random; } else { Util.Assert(config.randomSource == RandomSource.Crypto); Logger.Debug("Randoom seed = new System.Security.Cryptography.RNGCryptoServiceProvider()"); Enviroment.Random = new CryptoRandom(); } if (!Directory.Exists(config.outputdir)) { throw new InvalidUserParamsException("output directory does not exist: " + config.outputdir); } Collection <Assembly> assemblies = Misc.LoadAssemblies(config.assemblies); ////[email protected] for substituting MessageBox.Show() - start ////Instrument instrumentor = new Instrument(); //foreach (FileName asm in config.assemblies) //{ // Instrument.MethodInstrument(asm.fileName, "System.Windows.Forms.MessageBox::Show", "System.Logger.Debug"); //} ////[email protected] for substituting MessageBox.Show() - end IReflectionFilter filter1 = new VisibilityFilter(config); ConfigFilesFilter filter2 = new ConfigFilesFilter(config); Logger.Debug("========== REFLECTION PATTERNS:"); filter2.PrintFilter(Console.Out); IReflectionFilter filter = new ComposableFilter(filter1, filter2); Collection <Type> typesToExplore = ReflectionUtils.GetExplorableTypes(assemblies); PlanManager planManager = new PlanManager(config); planManager.builderPlans.AddEnumConstantsToPlanDB(typesToExplore); planManager.builderPlans.AddConstantsToTDB(config); Logger.Debug("========== INITIAL PRIMITIVE VALUES:"); planManager.builderPlans.PrintPrimitives(Console.Out); StatsManager stats = new StatsManager(config); Logger.Debug("Analyzing assembly."); ActionSet actions; try { actions = new ActionSet(typesToExplore, filter); } catch (EmpytActionSetException) { string msg = "After filtering based on configuration files, no remaining methods or constructors to explore."; throw new InvalidUserParamsException(msg); } Logger.Debug("Generating tests."); RandomExplorer explorer = new RandomExplorer(typesToExplore, filter, true, config.randomseed, config.arraymaxsize, stats, actions); ITimer t = new Timer(config.timelimit); try { explorer.Explore(t, planManager, config.methodweighing, config.forbidnull, true, config.fairOpt); } catch (Exception e) { Logger.Error("Explorer raised exception {0}", e.ToString()); throw; } }