Exemple #1
0
        public Demand(Demand copy)
        {
            this.ID = copy.ID;

            this.GettingDate = copy.GettingDate;
            this.FinishingDate = copy.FinishingDate;
            this.ShouldBeDoneDate = copy.ShouldBeDoneDate;
            this.Urgency = copy.Urgency;
            this.Products = new ProductCluster(copy.Products);
        }
Exemple #2
0
        public Demand(int id, DateTime geting, int urgency, ProductCluster productCluster)
        {
            this.ID = id;

            this.GettingDate = geting;
            this.FinishingDate = null;
            this.ShouldBeDoneDate = null;
            this.Urgency = urgency;
            this.Products = new ProductCluster(productCluster);
        }
Exemple #3
0
        public Demand ModifyDemand(Demand[] demands, DateTime currentDate)
        {
            var arctProbabilities = uGen.GenerateSequence().GetEnumerator();
            var urgProbabilities = uGen.GenerateSequence().GetEnumerator();

            Func<IEnumerator<double>, double> getNext = (sequence) =>
            {
                sequence.MoveNext();
                return sequence.Current;
            };

            var probabilitiesByProduct = new Dictionary<int, IEnumerator<double>>()
            {
                {1, this.firstArticleModifyGen.GenerateSequence().GetEnumerator()},
                {2, this.secondArticleModifyGen.GenerateSequence().GetEnumerator()},
                {3, this.thirdArticleModifyGen.GenerateSequence().GetEnumerator()},
            };

            var rand = new Random(Guid.NewGuid().GetHashCode());

            var returnDemand = new Demand();
            bool modifyFlag = false;

            while (!modifyFlag)
            {
                int i = rand.Next(demands.Length);
                var modifiedDemand = new Demand(demands[i]);
                if (modifiedDemand.Urgency == 2)
                    throw new Exception("Заявка от которой отказались не может быть изменена!");

                TimeSpan dt = currentDate.Subtract(demands[i].GettingDate);

                var demand = demands[i];

                if (this.articlesModifyGen.GetProbability(dt.TotalMinutes) >= getNext(arctProbabilities))
                {
                    bool changeFlag = false;
                    while (changeFlag == false)
                    {
                        var productClaster = new ProductCluster();

                        for (var productIndex = 1; productIndex <= 3; productIndex++)
                        {
                            int modifiedArticleNum = 0;

                            demand.Products.GetProduct(productIndex, out modifiedArticleNum);

                            modifiedArticleNum += (int)Math.Round(getNext(probabilitiesByProduct[productIndex]));

                            if (modifiedArticleNum < 0)
                                modifiedArticleNum = 0;

                            if (!demand.Products.CompareProduct(productIndex, modifiedArticleNum))
                                changeFlag = true;

                            productClaster.AddProduct(productIndex, modifiedArticleNum);
                        }

                        if (changeFlag && productClaster.CompareNomenclatureIsMore(demand.Products))
                        {
                            modifiedDemand.Products.CleanProductsCluster();
                            modifiedDemand.Products.AddProductCluster(productClaster);
                            modifyFlag = true;
                        }
                    }
                }

                if (demand.Urgency == 1)
                {
                    if (this.urgToStandModifyGen.GetProbability(dt.TotalMinutes) >= getNext(urgProbabilities))
                    {
                        modifiedDemand.Urgency = 0;
                        //modifyFlag = true;  срочность изменяется но если не изменились продукты изменение не произошло
                    }
                }
                else
                {
                    if (this.standToUrgModifyGen.GetProbability(dt.TotalMinutes) >= getNext(urgProbabilities))
                    {
                        modifiedDemand.Urgency = 1;
                        //modifyFlag = true; срочность изменяется но если не изменились продукты изменение не произошло
                    }
                }

                if (modifyFlag)
                    returnDemand = modifiedDemand;
            }
            return returnDemand;
        }
