/// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            try
            {
                string configurationUri = "https://devlng.blob.core.windows.net/simulation/SimulationConfiguration.json?st=2018-10-09T20%3A46%3A59Z&se=2028-10-10T20%3A46%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=c12%2Fj4Zjk0ci5PnzoC15kQ2OxzHMbeoWysfARdsg0eQ%3D";

                string jsonConfig;

                using (HttpClient client = new HttpClient())
                {
                    jsonConfig = await client.GetStringAsync(configurationUri);
                }

                SimulationConfiguration config = JsonConvert.DeserializeObject <SimulationConfiguration>(jsonConfig);

                foreach (ApiLicenseDisplay apiLicenseDisplay in config.PosDeviceLicenses)
                {
                    ActorId posActorId = new ActorId(apiLicenseDisplay.Id);

                    IPosDeviceSimulationActor posDeviceActor = ActorProxy.Create <IPosDeviceSimulationActor>(posActorId, PosServiceUri);

                    await posDeviceActor.InitializeAsync(apiLicenseDisplay.Code, config.ApplicationLicenses, PosDeviceModes.PosDeviceScans);

                    break;
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
 public bool Evaluate(Simulation ecs, SimulationConfiguration configuration)
 {
     return(_playerMatcherGroup.TryGetMatchingEntity(_player.EntityId, out var playerTuple) &&
            playerTuple.Component2.Items[0]?.Item != null &&
            _itemMatcherGroup.TryGetMatchingEntity(playerTuple.Component2.Items[0].Item.Value, out var itemTuple) &&
            (_filter == null || _filter.Evaluate(itemTuple.Entity)));
 }
Example #3
0
        public override void Initialize(Simulation simulation)
        {
            base.Initialize(simulation);

            simulationConfiguration = SimulationConfiguration.LoadConfigOrDefault();


            tileMap = TileMap.DeserializeFromFile("tilemap.dat", this);
            if (tileMap == null)
            {
                tileMap = new TileMap(100, 100, 100.0f);
                tileMap.Initialize(this);

                ValueNoise2D vn = new ValueNoise2D(tileMap.Width, tileMap.Height);
                vn.startFrequencyX = 10;
                vn.startFrequencyY = 10;
                vn.calculate();
                float[,] heightMap = vn.getHeightMap();
                for (int x = 0; x < tileMap.Width; x++)
                {
                    for (int y = 0; y < tileMap.Height; y++)
                    {
                        tileMap.SetTileType(x, y, heightMap[x, y] > 0.5 ? TileType.Land : TileType.Water);
                    }
                }

                tileMap.SerializeToFile("tilemap.dat");
            }
            creatureManager.Initialize(this);
            creatureManager.Deserialize("creatures.dat");
        }
Example #4
0
 public bool Evaluate(Simulation ecs, SimulationConfiguration configuration)
 {
     return(_itemMatcherGroup.MatchingEntities.Any(itemTuple =>
                                                   itemTuple.Component2.ActivationState == _activationState &&
                                                   (_entityConfig == null || itemTuple.Component3.Value == _entityConfig.EntityId) &&
                                                   (_filter == null || _filter.Evaluate(itemTuple.Entity))));
 }
Example #5
0
 public void Initialize(Simulation ecs, SimulationConfiguration configuration)
 {
     if (ecs.TryGetSystem <EventSystem>(out var eventSystem))
     {
         _eventSubscription = eventSystem.Subscribe <TEvent>(OnTEvent);
     }
 }
Example #6
0
        public void Initialize(Simulation ecs, SimulationConfiguration configuration)
        {
            _entityMatcherGroup = ecs.MatcherProvider.CreateMatcherGroup <TEntityType>();
            _entityMatcherGroup.MatchingEntityRemoved += MatchingEntityRemoved;

            _entityFilter?.Initialize(ecs, configuration);
        }
Example #7
0
 private void Awake()
 {
     if (!_systemConfig)
     {
         _systemConfig = (SimulationConfiguration)Resources.Load("Configs\\Darwing_config");
     }
 }
Example #8
0
        public ModelProperties MapFrom(SimulationConfiguration configuration, Model.Individual individual)
        {
            var modelProperties = _modelPropertiesTask.DefaultFor(individual.OriginData, configuration.Model);

            _batchLogger.AddDebug($"Using model method '{configuration.Model}'");
            return(modelProperties);
        }
        public async Task <IActionResult> Edit(int id, [Bind("SimulationId,Name,Time,MaxCalculationTime,Lotsize,OrderQuantity,TimeSpanForOrders,Seed,ConsecutiveRuns,DynamicKpiTimeSpan,WorkTimeDeviation,SettlingStart,SimulationEndTime,RecalculationTime,OrderRate,Id")] SimulationConfiguration simulationConfiguration)
        {
            if (id != simulationConfiguration.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(entity: simulationConfiguration);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SimulationConfigurationExists(id: simulationConfiguration.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(actionName: "Index"));
            }
            return(PartialView(viewName: "Details", model: simulationConfiguration));
        }
Example #10
0
        public void It_Should_Create_A_SimulationConfiguration_Given_A_Valid_Config_file()
        {
            var expected   = new SimulationConfiguration(100, 250, GridType.Glider, RuleSetType.Standard, 5, 5);
            var jsonLoader = new JsonConfigurationLoader(ValidFile);

            var actual = jsonLoader.Load();

            Assert.AreEqual(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(actual));
        }
Example #11
0
 public FloodingNetworkLayer(string localAddress, SimulationConfiguration configuration, Logger logger, LinkLayer link, StatisticsCollector results)
 {
     _localAddress = localAddress;
     _conf         = configuration;
     _logger       = logger;
     _linkLayer    = link;
     _statistics   = results;
     _time         = TimeHelper.GetInstance();
 }
 public AodvHelper(string localAddr, SimulationConfiguration conf, Logger logger)
 {
     _localAddress   = localAddr;
     _logger         = logger;
     RoutingTable    = new AodvRoutingTable(_localAddress, logger, conf);
     _conf           = conf;
     _time           = TimeHelper.GetInstance();
     _aodvParameters = _conf.AodvConfiguration;
 }
        public ElevatorCollection(SimulationConfiguration config)
        {
            this.Elevators = new List <Elevator>();

            for (int i = 0; i < config.NumberOfElevators; i++)
            {
                this.Elevators.Add(new Elevator(config));
            }
        }
        public void Simulation_Should_Write_The_Correct_Number_Of_Generations(SimulationConfiguration config)
        {
            var simulation = new Simulation(config, _presenter, _spyTimer.Object);

            simulation.Execute();

            var expectedWrites = config.MaximumGenerations + 1;

            _spyWriter.Verify(p => p.WriteLine(It.IsAny <string>()), Times.Exactly(expectedWrites));
        }
Example #15
0
 public void Initialize(Simulation ecs, SimulationConfiguration configuration)
 {
     if (configuration.TrySelectPlayer(_playerId, out _player) == false)
     {
         throw new ScenarioConfigurationException($"Player not found with id {_playerId}");
     }
     _playerMatcherGroup = ecs.MatcherProvider.CreateMatcherGroup <Player, ItemStorage>();
     _itemMatcherGroup   = ecs.MatcherProvider.CreateMatcherGroup <TItemType>();
     _filter?.Initialize(ecs, configuration);
 }
        protected override IAttemptResult TryCurrentVariant()
        {
            var config = new SimulationConfiguration(map, Constants.AUTO_EVO_VARIANT_SIMULATION_STEPS);

            PopulationSimulation.Simulate(config);

            var population = config.Results.GetGlobalPopulation(species);

            return(new AttemptResult(null, population));
        }
        public Logger(string path, SimulationConfiguration conf)
        {
            if (conf.EnableSatelliteLogging)
            {
                _file = new StreamWriter(path, false);
            }

            _time = TimeHelper.GetInstance();
            _conf = conf;
        }
        public LinkLayer(SimulationConfiguration conf, List <List <Satellite> > constellation, Satellite thisSatellite, Logger logger, StatisticsCollector results)
        {
            _conf          = conf;
            _constellation = constellation;
            _thisSatellite = thisSatellite;
            _logger        = logger;
            _statistics    = results;

            _lastNeighbours = new Dictionary <string, Satellite>();
        }
Example #19
0
 public AodvRoutingTable(string localAddress, Logger logger, SimulationConfiguration conf)
 {
     _table         = new Dictionary <string, AodvTableEntry>();
     _logger        = logger;
     SequenceNumber = 0;
     _rreqId        = 0;
     _time          = TimeHelper.GetInstance();
     _localAddress  = localAddress;
     _conf          = conf;
 }
Example #20
0
        public override void Initialize(Simulation simulation)
        {
            base.Initialize(simulation);

            simulationConfiguration = SimulationConfiguration.LoadConfigOrDefault();
            int poolSize = simulationConfiguration.NumThreads;

            if (poolSize == 0)
            {
                poolSize = Environment.ProcessorCount;
            }
            poolSize = Math.Max(1, poolSize);
            //ThreadPool.SetMaxThreads(poolSize, poolSize);
            taskManager = new TaskManager();
            tileMap     = TileMap.DeserializeFromFile("tilemap.dat", this);
            bool validTileMap = tileMap != null &&
                                tileMap.Width == simulationConfiguration.TileMapSizeX &&
                                tileMap.Height == simulationConfiguration.TileMapSizeY;

            if (!validTileMap)
            {
                tileMap = new TileMap(
                    simulation.SimulationConfiguration.TileMapSizeX,
                    simulation.simulationConfiguration.TileMapSizeY,
                    100.0f
                    );

                ValueNoise2D vn = new ValueNoise2D(tileMap.Width, tileMap.Height);
                vn.startFrequencyX = 10;
                vn.startFrequencyY = 10;
                vn.calculate();
                float[,] heightMap = vn.getHeightMap();
                for (int x = 0; x < tileMap.Width; x++)
                {
                    for (int y = 0; y < tileMap.Height; y++)
                    {
                        tileMap.SetTileType(x, y, heightMap[x, y] > SimulationConfiguration.WaterPercentage ? TileType.Land : TileType.Water);
                    }
                }

                tileMap.SerializeToFile("tilemap.dat");
            }
            tileMap.Initialize(this);

            CreatureManager deserialized = CreatureManager.Deserialize("creatures/creatures.dat", this);

            if (deserialized != null)
            {
                creatureManager = deserialized;
            }
            else
            {
                creatureManager.Initialize(this);
            }
        }
 public AodvNetworkLayer(string localAddress, SimulationConfiguration configuration, Logger logger, LinkLayer link, StatisticsCollector results)
 {
     _aodvHelper     = new AodvHelper(localAddress, configuration, logger);
     _localAddress   = localAddress;
     _logger         = logger;
     _time           = TimeHelper.GetInstance();
     _linkLayer      = link;
     _statistics     = results;
     _conf           = configuration;
     _aodvParameters = _conf.AodvConfiguration;
 }
Example #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config">The configuration for this simulation</param>
 public Simulation(string name, SimulationConfiguration config = null)
 {
     if (config == null)
     {
         Config = new SimulationConfiguration();
     }
     else
     {
         Config = config;
     }
 }
 public WorldSimulateStateRequest(
     WorldSimulationStateService worldSimulationStateService,
     WorldPersistanceService worldPersistanceService,
     SimulationConfiguration simulationConfiguration,
     WorldAsset indexGenerator) : base()
 {
     _serializer = new SharpSerializer();
     _worldPersistanceService = worldPersistanceService;
     _simulationConfiguration = simulationConfiguration;
     _indexGenerator          = indexGenerator;
 }
Example #24
0
        public PredictiveRelocatorPluggin(ElevatorCollection elevators, SimulationConfiguration config)
        {
            this.Elevaotrs = elevators;

            this.RequestsDistribution = new uint[config.BuildingFloors];

            // Keep track of a rolling average of the past half an hour
            this.N = (config.TotalResidents * config.AverageRequestsPerResidentPerDay) / 48;

            this.RequestQueue = new Queue <Request>();
        }
        public void Simulation_Should_Wait_For_Expected_Time_Between_Generations(SimulationConfiguration config)
        {
            var simulation = new Simulation(config, _presenter, _spyTimer.Object);

            simulation.Execute();

            var expectedAnimationDelay = config.AnimationDelay;
            var expectedTimesCalled    = config.MaximumGenerations + 1;

            _spyTimer.Verify(t => t.Sleep(expectedAnimationDelay), Times.Exactly(expectedTimesCalled));
        }
        public async Task <IActionResult> Create([Bind("SimulationId,Name,Time,MaxCalculationTime,Lotsize,OrderQuantity,TimeSpanForOrders,Seed,ConsecutiveRuns,DynamicKpiTimeSpan,WorkTimeDeviation,SettlingStart,SimulationEndTime,RecalculationTime,OrderRate,Id")] SimulationConfiguration simulationConfiguration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entity: simulationConfiguration);
                await _context.SaveChangesAsync();

                return(RedirectToAction(actionName: "Index"));
            }
            return(PartialView(viewName: "Create", model: simulationConfiguration));
        }
        public static PlantSimulationOptions ToSimulationOptions(this SimulationConfiguration configuration)
        {
            return(new PlantSimulationOptions());

            /*return new PlantSimulationOptions
             * {
             *  Id = configuration.Id,
             *  Simulation = ToSimulationOptions(configuration.Simulation),
             *  Environment = ToSimulationEnvironmentOptions(configuration.Environment),
             *  Plant = ToSimulationPlantOptions(configuration.Plant)
             * };*/
        }
