/*--------------------------------- * Description: Update Mining Model and process StockPredict DB with new MAX, MIN when MAX,MIN are changed by Technology Analysis (IdentifyTrend) * ----------------------------------- */ public static bool UpdateMMbyAnalysis(string sStockCode) { Server svr = ConnectServer(str_Con_Svr); Database db = svr.Databases.GetByName("StockPredict"); Microsoft.AnalysisServices.MiningStructure ms = db.MiningStructures.FindByName(sStockCode); Microsoft.AnalysisServices.MiningModel mm = ms.MiningModels.FindByName(sStockCode); mm.AlgorithmParameters.Remove("MAXIMUM_SERIES_VALUE"); mm.AlgorithmParameters.Remove("MINIMUM_SERIES_VALUE"); // Max, Min Time Series mm.AlgorithmParameters.Add("MAXIMUM_SERIES_VALUE", MAXIMUM_SERIES_VALUE); mm.AlgorithmParameters.Add("MINIMUM_SERIES_VALUE", MINIMUM_SERIES_VALUE); mm.Update(); mm.Process(ProcessType.ProcessFull); // Update parameters into StockForecastModel try { SqlConnection conn = new SqlConnection(str_Con_SQL); conn.Open(); SqlCommand cmdUpdate = conn.CreateCommand(); cmdUpdate.CommandText = "Update StockForecastModel Set MAXIMUM_SERIES_VALUE=" + MAXIMUM_SERIES_VALUE.ToString().Replace(',', '.') + ", MINIMUM_SERIES_VALUE=" + MINIMUM_SERIES_VALUE.ToString().Replace(',', '.') + " Where StockCode='" + sStockCode + "'"; cmdUpdate.ExecuteNonQuery(); cmdUpdate.Dispose(); conn.Close(); } catch (Exception ex) { MessageBox.Show("Không thể cập nhật StockForecastModel!"); return(false); } return(true); }
public static bool UpdateMMTest(Microsoft.AnalysisServices.MiningModel mm, string strStockCode, DateTime dtTo) { mm.AlgorithmParameters.Clear(); // Default:10; 10:5 -> from 0 to (n-10)/5 //mm.AlgorithmParameters.Add("MINIMUM_SUPPORT", 10); // 0.1:0.05 -> from 0 to (1-0.1)/0.05=18 mm.AlgorithmParameters.Add("COMPLEXITY_PENALTY", COMPLEXITY_PENALTY); // {5,20,60}, 0:0.1 -> from 0 to (1-0.1)/0.05=18 mm.AlgorithmParameters.Add("PERIODICITY_HINT", "{5,20,60}"); mm.AlgorithmParameters.Add("AUTO_DETECT_PERIODICITY", AUTO_DETECT_PERIODICITY); // Defeult: 1, 10 mm.AlgorithmParameters.Add("HISTORIC_MODEL_COUNT", HISTORIC_MODEL_COUNT); mm.AlgorithmParameters.Add("HISTORIC_MODEL_GAP", HISTORIC_MODEL_GAP); // Max, Min Time Series mm.AlgorithmParameters.Add("MAXIMUM_SERIES_VALUE", MAXIMUM_SERIES_VALUE); mm.AlgorithmParameters.Add("MINIMUM_SERIES_VALUE", MINIMUM_SERIES_VALUE); mm.Update(); mm.Process(ProcessType.ProcessFull); return(ADOMDLib.CheckResultTest(strStockCode, dtTo)); }