Exemple #4
0
        //public CDemand[] generateDemands(DateTime dt)
        //{
        //    int[] requestTimes = this.requestTimeGen.generateForDay();
        //    double[] firstArticlesSeq = this.firstArticleGen.generateN(requestTimes.Length);
        //    double[] secondArticlesSeq = this.secondArticleGen.generateN(requestTimes.Length);
        //    double[] thirdArticlesSeq = this.thirdArticleGen.generateN(requestTimes.Length);
        //    int[] urgency = generateUrgencyRefuse(requestTimes.Length);
        //    List<int> firstAricles = new List<int>();
        //    foreach (double i in firstArticlesSeq)
        //    {
        //        firstAricles.Add((int)Math.Round(i));
        //    }
        //    List<int> secondAricles = new List<int>();
        //    foreach (double i in secondArticlesSeq)
        //    {
        //        secondAricles.Add((int)Math.Round(i));
        //    }
        //    List<int> thirdAricles = new List<int>();
        //    foreach (double i in thirdArticlesSeq)
        //    {
        //        thirdAricles.Add((int)Math.Round(i));
        //    }
        //    List<CDemand> demands = new List<CDemand>();
        //    int minutes = 0;
        //    for (int i = 0; i < requestTimes.Length; i++)
        //    {
        //        minutes = minutes + requestTimes[i];
        //        /*
        //        demands.Add(new CDemand(0,dt.AddMinutes(minutes), urgency[i], new Dictionary<int, int> {
        //        { 1, firstAricles.ElementAt(i) },
        //        { 2, secondAricles.ElementAt(i) },
        //        { 3, thirdAricles.ElementAt(i) }
        //        }));
        //         */
        //        //--->
        //        CProductCluster productCluster = new CProductCluster();
        //        //Дима: очень странно, но thirdAricles.ElementAt(i) иногда выдает ОТРИЦАТЕЛЬНОЕ число!!!
        //        //вставил проверки на неотрицательность.
        //        if (firstAricles.ElementAt(i)>0)
        //            productCluster.AddProduct(1, firstAricles.ElementAt(i));
        //        if (secondAricles.ElementAt(i) > 0)
        //            productCluster.AddProduct(2, secondAricles.ElementAt(i));
        //        if (thirdAricles.ElementAt(i) > 0)
        //            productCluster.AddProduct(3, thirdAricles.ElementAt(i));
        //        demands.Add(new CDemand(0,dt.AddMinutes(minutes), urgency[i], productCluster));
        //        //<---
        //    }
        //    return demands.ToArray();
        //}
        /// <summary>
        /// генерация массива заявок
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public Demand[] GenerateDemands(DateTime dt)
        {
            int[] requestTimes = this.requestTimeGen.GenerateForDay();
            double[][] articlesModifyGen = new double[3][];

            //собственно генерация
            articlesModifyGen[0] = this.firstArticleGen.GenerateN(requestTimes.Length);
            articlesModifyGen[1] = this.firstArticleGen.GenerateN(requestTimes.Length);
            articlesModifyGen[2] = this.firstArticleGen.GenerateN(requestTimes.Length);

            int[] urgency = GenerateUrgencyRefuse(requestTimes.Length);

            Demand[] demands = new Demand[requestTimes.Length];
            int minutes = 0;
            //цикл по заявкам
            for (int iDemandNumber = 0; iDemandNumber < requestTimes.Length; iDemandNumber++)
            {
                minutes = minutes + requestTimes[iDemandNumber];

                ProductCluster productCluster = new ProductCluster();

                //заполнение кластера продуктов
                for (int iProductNumber = 1; iProductNumber <= Params.PRODUCTS_NUMBER; iProductNumber++)
                {
                    if (articlesModifyGen[iProductNumber - 1][iDemandNumber] > 0)
                    {
                        productCluster.AddProduct(iProductNumber, (int)Math.Round(articlesModifyGen[iProductNumber - 1][iDemandNumber]));
                    }
                }

                demands[iDemandNumber] = new Demand(0, dt.AddMinutes(minutes), urgency[iDemandNumber], productCluster);
            }
            return demands;
        }
Exemple #5
0
        public bool saveNewFrontDemands(Modeling.FrontOffice.Order[] newFrontOrders)
        {
            foreach(Modeling.FrontOffice.Order order in newFrontOrders)
            {
                int urg=0;
                if (order.isExpress==true) urg=1;
                /*
                CDemand demand = new CDemand(order.OrderID, this.modelTime, urg, new Dictionary<int, int> { { 1, order.ProductCount[0] }, { 2, order.ProductCount[1] }, { 3, order.ProductCount[2] } });
                */

                //--->
                ProductCluster productCluster = new ProductCluster();
                for (int iProductNumber = 1; iProductNumber <= Params.PRODUCTS_NUMBER; iProductNumber++)
                {
                    productCluster.AddProduct(iProductNumber, order.ProductCount[iProductNumber - 1 ]);
                }

                Demand demand = new Demand(order.OrderID, this.modelTime, urg, productCluster);
                //<---

                demand.ShouldBeDoneDate = order.doneDate;
                bool addResult = this.storage.AddAcceptedDemand(demand);
                if (addResult==false) return false;
            }
            return true;
        }
Exemple #6
0
 public bool saveChangedFrontDemands(Modeling.FrontOffice.Order[] changedFrontOrders)
 {
     foreach (Modeling.FrontOffice.Order order in changedFrontOrders)
     {
         int urg = 0;
         if (order.isExpress == true) urg = 1;
         ProductCluster productCluster = new ProductCluster();
         for (int iProductNumber = 1; iProductNumber <= Params.PRODUCTS_NUMBER; iProductNumber++)
         {
             productCluster.AddProduct(iProductNumber, order.ProductCount[iProductNumber - 1]);
         }
         Demand demand = new Demand(order.OrderID, new DateTime(), urg, productCluster);
         demand.ShouldBeDoneDate = order.doneDate;
         bool changeResult = this.storage.ModifyDemand(demand);
         if (changeResult == false) return false;
     }
     return true;
 }
Exemple #7
0
 public Demand()
 {
     Products = new ProductCluster();
 }
 public bool TakeAwayProductCluster(ProductCluster productCluster)
 {
     return Cluster.TakeAwayEntityCluster(productCluster.Cluster);
 }
 public bool IsProductCluster(ProductCluster productCluster)
 {
     return Cluster.IsEntityCluster(productCluster.Cluster);
 }
Exemple #10
0
 public bool CompareNomenclatureIsMore(ProductCluster productCluster)
 {
     return Cluster.CompareNomenclatureIsMore(productCluster.Cluster);
 }
Exemple #11
0
 public void AddProductCluster(ProductCluster productCluster)
 {
     Cluster.AddEntityCluster(productCluster.Cluster);
 }
Exemple #12
0
 public ProductCluster(ProductCluster copy)
 {
     Cluster = new EntityCluster(copy.Cluster, LIMITATION);
 }