Example #28
0
        public Elevator(SimulationConfiguration config)
        {
            this.Speed         = config.ElevatorSpeed;
            this.EnergyPerTick = config.EnergyPerTick;

            this.LoadingTime = config.LoadingTime;

            this.TopFloor = config.BuildingFloors;

            this.Waypoints        = new List <ElevatorWaypoint>();
            this.PickedUpRequests = new List <Request>();
            this.OnTheWayRequests = new List <Request>();
        }
Example #29
0
        public Network(ref List <List <Satellite> > constellation, ref SimulationConfiguration conf, Satellite thisSatellite, Logger logger, StatisticsCollector results)
        {
            _linkLayer = new LinkLayer(conf, constellation, thisSatellite, logger, results);

            if (conf.NetworkLayer == "AODV")
            {
                _networkLayer = new AodvNetworkLayer(thisSatellite.LocalAddress, conf, logger, _linkLayer, results);
            }
            else if (conf.NetworkLayer.Equals("Flooding", StringComparison.OrdinalIgnoreCase))
            {
                _networkLayer = new FloodingNetworkLayer(thisSatellite.LocalAddress, conf, logger, _linkLayer, results);
            }
        }
Example #30
0
 public PlayerSystem(SimulationConfiguration configuration,
                     IEntityFactoryProvider entityFactoryProvider,
                     GraphSystem graphSystem,
                     MovementSystem movementSystem,
                     [InjectOptional] List <IPlayerSystemBehaviour> playerSystemBehaviours)
 {
     _configuration           = configuration;
     _entityFactoryProvider   = entityFactoryProvider;
     _graphSystem             = graphSystem;
     _movementSystem          = movementSystem;
     _playterSystemBehaviours = playerSystemBehaviours;
     _playerEntityMapping     = new Dictionary <int, int>();
 }