public MoveEvaluator(IBoardAnalyzer boardAnalyzer, IRandomProvider randomProvider, ProtoBoard protoBoard) { this._boardAnalyzer = boardAnalyzer; _randomProvider = randomProvider; this._protoBoard = protoBoard; this._setEvaluators = new List <CoordinateEvaluator>(); }
public Variant960Controller(IUserRepository _userRepository, IPersistentLoginHandler _loginHandler, IRandomProvider _randomProvider, IGameRepository _gameRepository, IMoveCollectionTransformer _moveCollectionTransformer, IGameConstructor _gameConstructor) : base(_userRepository, _loginHandler) { randomProvider = _randomProvider; gameRepository = _gameRepository; moveCollectionTransformer = _moveCollectionTransformer; gameConstructor = _gameConstructor; }
private void RandomIntConsistencyTest(IRandomProvider r) { int mintries = 1000; int maxtries = 10000; int min = 1; int max = 6; bool foundmin = false; bool foundmax = false; for (int i = 0; i < maxtries; i++) { int next = r.RandomInt(min, max); Assert.IsTrue(next >= min && next <= max); if (next == max) { foundmax = true; } if (next == min) { foundmin = true; } if (foundmax && foundmin && i > mintries) { break; } } Assert.IsTrue(foundmin); Assert.IsTrue(foundmax); }
public JobLogic(IRandomProvider randomProvider, IEventAggregator eventAggregator) { RP = randomProvider; EA = eventAggregator; //EA.GetEvent<JobEventOccuredEvent>().Subscribe(JobEventOccuredEventExecute); }
public GeneticAlgorithm( double mutationProbability, double crossoverPropability, int minPopulationSize, int maxPopulationSize, IMutation mutationOperator, ICrossover crossoverOperator, IFitnessEvaluator <TWorkload> fitnessEvaluator, IInitialPopulationCreator initialPopulationCreator, ITerminationCondition <TState> terminationCondition, ISelectionStrategy selectionStrategy, IReinsertionStrategy reinsertionStrategy, IDeploymentChromosomeFactory chromosomeFactory, TState currentState, TWorkload workload, IRandomProvider randomProvider) { MutationProbability = mutationProbability; CrossoverProbability = crossoverPropability; MinPopulationSize = minPopulationSize; MaxPopulationSize = maxPopulationSize; MutationOperator = mutationOperator; CrossoverOperator = crossoverOperator; FitnessEvaluator = fitnessEvaluator; InitialPopulationCreator = initialPopulationCreator; TerminationCondition = terminationCondition; SelectionStrategyStrategy = selectionStrategy; ReinsertionStrategy = reinsertionStrategy; ChromosomeFactory = chromosomeFactory; CurrentState = currentState; Workload = workload; RandomProvider = randomProvider; }
public static Vector3 Inside(this IRandomProvider random, AABox box) => new Vector3 ( x: box.Min.x + box.Size.x * random.GetNext(), y: box.Min.y + box.Size.y * random.GetNext(), z: box.Min.z + box.Size.z * random.GetNext() );
public void Cross_WithNoMutation_Returns_CorrectOffspring() { _mutationOperator = A.Fake <IMutation>(); _randomProvider = A.Fake <IRandomProvider>(); A.CallTo(() => _randomProvider.GetRandom()).WithAnyArguments().Returns(1); _mutationProbability = 0; ConstructGeneticAlgorithm(); var deploymentModel = CreateDeploymentModel(); var genes = new[] { new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")) }; var chromosomes = new[] { new DeploymentChromosome(deploymentModel.FeatureModel, genes), new DeploymentChromosome(deploymentModel.FeatureModel, genes), }; var result = _testGeneticAlgorithm.Mutation(chromosomes); A.CallTo(() => _mutationOperator.Mutate(null)).WithAnyArguments().MustNotHaveHappened(); CollectionAssert.AreEqual(chromosomes, result); }
public GamesController(IAppData data, INumberValidator validator, IBullsAndCowsCounter bullsAndCowsCounter, IRandomProvider randomProvider) : base(data) { this.numberValidator = validator; this.bullsAndCowsCounter = bullsAndCowsCounter; this.randomProvider = randomProvider; }
public DelayedCache(IMetrics metrics, IStoreEvents store, IVersionRegistrar registrar, IRandomProvider random, ITimeProvider time) { _metrics = metrics; _store = store; _registrar = registrar; _random = random; _time = time; _flushInterval = Configuration.Settings.FlushInterval; _endpoint = Configuration.Settings.Endpoint; _maxSize = Configuration.Settings.MaxDelayed; _flushSize = Configuration.Settings.FlushSize; _expiration = Configuration.Settings.DelayedExpiration; _streamGen = Configuration.Settings.Generator; _cts = new CancellationTokenSource(); _cacheLock = new object(); _memCache = new Dictionary <CacheKey, CachedList>(new CacheKey.EqualityComparer()); _thread = new Thread(Threaded) { IsBackground = true, Name = $"Delayed Cache Thread" }; // Add a process exit event handler to flush cached delayed events before exiting the app // Not perfect in the case of a fatal app error - but something AppDomain.CurrentDomain.ProcessExit += (sender, e) => Threaded(this); _thread.Start(this); }
public TestGeneticAlgorithm( double mutationProbability, double crossoverPropability, int minPopulationSize, int maxPopulationSize, IMutation mutationOperator, ICrossover crossoverOperator, IFitnessEvaluator <TestWorkload> fitnessEvaluator, IInitialPopulationCreator initialPopulationCreator, ITerminationCondition <TestState> terminationCondition, ISelectionStrategy selectionStrategy, IReinsertionStrategy reinsertionStrategy, IDeploymentChromosomeFactory chromosomeFactory, TestState currentState, TestWorkload workload, IRandomProvider randomProvider) : base( mutationProbability, crossoverPropability, minPopulationSize, maxPopulationSize, mutationOperator, crossoverOperator, fitnessEvaluator, initialPopulationCreator, terminationCondition, selectionStrategy, reinsertionStrategy, chromosomeFactory, currentState, workload, randomProvider) { }
public static T PickSingleItem(List <WeightedChoice <T> > weights, IRandomProvider randomProvider) { var totalWeight = WeightsAddUpToOne(weights); if (Math.Abs(1d - totalWeight) > Sensitivity) { throw new ArgumentException($"The weights for the items to choose do not add up to one. Total weight = {totalWeight}"); } var randomValue = randomProvider.NextDouble(); for (var i = 0; i < weights.Count; i++) { var currentWeight = weights[i]; if (i == weights.Count - 1) { return(currentWeight.Choice); // last item on the list so it must be chosen } randomValue -= currentWeight.Weight; if (randomValue < 0) { return(currentWeight.Choice); } } throw new Exception("Failed to make a random choice"); }
public GamesServices(IRepository <Game> games, IRepository <User> users, IRandomProvider randomProvider, IHighScoreService highScore) { this.highScore = highScore; this.games = games; this.users = users; this.randomProvider = randomProvider; }
public PhotonMappingContextSampler() { rnd = new FastRandom(); //new HaltonSequence(); TotalSamples = 0L; }
public IdCard(IRandomProvider randomProvider) { foreach (var i in Enumerable.Range(0, 8)) { Number += randomProvider.GetNumber(0, 9) * (int)System.Math.Pow(10, i); } }
public bool ImproveMap(IMap map, IRandomProvider random) { // Let's reuse directions, but let them represent quadrants // So north-> north-west var quadrant = ChooseQuadrant(random); var goaltile = new GoalTile(); (var success, var location, var openDir) = PlaceTileInQuadrant(quadrant, map, goaltile); if (!success) { return(success); } goaltile.Direction = openDir; map.Goal = location; var startTile = new StartTile(); (success, location, openDir) = PlaceTileInQuadrant(Directions.GetOpposite(quadrant), map, startTile); if (success) { startTile.Direction = openDir; map.Start = location; } return(success); }
private PasswordGeneratorInteral(RuleSet ruleSet, int length, IRandomProvider randomProvider) { if (ruleSet == null) { throw new ArgumentNullException(nameof(ruleSet)); } if (!ruleSet.IsValid) { throw new ArgumentException("Invalid Rule Set", nameof(ruleSet)); } if (randomProvider == null) { throw new ArgumentNullException(nameof(randomProvider)); } if (length < ruleSet.MinLength) { throw new ArgumentOutOfRangeException(nameof(length), length, $"{nameof(length)} is shorter than what is needed to meet the requirements ({ruleSet.MinLength})."); } Length = length; SetResults = ruleSet.Requirements.Select(r => new CharacterSetResult(r)).ToList(); RandomProvider = randomProvider; GeneratedPassword = new SecureString(); }
public static FluentBuilder <TContext> RandomSelector <TContext>( this FluentBuilder <TContext> builder, string name, IRandomProvider randomProvider = null) { return(builder.PushComposite(children => new RandomSelector <TContext>(name, children, randomProvider))); }
public RandomSampler() { rnd = //new HaltonSequence(); new FastRandom(); //new BaseQMCSequence(); }
public UniformSampler() { rnd = new FastRandom(); //new HaltonSequence(); TotalSamples = 0L; }
private void PersonMovedToIcu(Human agent, IRandomProvider random) { agent.DiesInIcu = random.Chance(Parameters.PropDieInIcu); var meanTimeInIcu = agent.DiesInIcu ? Parameters.TimeCtoD : Parameters.TimeCtoR; var rateOfExit = 1d / meanTimeInIcu; agent.DaysInIntensiveCare = random.SampleDaysInState(rateOfExit); }
public PasswordGeneratorService(IRandomProvider randomProvider) { Guard.WhenArgument(randomProvider, "randomProvider").IsNull().Throw(); this.randomProvider = randomProvider; this.Characters = Enumerable.Range(StartSymbolCode, NumberOfLastValidSymbol - StartSymbolCode).Select(c => (char)c).ToList(); }
public static FluentBuilder <TContext> Random <TContext>( this FluentBuilder <TContext> builder, string name, double threshold, IRandomProvider randomProvider = null) { return(builder.PushComposite(children => new Random <TContext>(name, children[0], threshold, randomProvider))); }
public PSSMLTSampler() { rnd = new FastRandom(); //new HaltonSequence(); TotalSamples = 0L; state = MCMCSamplerState.Initialized; }
private void IncubationEndsSevere(Human agent, IRandomProvider random) { agent.SevereToHospital = random.Chance(Parameters.PropStoH); var meanTimeToAdmission = agent.SevereToHospital ? Parameters.TimeStoH : Parameters.TimeStoC; var progressionRate = 1d / meanTimeToAdmission; agent.DaysIsolated = random.SampleDaysInState(progressionRate); }
public GameProcessor(IRandomProvider random, ICardsRepository cardsRepository) { Validated.NotNull(random, nameof(random)); Validated.NotNull(cardsRepository, nameof(cardsRepository)); this.random = random; this.cardsRepository = cardsRepository; }
public CertificatesService(IRepository <Certificate> certificates, IRandomProvider random, IUserService users, ICoursesService courses, ICertificateGenerationInfoProvider generationInfoProvider) { _certificates = certificates; _random = random; _users = users; _courses = courses; _generationInfoProvider = generationInfoProvider; }
public SpawnTurretSystem(AABox spawnArea, int count, IRandomProvider random, EntityContext context) : base(batchSize: 100) { this.spawnArea = spawnArea; this.count = count; this.random = random; this.context = context; }
public CaptchaService(ICaptchaStore captchaStore, IGraphicsProvider graphicsStrategy, IRandomProvider randomProvider) { _captchaStore = captchaStore; _graphicsStrategy = graphicsStrategy; _randomProvider = randomProvider; }
public MembershipService(IRepository <User> users, IRandomProvider randomProvider, IMessageService messageService, IRouteProvider routeProvider, IUserService userService) { _users = users; _randomProvider = randomProvider; _messageService = messageService; _routeProvider = routeProvider; _userService = userService; }
public SpawnSpaceshipSystem(AABox spawnArea, int targetCount, IRandomProvider random, EntityContext context) : base(batchSize: 100) { this.spawnArea = spawnArea; this.targetCount = targetCount; this.random = random; this.context = context; }
public InputContext(InputContext parent, int scopeid) { ParentScope = parent; Random = parent.Random; LibraryProviders = parent.LibraryProviders; ScopeId = scopeid; PrintChannel = parent.PrintChannel; }
public static Vector2 Inside(this IRandomProvider random, Rect rect) { return(rect.position + new Vector2 ( x: random.Between(0f, rect.width), y: random.Between(0f, rect.height) )); }
public Market(ITradingHistory tradingHistory, IRandomProvider randomProvider) { Contract.Requires<ArgumentNullException>(tradingHistory != null); Contract.Requires<ArgumentNullException>(randomProvider != null); History = tradingHistory; _randomProvider = randomProvider; }
protected void Start() { if (mesh == null) { Debug.LogError("[SampleController] No 'mesh' provided"); return; } if (material == null) { Debug.LogError("[SampleController] No 'material' provided"); return; } //Allocate arrays cubeData = new CubeData[cubeCount]; bucketedCubes = new BucketSet <CubeData>(bucketCount: avoidanceBucketCount, maxBucketSize: avoidanceMaxBucketSize); renderSet = new RenderSet(mesh, material, maxBatches: Mathf.CeilToInt(cubeCount / 1023f)); //Create misc stuff int numExecutors = useMultiThreading ? (System.Environment.ProcessorCount - 1) : 0; Debug.Log(string.Format("[SampleController] Staring 'TaskManager' with '{0}' executors", numExecutors)); taskManager = new TaskManager(numExecutors); avoidanceHasher = new PositionHasher(); random = new ShiftRandomProvider(); //Create tasks startTask = new StartFrameTask(); bucketCubeTask = new BucketCubeTask(bucketedCubes, avoidanceHasher); moveCubeTask = new MoveCubeTask(avoidanceHasher, bucketedCubes); respawnCubeTask = new RespawnCubeTask(random); addToRenderSetTask = new AddToRenderSetTask(renderSet); //Setup profiler timeline if (profiler != null) { completeProfilerTrack = profiler.CreateTrack <TimelineTrack>("Blocking main-thread to complete tasks"); renderProfilerTrack = profiler.CreateTrack <TimelineTrack>("Render instanced"); bucketCubesProfilerTrack = profiler.CreateTrack <TaskTimelineTrack>("Bucket cubes"); moveCubesProfilerTrack = profiler.CreateTrack <TaskTimelineTrack>("Move cubes"); respawnCubesProfilerTrack = profiler.CreateTrack <TaskTimelineTrack>("Respawn cubes"); addToRenderSetProfilerTrack = profiler.CreateTrack <TaskTimelineTrack>("Creating render batches"); profiler.StartTimers(); } //Setup initial data Rect spawnArea = MathUtils.FromCenterAndSize(Vector2.zero, spawnAreaSize); for (int i = 0; i < cubeCount; i++) { cubeData[i] = new CubeData { ID = i, Position = random.Inside(spawnArea), TimeNotHitTarget1 = 999f, TimeNotHitTarget2 = 999f } } ; }
public CatService( IDbContext database, IRandomProvider randomProvider, ICurrentTimeProvider currentTimeProvider) { this.database = database; this.randomProvider = randomProvider; this.currentTimeProvider = currentTimeProvider; }
public AdaptiveBlockSampler() { rnd = new FastRandom(); //new HaltonSequence(); TotalSamples = 0L; blocks = new List<SampleBlock>(65535); subBlocks = new List<SampleBlock>(65535); }
public VideoDirectory(VideoDirectoryConfiguration videoDirectoryConfiguration, IVideoScanner videoScanner, IRandomProvider randomProvider) { Videos = new List<Video>(); _videoDirectoryConfiguration = videoDirectoryConfiguration; _videoScanner = videoScanner; _randomProvider = randomProvider; ReinitializeVideoDirectory(); }
public LDSampler() { rnd = new HaltonSequence(); ldSequence = //new HaltonSequence(); new HaltonSequence(); // new FastRandom(); //new BaseQMCSequence(); }
public virtual void Setup() { _blacklistStore = MockRepository.GenerateStub<IBlacklistStore>(); _videoScannerProvider = MockRepository.GenerateStub<IVideoScannerProvider>(); _videoScanner = MockRepository.GenerateStub<IVideoScanner>(); _randomProvider = new RandomProvider(RandomSeed); _videoScannerProvider.Stub(x => x.GetVideoScanner(Arg<VideoScannerOptions>.Is.Anything)).Return(_videoScanner); GivenPlaylistConfiguration = new PlaylistConfigurationBuilder(); }
public Pool(PoolConfiguration poolConfiguration, IVideoScanner videoScanner, IRandomProvider randomProvider) { VideoDirectories = new List<VideoDirectory>(); Videos = new List<Video>(); _randomProvider = randomProvider; CurrentVideoDirectoryIndex = 0; _videoScanner = videoScanner; PoolConfiguration = poolConfiguration; InitializePool(); }
public void SplatProvider(IRandomProvider rnd) { Clean(); //using (var gs = Graphics.FromImage(this.canvas.Image)) for (int i = 0; i < this.canvas.Image.Width*this.canvas.Image.Height;i++) { int x = Math.Min((int) (this.canvas.Image.Width*rnd.NextFloat()), canvas.Image.Width - 1); int y = Math.Min((int) (this.canvas.Image.Height*rnd.NextFloat()), canvas.Image.Height - 1); (this.canvas.Image as Bitmap).SetPixel(x, y, //Color.FromArgb((int)(255 * rnd.NextFloat()), (int)(255 * rnd.NextFloat()), (int)(255 * rnd.NextFloat())) Color.White ); } }
public int Pick(IRandomProvider randomProvider, EnvelopePair envelopePair) { int amount = 0; int randomValue = randomProvider.Next(1, max); /* * То есть чем меньше сумма в конверте А, тем с большей вероятностью следует сменить конверт и наоборот, * несколько большая сумма в А говорит о том, что скорее следует оставить первый конверт себе. */ if (envelopePair.FirstEnvelope.Amount <= randomValue) { amount = envelopePair.SecondEnvelope.Amount; } else { amount = envelopePair.FirstEnvelope.Amount; } if (amount > max) max = amount; return amount; }
public GamesService(IHighScoreService highScore, IRepository<Game> games, IRandomProvider random) { this.highScore = highScore; this.games = games; this.random = random; }
public Sampler(IRandomProvider randomProvider) { this.randomProvider = randomProvider; }
public void Setup() { mDice = new CryptoRandomProvider(); }
public PlaylistCreator(IBlacklistStore blacklistStore = null, IVideoScannerProvider videoScannerProvider = null, IRandomProvider randomProvider = null) { _blacklistStore = blacklistStore ?? new BlacklistStore(); _videoScannerProvider = videoScannerProvider ?? new VideoScannerProvider(); _randomProvider = randomProvider ?? new RandomProvider(); }
public SamplerBase() { rnd = new HaltonSequence(); //new FastRandom(); }
protected ImagePlaneSampler(IRandomProvider p) { randomProvider = p; }
public SimpleSelectionDialog(List<Comment> data, IRandomProvider provider) { InitializeComponent(); _data = data; randomProvider = provider; }
public int Pick(IRandomProvider randomProvider, EnvelopePair envelopePair) { return envelopePair.SecondEnvelope.Amount; }
public CameraSample GetCameraSample(float x, float y, IRandomProvider sampler) { var res = new CameraSample() { imageX = x, imageY = y, }; if (sampler != null) { res.lensU = sampler.NextFloat(); res.lensV = sampler.NextFloat(); res.time = sampler.NextFloat(); } IRay ray; this.Camera.GetRay(x, y, out ray); res.EyeRay = (RayData)ray; return res; }
public MainWindow() { InitializeComponent(); randomProvider = new SystemRandomProvider(); }
public PsMltSampler() { this.rnd = new FastRandom(); }
protected BasePrimarySampler(IRandomProvider r) { rnd = r; }
public Sensor(IRandomProvider random) { this.random = random; }