Ejemplo n.º 1
0
        public void AggreteResults()
        {
            var _resultContext = ResultContext.GetContext(remoteResultCtxString);

            var aggregator = new ResultAggregator(_resultContext);

            aggregator.BuildResults(1);
        }
Ejemplo n.º 2
0
 private void WriteToDB(Collector agent, bool writeResultsToDB)
 {
     if (agent.saveToDB.Value && writeResultsToDB)
     {
         using (var ctx = ResultContext.GetContext(resultCon: agent.Config.GetOption <DBConnectionString>().Value))
         {
             ctx.SimulationOrders.AddRange(entities: simulationOrders);
             ctx.SaveChanges();
             ctx.Dispose();
         }
     }
 }
Ejemplo n.º 3
0
 private void LogToDB(Collector agent, bool writeToDatabase)
 {
     if (agent.saveToDB.Value && writeToDatabase)
     {
         using (var ctx = ResultContext.GetContext(resultCon: agent.Config.GetOption <DBConnectionString>().Value))
         {
             ctx.Kpis.AddRange(entities: StockValuesOverTime);
             ctx.SaveChanges();
             ctx.Dispose();
         }
     }
 }
 private void LogToDB(bool writeResultsToDB)
 {
     if (Collector.saveToDB.Value && writeResultsToDB)
     {
         using (var ctx = ResultContext.GetContext(resultCon: Collector.Config.GetOption <DBConnectionString>().Value))
         {
             ctx.SimulationOperations.AddRange(entities: simulationWorkschedules);
             ctx.Kpis.AddRange(entities: Kpis);
             ctx.SaveChanges();
             ctx.Dispose();
         }
     }
 }
Ejemplo n.º 5
0
        public void CheckOrganizationDegreeFromResults()
        {
            var simNumber      = 9;
            var dbContext      = MasterDBContext.GetContext(testCtxString);
            var dbResultCtx    = ResultContext.GetContext(testResultCtxString);
            var dbGeneratorCtx = DataGeneratorContext.GetContext(testGeneratorCtxString);

            var transitionMatrixGeneratorVerifier = new TransitionMatrixGeneratorVerifier();

            transitionMatrixGeneratorVerifier.VerifySimulatedData(dbContext, dbGeneratorCtx, dbResultCtx, simNumber);

            Assert.True(true);
        }
 private void LogToDB(bool writeResultsToDB)
 {
     if (Collector.saveToDB.Value && writeResultsToDB)
     {
         using (var ctx = ResultContext.GetContext(resultCon: Collector.Config.GetOption <DBConnectionString>().Value))
         {
             ctx.TaskItems.AddRange(entities:  _taskArchive.Select(x => x.Value).ToArray()[0].ToList().Cast <TaskItem>());
             ctx.TaskItems.AddRange(entities: _taskArchive.Select(x => x.Value).ToArray()[1].ToList().Cast <TaskItem>());
             ctx.SaveChanges();
             ctx.Kpis.AddRange(entities: Collector.Kpis);
             ctx.SaveChanges();
             ctx.Dispose();
         }
     }
 }
Ejemplo n.º 7
0
        public void ResetResultsDB(string connectionString, string resultConnectionString)

        {
            MasterDBContext masterCtx = MasterDBContext.GetContext(connectionString);

            masterCtx.Database.EnsureDeleted();
            masterCtx.Database.EnsureCreated();
            MasterDBInitializerTruck.DbInitialize(masterCtx, ModelSize.Medium, ModelSize.Small, ModelSize.Small, 3, true);

            ResultContext results = ResultContext.GetContext(resultCon: resultConnectionString);

            results.Database.EnsureDeleted();
            results.Database.EnsureCreated();
            ResultDBInitializerBasic.DbInitialize(results);
        }
Ejemplo n.º 8
0
 private void LogToDB(bool writeResultsToDB)
 {
     if (Collector.saveToDB.Value && writeResultsToDB)
     {
         using (var ctx = ResultContext.GetContext(resultCon: Collector.Config.GetOption <DBConnectionString>().Value))
         {
             ctx.SimulationJobs.AddRange(entities: simulationJobsForDb);
             ctx.SaveChanges();
             ctx.SimulationResourceSetups.AddRange(entities: simulationResourceSetupsForDb);
             ctx.SaveChanges();
             ctx.Kpis.AddRange(entities: Collector.Kpis);
             ctx.SaveChanges();
             ctx.Dispose();
         }
     }
 }
