コード例 #1
0
        public static List <Goal> MainComputeTravel(int[] CodeProducts, Point pStart, int numShop, bool endCash, string path)
        {
            CodeShop = numShop;
            GeneralDB dB = new GeneralDB();
            Shop      s  = dB.MyDb.Shops.Where(x => x.Code == numShop).FirstOrDefault();
            List <GetawayProcI_Result> getawayProcI_Results = dB.MyDb.GetawayProcI(numShop).ToList();
            int width  = Convert.ToInt32(s.Walls.Max(x => x.X2)) + 1;
            int height = (int)s.Walls.Max(x => x.Y2) + 1;

            //TODO: להחליט אם מחשבים כאן
            int[][] matShop = MatShopComputer.ComputeMat(s.Walls.ToArray(), s.Stands.ToArray(), s.Getaways.ToArray(), width, height);
            Cell[,] baseDistanceMatrix = dtoShop.ReadDistanceMatrix(s, path);
            // Cell[,] baseDistanceMatrix = DijkstraFunction.ComputeDikjstra(getawayProcI_Results,s.Connections.ToList());
            List <Wall> cashes = null;

            if (endCash)
            {
                cashes = s.Walls.Where(x => x.Alias.TextAlias == "cash").ToList();
            }
            List <Product> product = dB.MyDb.Products.Where(p => CodeProducts.Contains(p.Code)).Distinct().ToList();

            if (pStart == null)
            {
                pStart = UtilitiesFunctions.MidPoint(Converts.ToDtoGetawayI(getawayProcI_Results.Where(x => x.Code == s.CodeGetaway).First()));
            }
            //foreach (var item in productShops)
            //{
            //    MessageBox.Show(item.Product.Alias.TextAlias);
            //}
            //levels
            Dictionary <Stand, List <Product> > ExtraStand = Level1GroupProductsByStand(product.ToArray());
            //TODO: לעשות שיקבץ לאזורים רק אם צריך
            Dictionary <KeyArea, Area> productArea;

            //if (ExtraStand.Count() <= 10)
            //    productArea = Level2NotGroupStandsByArea(ExtraStand, getawayProcI_Results);
            //else
            productArea = Level2GroupStandsByArea(ExtraStand, getawayProcI_Results, s);
            List <KeyValuePair <KeyArea, Area> > productAreaList = Level3ConvertDictToList(pStart, productArea, matShop, getawayProcI_Results, s.Connections.ToList(), cashes, Convert.ToInt32(s.CodeGetaway), s.Stands.ToList(), s);

            Cell[,] matrix      = Level4ComputeDistanceMatrix(productAreaList, baseDistanceMatrix, pStart, cashes);
            Cell[,] matrixToTsp = Level5CutMatrix(matrix, productAreaList.Count, matrix.GetLength(1));

            return(Level6ComputeGoalsTravel(matrix, matrixToTsp, matrix.GetLength(1) - matrixToTsp.GetLength(1) - 1, matrixToTsp.GetLength(1), productAreaList, getawayProcI_Results, pStart, cashes.Count()));
        }
コード例 #2
0
        public List <Goal> DOmain(List <Product> products, Point pStart, Wall cash, int numShop, List <GetawayProcI_Result> getaways, List <Connection> connections)
        {
            string path = @"C:\ProgramData\superQuick";

            CodeShop = numShop;
            GeneralDB DB   = new GeneralDB();
            Shop      shop = DB.MyDb.Shops.Where(x => x.Code == numShop).First();
            List <GetawayProcI_Result> getawayProcI_Results = DB.MyDb.GetawayProcI(1).ToList();

            Cell[,] distanceMatrix = DijkstraFunction.ComputeDikjstra(DB.MyDb.GetawayProcI(1).ToList(), shop.Connections.ToList());
            //Cell[,] distanceMatrix = dtoShop.ReadDistanceMatrix(shop,path);
            ShopWayEntities shopWay = new ShopWayEntities();

            pStart.X = 8; pStart.Y = 22;
            int[][]  matShop = MatShopComputer.ComputeMat(shop.Walls.ToArray(), shop.Stands.ToArray(), shop.Getaways.ToArray(), 29, 29);
            string[] arr     = { "מים", "שוגי", "ציפס קידס", "קורונפלקס", "כריות", "סוכריות אדומות", "במבה", "תן צאפ", "ביסלי", "ציפס מקסיקני", "פופקורן", "במבה אדומה", "דוריטוס" };
            //string[] arr = { "watter", "shugi", "chips kids", "coronflex", "cariot", "red swits", "bamba", "ten chap", "bisli", "chips meksicani", "popcoren", "red bamba", "new snak" };
            //List<Product> productsTrap = DB.MyDb.Products.Where(x => arr.Contains(x.Alias.TextAlias) && x.GetProductShops().Where(y => y.CodeShop == numShop).ToList().Count > 0).ToList();
            List <ProductShop> productShops = shop.GetProductShop();
            bool           b            = productShops.Where(x => x.Code == 1).FirstOrDefault() != null;
            List <Product> productsShop = shop.ProductShops.Select(x => x.Product).ToList();

            List <Product> productsTrap = productsShop.Where(x => arr.Contains(x.Alias.TextAlias)).ToList();
            //List<Product> productsTrap&& productShops.Where(y=>y.CodeProduct==x.Code).FirstOrDefault()!=null).ToList();
            Dictionary <Stand, List <Product> > ExtraStand = Level1GroupProductsByStand(productsTrap.ToArray());
            Dictionary <KeyArea, Area>          productArea;

            //TODO: לעשות שלא יקבץ לאזורים אם לא צריך
            //if (ExtraStand.Count()<=10)
            //    productArea= Level2NotGroupStandsByArea(ExtraStand, getawayProcI_Results);
            //else
            productArea = Level2GroupStandsByArea(ExtraStand, getawayProcI_Results, shop);
            List <Wall> cashes = shop.Walls.Where(w => w.Alias.TextAlias == "cash").ToList();
            List <KeyValuePair <KeyArea, Area> > productAreaList = Level3ConvertDictToList(pStart, productArea, matShop, getaways, connections, cashes, Convert.ToInt32(shop.CodeGetaway), shop.Stands.ToList(), shop);

            Cell[,] matrix      = Level4ComputeDistanceMatrix(productAreaList, distanceMatrix, pStart, cashes);
            Cell[,] matrixToTsp = Level5CutMatrix(matrix, productAreaList.Count, matrix.GetLength(1));
            return(Level6ComputeGoalsTravel(matrix, matrixToTsp, matrix.GetLength(1) - matrixToTsp.GetLength(1) - 1, matrixToTsp.GetLength(1), productAreaList, getawayProcI_Results, pStart, cashes.Count()));
        }