Exemple #1
0
        private void CheckForOrderRequests(TimeTable <ISimulationItem> timeTable)
        {
            var osi = timeTable.Items.Where(a => a.GetType() == typeof(OrderSimulationItem) && ((OrderSimulationItem)a).AddOrder).ToList();

            if (!osi.Any() || !osi.Any(b => ((OrderSimulationItem)b).AddOrder))
            {
                return;
            }
            foreach (var singleOsi in osi)
            {
                var order = (OrderSimulationItem)singleOsi;
                _context.Orders.Add(
                    _context.CreateNewOrder(order.ArticleIds[0], order.Amounts[0], 1, order.DueTime));
            }
        }
        public static Task GenerateOrders(ProductionDomainContext context, SimulationConfiguration simConfig, int simulationNumber)
        {
            return(Task.Run(() =>
            {
                var time = 0;
                var samples = simConfig.OrderQuantity;
                var seed = new Random(simConfig.Seed + simulationNumber);
                var productIds = context.ArticleBoms.Where(b => b.ArticleParentId == null).Select(a => a.ArticleChildId)
                                 .ToList();

                var dist = new Exponential(rate: simConfig.OrderRate, randomSource: seed);
                //get equal distribution from 0 to 1
                var norml = new DiscreteUniform(0, productIds.Count() - 1, seed);
                //get equal distribution for duetime
                var normalDuetime = new DiscreteUniform(1160, 1600, seed); //2160,3600

                double[] exponential = new double[samples];                //new Exponential(0.25, seed);
                int[] prodVariation = new int[samples];
                int[] duetime = new int[samples];
                dist.Samples(exponential);
                norml.Samples(prodVariation);
                normalDuetime.Samples(duetime);
                //get products by searching for articles without parents
                for (int i = 0; i < samples; i++)
                {
                    //define the time between each new order
                    time += (int)Math.Round(exponential[i] * 10, MidpointRounding.AwayFromZero);
                    //get which product is to be ordered
                    var productId = productIds.ElementAt(prodVariation[i]);

                    //create order and orderpart, duetime is creationtime + 1 day
                    context.Orders.Add(context.CreateNewOrder(productId, 1, time, time + duetime[i]));
                }
                context.SaveChangesAsync();
            }));
        }
Exemple #3
0
        public void GanttPlanInsertConfirmationAndReplan()
        {
            ProductionDomainContext master40Context = ProductionDomainContext.GetContext(masterCtxString);

            master40Context.CustomerOrders.RemoveRange(master40Context.CustomerOrders);
            master40Context.CustomerOrderParts.RemoveRange(master40Context.CustomerOrderParts);
            master40Context.SaveChanges();

            master40Context.CreateNewOrder(10115, 1, 0, 250);
            master40Context.SaveChanges();

            GanttPlanDBContext ganttPlanContext = GanttPlanDBContext.GetContext(GanttPlanCtxString);

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

            Assert.True(ganttPlanContext.GptblProductionorder.Any());

            ganttPlanContext.GptblConfirmation.RemoveRange(ganttPlanContext.GptblConfirmation);
            var productionorder = ganttPlanContext.GptblProductionorder.Single(x => x.ProductionorderId.Equals("000004"));

            ganttPlanContext.GptblConfirmation.RemoveRange(ganttPlanContext.GptblConfirmation);

            var activities = ganttPlanContext.GptblProductionorderOperationActivity.Where(x =>
                                                                                          x.ProductionorderId.Equals(productionorder.ProductionorderId));

            var activity     = activities.Single(x => x.OperationId.Equals("10") && x.ActivityId.Equals(2));
            var confirmation = CreateConfirmation(activity, productionorder, 1);

            ganttPlanContext.GptblConfirmation.Add(confirmation);

            ganttPlanContext.SaveChanges();

            GanttPlanOptRunner.RunOptAndExport("Continuous");

            Assert.True(ganttPlanContext.GptblConfirmation.Any());

            confirmation = ganttPlanContext.GptblConfirmation.SingleOrDefault(x =>
                                                                              x.ConfirmationId.Equals(confirmation.ConfirmationId));
            //ganttPlanContext.GptblConfirmation.Remove(confirmation);
            var finishConfirmation = CreateConfirmation(activity, productionorder, 16);

            ganttPlanContext.SaveChanges();

            ganttPlanContext.GptblConfirmation.Add(finishConfirmation);

            activity = activities.Single(x => x.OperationId.Equals("10") && x.ActivityId.Equals(3));

            confirmation = CreateConfirmation(activity, productionorder, 16);

            ganttPlanContext.GptblConfirmation.Add(confirmation);

            activity = activities.Single(x => x.OperationId.Equals("20") && x.ActivityId.Equals(2));

            confirmation = CreateConfirmation(activity, productionorder, 16);
            ganttPlanContext.GptblConfirmation.Add(confirmation);

            ganttPlanContext.SaveChanges();

            GanttPlanOptRunner.RunOptAndExport("Continuous");

            Assert.True(ganttPlanContext.GptblProductionorder.Count().Equals(10));
        }