コード例 #1
0
        /// <summary>
        /// Creates ResourcesAgents based on current Model and add them to the SimulationContext
        /// </summary>
        /// <param name="configuration">Environment.Configuration</param>
        private void CreateResourceAgents(Configuration configuration)
        {
            WorkTimeGenerator randomWorkTime = WorkTimeGenerator.Create(configuration: configuration);
            var maxBucketSize             = configuration.GetOption <MaxBucketSize>().Value;
            var timeConstraintQueueLength = configuration.GetOption <TimeConstraintQueueLength>().Value;

            // Get All Resources that have an Agent (that are limited)
            //var resources = _dBContext.Resources.ToList(); // all Resources
            var limitedResources = _dBContext.Resources.Where(x => x.IsPhysical).ToList(); // all Limited Resources


            foreach (var resource in limitedResources)
            {
                var capabilityProviders = GetCapabilityProviders(resource);
                System.Diagnostics.Debug.WriteLine($"Creating Resource: {resource.Name} with {capabilityProviders.Count} capabilities");
                //TODO: !IMPORTANT Max bucket size dynamic by Setup Count?

                var capabilityProviderDefinition = new FCapabilityProviderDefinition(workTimeGenerator: randomWorkTime
                                                                                     , resource: resource
                                                                                     , capabilityProvider: capabilityProviders
                                                                                     , maxBucketSize: maxBucketSize
                                                                                     , timeConstraintQueueLength: timeConstraintQueueLength
                                                                                     , debug: _debugAgents);
                _simulation.SimulationContext
                .Tell(message: Directory.Instruction.Default
                      .CreateMachineAgents
                      .Create(message: capabilityProviderDefinition, target: ActorPaths.HubDirectory.Ref)
                      , sender: ActorPaths.HubDirectory.Ref);
            }
        }
コード例 #2
0
 private static IBehaviour Default(WorkTimeGenerator workTimeGenerator, List <M_ResourceCapabilityProvider> capabilityProvider, int timeConstraintQueueLength, int resourceId)
 {
     //TODO - create config item.
     return(new Default(timeConstraintQueueLength: timeConstraintQueueLength //480
                        , resourceId: resourceId
                        , workTimeGenerator: workTimeGenerator
                        , capabilityProvider: capabilityProvider));
 }
 public Default(int planingJobQueueLength, int fixedJobQueueSize, WorkTimeGenerator workTimeGenerator, ToolManager toolManager, SimulationType simulationType = SimulationType.None) : base(childMaker: null, simulationType: simulationType)
 {
     this._processingQueue = new JobQueueItemLimited(limit: fixedJobQueueSize);
     this._planingQueue    = new JobQueueTimeLimited(limit: planingJobQueueLength);
     this._agentDictionary = new AgentDictionary();
     _workTimeGenerator    = workTimeGenerator;
     _toolManager          = toolManager;
 }
コード例 #4
0
 private static IBehaviour Default(WorkTimeGenerator workTimeGenerator, int resourceId, ToolManager toolManager)
 {
     //TODO - create config item.
     return(new Default(planingJobQueueLength: 45
                        , fixedJobQueueSize: 1
                        , workTimeGenerator: workTimeGenerator
                        , toolManager: toolManager));
 }
コード例 #5
0
ファイル: Default.cs プロジェクト: mschwrdtnr/ng-erp-4.0
 public Default(int timeConstraintQueueLength, int resourceId, WorkTimeGenerator workTimeGenerator, List <M_ResourceCapabilityProvider> capabilityProvider, SimulationType simulationType = SimulationType.None)
     : base(simulationType: simulationType)
 {
     _resourceId                = resourceId;
     _workTimeGenerator         = workTimeGenerator;
     _capabilityProviderManager = new CapabilityProviderManager(capabilityProvider);
     _agentDictionary           = new AgentDictionary();
     // SCOPELIMIT something like 480
     _scopeQueue = new TimeConstraintQueue(limit: timeConstraintQueueLength);
 }
コード例 #6
0
ファイル: MachineAgent.cs プロジェクト: langzimu/ng-erp-4.0
 public MachineAgent(Agent creator, string name, bool debug, DirectoryAgent directoryAgent, Machine machine, WorkTimeGenerator workTimeGenerator) : base(creator, name, debug)
 {
     _directoryAgent   = directoryAgent;
     ProgressQueueSize = 1;                     // TODO COULD MOVE TO MODEL for CONFIGURATION, May not required anymore
     Queue             = new List <WorkItem>(); // ThenBy( x => x.Status)
     ProcessingQueue   = new LimitedQueue <WorkItem>(1);
     Machine           = machine;
     WorkTimeGenerator = workTimeGenerator;
     ItemsInProgess    = false;
     RegisterService();
     QueueLength = 45; // plaing forecast
 }