Ejemplo n.º 9
0
        public void GenerateData() //Generierung für Simulation direkt im Testfall, wo Simulation durchgeführt wird
        {
            for (var i = 5; i < 6; i++)
            {
                var approachId     = i;
                var generatorDbCtx = DataGeneratorContext.GetContext(testGeneratorCtxString);
                var approach       = ApproachRepository.GetApproachById(generatorDbCtx, approachId);

                /*var parameterSet = ParameterSet.Create(new object[] { Dbms.GetNewMasterDataBase(false, "Master40") });
                 * var dataBase = parameterSet.GetOption<DataBase<ProductionDomainContext>>();*/

                var dbContext     = MasterDBContext.GetContext(testCtxString);
                var resultContext = ResultContext.GetContext(testResultCtxString);

                var generator = new MainGenerator();
                generator.StartGeneration(approach, dbContext, resultContext, true);
            }
            Assert.True(true);
        }
Ejemplo n.º 10
0
        private void WriteToDB(Collector agent, bool writeResultsToDB)
        {
            if (writeResultsToDB)
            {
                Collector.messageHub.ProcessingUpdate(finishedOrderParts, openOrderParts,
                                                      $"Progress({100} %) Finalizing Steps. Write to DB and Shutdown!"
                                                      , totalOrders);
            }

            if (agent.saveToDB.Value && writeResultsToDB)
            {
                using (var ctx = ResultContext.GetContext(resultCon: agent.Config.GetOption <DBConnectionString>().Value))
                {
                    ctx.SimulationOrders.AddRange(entities: simulationOrders);
                    ctx.SaveChanges();
                    ctx.Kpis.AddRange(this.Collector.Kpis);
                    ctx.SaveChanges();
                    ctx.Dispose();
                }
            }
        }
Ejemplo n.º 11
0
        public void InitializeRemote()
        {
            ResultContext results = ResultContext.GetContext(resultCon: remoteResultCtxString);

            results.Database.EnsureDeleted();
            results.Database.EnsureCreated();
            ResultDBInitializerBasic.DbInitialize(results);

            MasterDBContext masterCtx = MasterDBContext.GetContext(remoteMasterCtxString);

            masterCtx.Database.EnsureDeleted();
            masterCtx.Database.EnsureCreated();
            MasterDBInitializerTruck.DbInitialize(masterCtx, resourceModelSize: ModelSize.Small, setupModelSize: ModelSize.Small, ModelSize.Small, 3, false);

            HangfireDBContext dbContext = new HangfireDBContext(options: new DbContextOptionsBuilder <HangfireDBContext>()
                                                                .UseSqlServer(connectionString: hangfireCtxString)
                                                                .Options);

            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();
            HangfireDBInitializer.DbInitialize(context: dbContext);
        }
        private void LogToDB(bool writeResultsToDB)
        {
            if (Collector.saveToDB.Value && writeResultsToDB)
            {
                using var ctx = ResultContext.GetContext(resultCon: Collector.Config.GetOption <DBConnectionString>().Value);

                //var refTask = _taskArchive.First();
                //CreateTaskItem(
                //    new FCreateTaskItem(
                //        JobType.OPERATION,
                //        refTask.Resource,
                //        refTask.Start, refTask.End, refTask.Capability, refTask.Operation, refTask.GroupId));
                //
                //ResourceUtilization();

                ctx.TaskItems.AddRange(entities: _taskArchive);
                ctx.SaveChanges();
                ctx.Kpis.AddRange(entities: Kpis);
                ctx.SaveChanges();
                ctx.Dispose();
            }
        }
