示例#1
0
文件: Predict.cs 项目: vutiendung/RS
        public void LoadRecommendation(string LoginID)
        {
            Predict_DAO_MCol dao = null;

            RecommdationSchedule schedule = new RecommdationSchedule();
            schedule.Log = "Recommendation";
            schedule.LoginID = LoginID;
            Predict_MC predictMC = new Predict_MC();
            try
            {
                dao = new Predict_DAO_MCol();
                dao.beginTransaction();
                RecommdationSchedule currentSchedule = dao.addRecommdationSchedule(schedule);
                //Settings st = getSettings();
                Settings r = predictMC.GetRecommendationSeting(dao);
                Dictionary<string, double> UCA = predictMC.getUCA(dao);

                //Data service
                IntergrationManager manager = new IntergrationManager();
                manager.execute();

                //Clustering service
                new ClusterUsers().startClusteringAuto();

                /*
                 *
                 *
                 * this paragraph need to rewrite
                 *
                 * */
                //calculate confident matrix - c4
                ComputeConfident(dao);
                // calculate dist matrix - C5
                ComputeDIST(dao);

                //=====================================================================================

                dao.CLEAN_RECOMMENDATION();

                // R1
                DateTime startC6 = DateTime.Now;
                // predictMC.R1(dao, currentSchedule, r.nbR1, UCA, lstGAP);
                predictMC.R1(dao, currentSchedule);
                DateTime endC6 = DateTime.Now;
                int time_Seconds_CLC6 = Convert.ToInt32((endC6 - startC6).TotalSeconds);

                //////R2
                //DateTime startC7 = DateTime.Now;
                //setRCPurchasedItems(dao, currentSchedule, r.nbR2, lstGAP);
                //DateTime endC7 = DateTime.Now;
                //int time_Seconds_CLC7 = Convert.ToInt32((endC7 - startC7).TotalSeconds);

                //// R3
                DateTime startC8 = DateTime.Now;
                // predictMC.R3(dao, currentSchedule, r.nbR3, UCA, lstGAP);
                predictMC.R3(dao, currentSchedule);
                DateTime endC8 = DateTime.Now;
                int time_Seconds_CLC8 = Convert.ToInt32((endC8 - startC8).TotalSeconds);

                //// R4
                DateTime startC9 = DateTime.Now;
                // predictMC.R4(dao, currentSchedule, r.paramR4, UCA, lstGAP);
                predictMC.R4(dao, currentSchedule);
                DateTime endC9 = DateTime.Now;
                int time_Seconds_CLC9 = Convert.ToInt32((endC9 - startC9).TotalSeconds);

                ////Get R1R4 for new users
                DateTime startR1R4NewUsers = DateTime.Now;
                predictMC.R1R4_FOR_NEW_USERS(dao, currentSchedule, UCA);
                DateTime endR1R4NewUsers = DateTime.Now;
                int time_second_R1R4NewUsers = Convert.ToInt32((endR1R4NewUsers - startR1R4NewUsers).TotalSeconds);

                //GetPrice
                //dao.GetPrice();

                Console.WriteLine("FINISH");

                // build statistic log
                List<string[]> lstStatic = dao.getStaticsData();
                foreach (string[] statics in lstStatic)
                {
                    schedule.Log += statics[0] + statics[1] + ". ";
                }

                schedule.Log += "Time to find LRS01 : " + time_Seconds_CLC6.ToString() + ". ";
                //schedule.Log += "Time to find LRS02 : " + time_Seconds_CLC7.ToString() + ". ";
                schedule.Log += "Time to find LRS03 : " + time_Seconds_CLC8.ToString() + ". ";
                schedule.Log += "Time to find LRS04 : " + time_Seconds_CLC9.ToString() + ". ";
                schedule.Log += "Time to find recommendations for new clients : " + time_second_R1R4NewUsers.ToString() + ". ";
                schedule.Log += "System successfully stopped at " + DateTime.Now.ToString();

                dao.updateRecommdationSchedule(schedule);
                dao.commitTransaction();

            }
            catch (Exception ex)
            {
                dao.rollbackTransaction();
                throw ex;
            }
        }