コード例 #7
0
        private void CreateHubAgent(IActorRef directory, Configuration configuration)
        {
            WorkTimeGenerator randomWorkTime = WorkTimeGenerator.Create(configuration: configuration, 0);

            var hubInfo = new FResourceHubInformation(resourceList: _resourceDictionary
                                                      , dbConnectionString: _ganttContext.Database.GetDbConnection().ConnectionString
                                                      , masterDbConnectionString: _productionContext.Database.GetDbConnection().ConnectionString
                                                      , workTimeGenerator: randomWorkTime);

            _simulation.SimulationContext.Tell(
                message: Directory.Instruction.Central.CreateHubAgent.Create(hubInfo, directory),
                sender: ActorRefs.NoSender);
        }
コード例 #8
0
ファイル: Central.cs プロジェクト: mschwrdtnr/ng-erp-4.0
        public Central(string dbConnectionStringGanttPlan, string dbConnectionStringMaster, WorkTimeGenerator workTimeGenerator, SimulationType simulationType = SimulationType.Default) : base(childMaker: null, simulationType: simulationType)
        {
            _workTimeGenerator           = workTimeGenerator;
            _dbConnectionStringGanttPlan = dbConnectionStringGanttPlan;
            _dbConnectionStringMaster    = dbConnectionStringMaster;
            _confirmationManager         = new ConfirmationManager(dbConnectionStringGanttPlan);
            _stockPostingManager         = new StockPostingManager(dbConnectionStringGanttPlan);

            using (var localganttplanDB = GanttPlanDBContext.GetContext(_dbConnectionStringGanttPlan))
            {
                _products = localganttplanDB.GptblMaterial.Where(x => x.Info1.Equals("Product")).ToList();
            }
        }
コード例 #9
0
        public static IBehaviour Get(SimulationType simType, WorkTimeGenerator workTimeGenerator, int resourceId, ToolManager toolManager)
        {
            switch (simType)
            {
            case SimulationType.DefaultSetup:
                return(DefaultSetup(workTimeGenerator: workTimeGenerator, resourceId: resourceId, toolManager: toolManager));

            case SimulationType.Bucket:
                return(Bucket(workTimeGenerator: workTimeGenerator, resourceId: resourceId, toolManager: toolManager));

            default:
                return(Default(workTimeGenerator: workTimeGenerator, resourceId: resourceId, toolManager: toolManager));
            }
        }
コード例 #10
0
ファイル: Factory.cs プロジェクト: smfichadiya/ng-erp-4.0
        public static IBehaviour Get(SimulationType simType, long maxBucketSize, WorkTimeGenerator workTimeGenerator)
        {
            IBehaviour behaviour;

            switch (simType)
            {
            case SimulationType.Default:
                behaviour = Default(maxBucketSize, workTimeGenerator);
                break;

            default:
                behaviour = Default(maxBucketSize, workTimeGenerator);
                break;
            }

            return(behaviour);
        }
コード例 #11
0
        public static IBehaviour Get(SimulationType simType, WorkTimeGenerator workTimeGenerator, List <M_ResourceCapabilityProvider> capabilityProvider, int timeConstraintQueueLength, int resourceId)
        {
            IBehaviour behaviour;

            switch (simType)
            {
            case SimulationType.Default:
                behaviour = Default(workTimeGenerator: workTimeGenerator, capabilityProvider, timeConstraintQueueLength, resourceId);
                break;

            default:
                behaviour = Default(workTimeGenerator: workTimeGenerator, capabilityProvider, timeConstraintQueueLength, resourceId);
                break;
            }

            return(behaviour);
        }