Ejemplo n.º 13
0
        public async Task SystemTestAsync(int approachId
                                          , int orderQuantity
                                          , int maxBucketSize
                                          , long throughput
                                          , int seed
                                          , double arrivalRate
                                          , long simulationEnd)
        {
            ResultContext           ctxResult  = ResultContext.GetContext(resultCon: testResultCtxString);
            ProductionDomainContext masterCtx  = ProductionDomainContext.GetContext(testCtxString);
            DataGeneratorContext    dataGenCtx = DataGeneratorContext.GetContext(testGeneratorCtxString);

            var approach  = ApproachRepository.GetApproachById(dataGenCtx, approachId);
            var generator = new MainGenerator();
            await Task.Run(() =>
                           generator.StartGeneration(approach, masterCtx, ctxResult));

            var simContext = new AgentSimulation(DBContext: masterCtx, messageHub: new ConsoleHub());
            var simConfig  = ArgumentConverter.ConfigurationConverter(ctxResult, 1);

            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Trace, LogLevel.Trace);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PRIORITY, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.SCHEDULING, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.DISPOPRODRELATION, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PROPOSAL, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.INITIALIZE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.JOB, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.ENQUEUE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.JOBSTATE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace, LogLevel.Trace);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AKKA, LogLevel.Warn);

            var dataGenSim = new DB.GeneratorModel.Simulation();

            dataGenSim.ApproachId = approachId;
            dataGenSim.StartTime  = DateTime.Now;
            await Task.Run(() =>
            {
                dataGenCtx.Simulations.AddRange(dataGenSim);
                dataGenCtx.SaveChanges();
            });

            // update customized Configuration
            simConfig.AddOption(new DBConnectionString(testResultCtxString));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arrivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: orderQuantity));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: throughput));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 2880));
            simConfig.ReplaceOption(new Seed(value: seed));
            simConfig.ReplaceOption(new SettlingStart(value: 0));
            simConfig.ReplaceOption(new SimulationEnd(value: simulationEnd));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new MaxBucketSize(value: maxBucketSize));
            simConfig.ReplaceOption(new SimulationNumber(value: dataGenSim.Id));
            simConfig.ReplaceOption(new DebugSystem(value: true));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.0));
            // anpassen der Lieferzeiten anhand der Erwarteten Durchlaufzeit.
            simConfig.ReplaceOption(new MinDeliveryTime(80));
            simConfig.ReplaceOption(new MaxDeliveryTime(150));

            await Task.Run(() =>
                           ArgumentConverter.ConvertBackAndSave(ctxResult, simConfig, dataGenSim.Id));

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);


            if (simulation.IsReady())
            {
                // Start simulation
                var sim = simulation.RunAsync();
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
                dataGenSim.FinishTime           = DateTime.Now;
                dataGenSim.FinishedSuccessfully = sim.IsCompletedSuccessfully;
                await Task.Run(() =>
                               dataGenCtx.SaveChanges());

                System.Diagnostics.Debug.WriteLine("################################# Simulation has finished with number " + dataGenSim.Id);
                Assert.True(condition: sim.IsCompleted);
            }
        }
Ejemplo n.º 14
0
 public AgentCore()
 {
     _context       = ProductionDomainContext.GetContext(ConfigurationManager.AppSettings[DEFAULT_CONNECTION]);
     _resultContext = ResultContext.GetContext(ConfigurationManager.AppSettings[RESULT_CONNECTION]);
 }
Ejemplo n.º 15
0
        //[InlineData(SimulationType.DefaultSetup, 1, Int32.MaxValue, 1920, 169, ModelSize.Small, ModelSize.Small)]
        public async Task CentralSystemTest()
        {
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Trace, LogLevel.Trace);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Warn, LogLevel.Warn);

            var simtulationType = SimulationType.Central;
            var seed            = 169;
            var throughput      = 1920;
            var arrivalRate     = 0.015;

            //Create Master40Data
            var masterPlanContext = ProductionDomainContext.GetContext(masterCtxString);

            masterPlanContext.Database.EnsureDeleted();
            masterPlanContext.Database.EnsureCreated();
            MasterDBInitializerTruck.DbInitialize(masterPlanContext, ModelSize.Medium, ModelSize.Medium, ModelSize.Small, 3, false);

            //CreateMaster40Result
            var masterPlanResultContext = ResultContext.GetContext(masterResultCtxString);

            masterPlanResultContext.Database.EnsureDeleted();
            masterPlanResultContext.Database.EnsureCreated();
            ResultDBInitializerBasic.DbInitialize(masterPlanResultContext);

            //Reset GanttPLan DB?
            var ganttPlanContext = GanttPlanDBContext.GetContext(GanttPlanCtxString);

            ganttPlanContext.Database.ExecuteSqlRaw("EXEC sp_MSforeachtable 'DELETE FROM ? '");

            //Synchronisation GanttPlan
            GanttPlanOptRunner.RunOptAndExport("Init");

            var simContext = new GanttSimulation(GanttPlanCtxString, masterCtxString, messageHub: new ConsoleHub());
            var simConfig  = ArgumentConverter.ConfigurationConverter(masterPlanResultContext, 1);

            // update customized Items
            simConfig.AddOption(new DBConnectionString(masterResultCtxString));
            simConfig.ReplaceOption(new KpiTimeSpan(240));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new SimulationKind(value: simtulationType));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arrivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: 141));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: throughput));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 4000));
            simConfig.ReplaceOption(new Seed(value: seed));
            simConfig.ReplaceOption(new SettlingStart(value: 2880));
            simConfig.ReplaceOption(new SimulationEnd(value: 10080));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new DebugSystem(value: false));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.2));

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);

            //emtpyResultDBbySimulationNumber(simNr: simConfig.GetOption<SimulationNumber>());

            var simWasReady = false;

            if (simulation.IsReady())
            {
                // set for Assert
                simWasReady = true;
                // Start simulation
                var sim = simulation.RunAsync();
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
            }

            Assert.True(condition: simWasReady);
        }
Ejemplo n.º 16
0
        public async Task SystemTestAsync(SimulationType simulationType, int simNr, int maxBucketSize, long throughput,
                                          int seed
                                          , ModelSize resourceModelSize, ModelSize setupModelSize
                                          , double arrivalRate, bool distributeSetupsExponentially)
        {
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Trace, LogLevel.Trace);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PRIORITY, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.SCHEDULING, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.DISPOPRODRELATION, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PROPOSAL, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.INITIALIZE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.JOB, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.ENQUEUE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.JOBSTATE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace, LogLevel.Trace);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AKKA, LogLevel.Warn);

            //CreateMaster40Result
            var masterPlanResultContext = ResultContext.GetContext(testResultCtxString);

            masterPlanResultContext.Database.EnsureDeleted();
            masterPlanResultContext.Database.EnsureCreated();
            ResultDBInitializerBasic.DbInitialize(masterPlanResultContext);

            var masterCtx = ProductionDomainContext.GetContext(testCtxString);

            masterCtx.Database.EnsureDeleted();
            masterCtx.Database.EnsureCreated();
            MasterDBInitializerTruck.DbInitialize(masterCtx, resourceModelSize, setupModelSize, ModelSize.Small, 3, distributeSetupsExponentially);
            //InMemoryContext.LoadData(source: _masterDBContext, target: _ctx);
            var simContext = new AgentSimulation(DBContext: masterCtx, messageHub: new ConsoleHub());
            var simConfig  = Simulation.CLI.ArgumentConverter.ConfigurationConverter(_ctxResult, 1);

            // update customized Items
            simConfig.AddOption(new DBConnectionString(testResultCtxString));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new KpiTimeSpan(1440));
            simConfig.ReplaceOption(new SimulationKind(value: simulationType));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arrivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: 150));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: throughput));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 1920));
            simConfig.ReplaceOption(new Seed(value: seed));
            simConfig.ReplaceOption(new SettlingStart(value: 0));
            simConfig.ReplaceOption(new SimulationEnd(value: 10080));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new MaxBucketSize(value: maxBucketSize));
            simConfig.ReplaceOption(new SimulationNumber(value: simNr));
            simConfig.ReplaceOption(new DebugSystem(value: false));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.2));
            simConfig.ReplaceOption(new MinDeliveryTime(1920));
            simConfig.ReplaceOption(new MaxDeliveryTime(2880));

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);

            emtpyResultDBbySimulationNumber(simNr: simConfig.GetOption <SimulationNumber>());

            var simWasReady = false;

            if (simulation.IsReady())
            {
                // set for Assert
                simWasReady = true;
                // Start simulation
                var sim = simulation.RunAsync();
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
            }

            Assert.True(condition: simWasReady);
        }