コード例 #12
0
        private void CreateHubAgents(IActorRef directory, Configuration configuration)
        {
            var capabilities = _dBContext.ResourceCapabilities.Where(x => x.ParentResourceCapabilityId == null).ToList();

            for (var index = 0; index < capabilities.Count; index++)
            {
                WorkTimeGenerator randomWorkTime = WorkTimeGenerator.Create(configuration: configuration, index);
                var capability = capabilities[index];
                GetCapabilitiesRecursive(capability);

                var hubInfo = new FResourceHubInformations.FResourceHubInformation(capability: capability
                                                                                   , workTimeGenerator: randomWorkTime
                                                                                   , maxBucketSize: configuration.GetOption <MaxBucketSize>().Value);
                _simulation.SimulationContext.Tell(
                    message: Directory.Instruction.Default.CreateResourceHubAgents.Create(hubInfo, directory),
                    sender: ActorRefs.NoSender);
            }
        }
コード例 #13
0
        /// <summary>
        /// Creates ResourcesAgents based on current Model and add them to the SimulationContext
        /// </summary>
        /// <param name="configuration">Environment.Configuration</param>
        private void CreateResourceAgents(Configuration configuration)
        {
            WorkTimeGenerator randomWorkTime = WorkTimeGenerator.Create(configuration: configuration);


            foreach (var resource in _resourceDictionary)
            {
                System.Diagnostics.Debug.WriteLine($"Creating Resource: {resource.Value.Name}");

                var resourceDefinition = new FCentralResourceDefinitions.FCentralResourceDefinition(resourceId: resource.Key, resourceName: resource.Value.Name, resource.Value.GroupId, (int)resource.Value.ResourceType);

                _simulation.SimulationContext
                .Tell(message: Directory.Instruction.Central
                      .CreateMachineAgents
                      .Create(message: resourceDefinition, target: ActorPaths.HubDirectory.Ref)
                      , sender: ActorPaths.HubDirectory.Ref);
            }
        }
コード例 #14
0
        private async Task <SystemAgent> CreateModel(SimulationContext context, int simulationId, int simNr)
        {
            var simConfig = _productionDomainContext.SimulationConfigurations.Single(x => x.Id == simulationId);

            //context.Register(new SimulationEndTrigger(() => (context.TimePeriod > simConfig.SimulationEndTime)));
            new SimulationEndTrigger(() => context.TimePeriod > simConfig.SimulationEndTime);


            var system         = new SystemAgent(null, "System", false, _productionDomainContext, _messageHub, simConfig);
            var randomWorkTime = new WorkTimeGenerator(simConfig.Seed, simConfig.WorkTimeDeviation, simNr);
            // Create Directory Agent,
            var directoryAgent = new DirectoryAgent(system, "Directory", false);

            system.ChildAgents.Add(directoryAgent);

            // Create Machine Agents
            foreach (var machine in _productionDomainContext.Machines.Include(m => m.MachineGroup))
            {
                system.ChildAgents.Add(new MachineAgent(creator: system,
                                                        name: "Machine: " + machine.Name,
                                                        debug: false,
                                                        directoryAgent: directoryAgent,
                                                        machine: machine,
                                                        workTimeGenerator: randomWorkTime));
            }

            // Create Stock Agents
            foreach (var stock in _productionDomainContext.Stocks.AsNoTracking()
                     .Include(x => x.StockExchanges)
                     .Include(x => x.Article).ThenInclude(x => x.ArticleToBusinessPartners)
                     .ThenInclude(x => x.BusinessPartner))
            {
                system.ChildAgents.Add(new StorageAgent(creator: system,
                                                        name: stock.Name,
                                                        debug: false,
                                                        stockElement: stock));
            }

            await system.PrepareAgents(simConfig, simNr);

            // Return System Agent to Context
            return(system);
        }
コード例 #15
0
        private async Task <TimeTable <ISimulationItem> > InitializeSimulation(int simulationId, int simNumber, SimulationConfiguration simConfig)
        {
            _messageHub.SendToAllClients("Start Simulation...", MessageType.info);
            _context = InMemoryContext.CreateInMemoryContext();
            InMemoryContext.LoadData(_evaluationContext, _context);
            capacityScheduling = new CapacityScheduling(_context);
            rebuildNets        = new RebuildNets(_context);
            await PrepareSimulationContext();

            await OrderGenerator.GenerateOrders(_context, simConfig, simNumber);

            _workTimeGenerator = new WorkTimeGenerator(simConfig.Seed, simConfig.WorkTimeDeviation, simNumber);
            var timeTable = new TimeTable <ISimulationItem>(simConfig.RecalculationTime);

            UpdateStockExchangesWithInitialValues(simulationId, simNumber);

            //call the initial central planning
            await Recalculate(timeTable, simulationId, simNumber, new List <ProductionOrderWorkSchedule>());

            CreateMachinesReady(timeTable);
            timeTable = UpdateGoodsDelivery(timeTable, simulationId);
            return(timeTable);
        }
        /// <summary>
        /// Creates ResourcesAgents based on current Model and add them to the SimulationContext
        /// </summary>
        /// <param name="configuration">Environment.Configuration</param>
        private void CreateResourceAgents(Configuration configuration)
        {
            WorkTimeGenerator randomWorkTime = WorkTimeGenerator.Create(configuration: configuration);

            var setups = _dBContext.ResourceSetups.Include(navigationPropertyPath: m => m.Resource)
                         .Include(navigationPropertyPath: r => r.ResourceSkill)
                         .ThenInclude(s => s.ResourceSetups)
                         .Include(navigationPropertyPath: t => t.ResourceTool)
                         .AsNoTracking().ToListAsync().Result;

            var resourceList = _dBContext.Resources.ToList();

            foreach (var resource in resourceList)
            {
                var resourceSetups = setups.Where(predicate: x => x.ResourceId == resource.Id).ToList();

                var resourceSetupDefinition = new FResourceSetupDefinition(workTimeGenerator: randomWorkTime, resourceSetup: resourceSetups, debug: _debugAgents);

                _simulation.SimulationContext.Tell(message: Directory.Instruction
                                                   .CreateMachineAgents
                                                   .Create(message: resourceSetupDefinition, target: ActorPaths.HubDirectory.Ref)
                                                   , sender: ActorPaths.HubDirectory.Ref);
            }
        }
コード例 #17
0
ファイル: Factory.cs プロジェクト: smfichadiya/ng-erp-4.0
 private static IBehaviour Default(long maxBucketSize, WorkTimeGenerator workTimeGenerator)
 {
     return(new Default(maxBucketSize: maxBucketSize, workTimeGenerator: workTimeGenerator));
 }
コード例 #18
0
 public Hub(ActorPaths actorPaths, long time, SimulationType simtype, long maxBucketSize, WorkTimeGenerator workTimeGenerator, bool debug, IActorRef principal) : base(actorPaths: actorPaths, time: time, debug: debug, principal: principal)
 {
     this.Do(o: BasicInstruction.Initialize.Create(target: Self, message: HubAgent.Behaviour.Factory.Get(simType: simtype, maxBucketSize: maxBucketSize, workTimeGenerator: workTimeGenerator)));
 }
コード例 #19
0
 public static Props Props(ActorPaths actorPaths, long time, SimulationType simtype, long maxBucketSize, string dbConnectionStringGanttPlan, string dbConnectionStringMaster, WorkTimeGenerator workTimeGenerator, bool debug, IActorRef principal)
 {
     return(Akka.Actor.Props.Create(factory: () => new Hub(actorPaths, time, simtype, maxBucketSize, dbConnectionStringGanttPlan, dbConnectionStringMaster, workTimeGenerator, debug, principal)));
 }
コード例 #20
0
ファイル: Default.cs プロジェクト: smfichadiya/ng-erp-4.0
 public Default(long maxBucketSize, WorkTimeGenerator workTimeGenerator, SimulationType simulationType = SimulationType.Default) : base(childMaker: null, simulationType: simulationType)
 {
     _bucketManager     = new BucketManager(maxBucketSize: maxBucketSize);
     _workTimeGenerator = workTimeGenerator;
 }
コード例 #21
0
 public Hub(ActorPaths actorPaths, long time, SimulationType simtype, long maxBucketSize, string dbConnectionStringGanttPlan, string dbConnectionStringMaster, WorkTimeGenerator workTimeGenerator, bool debug, IActorRef principal) : base(actorPaths: actorPaths, time: time, debug: debug, principal: principal)
 {
     this.Do(o: BasicInstruction.Initialize.Create(target: Self, message: HubAgent.Behaviour.Factory.Central(dbConnectionStringGanttPlan, dbConnectionStringMaster, workTimeGenerator: workTimeGenerator)));
 }
コード例 #22
0
ファイル: Factory.cs プロジェクト: mschwrdtnr/ng-erp-4.0
 public static IBehaviour Central(string dbConnectionStringGanttPlan, string dbConnectionStringMaster, WorkTimeGenerator workTimeGenerator)
 {
     return(new Central(dbConnectionStringGanttPlan, dbConnectionStringMaster, workTimeGenerator));
 }