01-api/Application/IStation.Application/01-open-api/01-schedule/Schedule_Controller.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
01-api/Service/IStation.Service/03-settings/paras/Paras_LocalFile.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
01-api/Service/IStation.Service/05-service/00-basic/FlowDeviation.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
01-api/Service/IStation.Service/paras_schedule_settings.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
01-api/_Expand/IStation.Win.Schedule/bjMain.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
02-desktop/Desktop/IStation.Test/Program.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
01-api/Application/IStation.Application/01-open-api/01-schedule/Schedule_Controller.cs
@@ -18,6 +18,7 @@ private static readonly Service.ScheduleConfig _service_schedule_config = new(); private static readonly Service.AnalysisDeviation _service_analysis_deviation = new(); private static readonly Service.FlowDeviation _service_flow_deviation = new(); /// <summary> /// è®¡ç® @@ -56,7 +57,8 @@ var is_monitor_record_debug = false; #if DEBUG is_monitor_record_debug = true; #endif #endif log_title = "宿¶ZyScada请æ±"; var get_msg = GlobalHelper.GetMonitorRecordList(receipt_time, out List<Model.MonitorRecord> monitor_record_list, is_monitor_record_debug); @@ -104,17 +106,20 @@ } log_title = "è°åº¦è¿å"; var msg = "计ç®ç»æ!"; var helper = new Service.ScheduleHelper(); log_title = "æµé补差"; var helper = new Service.ScheduleHelper(); helper.Initial(station1_open_flag_list, station1_schedule_config, analysis_deviation_list); var optimal_combine1 = helper.GetOptAnaCombine(station1, station1_flag_inlet_water_level_dict, target_flow1, target_pressure1); helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list); var station2_target_flow_diff=_service_flow_deviation.GetFlowDiff(target_pressure2); ScheduleLog.Info(request_id, log_title, $"2è¾æ°´:{station2_target_flow_diff:N1}"); helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list,station2_target_flow_diff); var optimal_combine2 = helper.GetOptAnaCombine(station2, station2_flag_inlet_water_level_dict, target_flow2, target_pressure2); log_title = "è°åº¦è¿å"; var msg = "计ç®ç»æ!"; var schedule_request = new Model.ScheduleRequest { ID = request_id, 01-api/Service/IStation.Service/03-settings/paras/Paras_LocalFile.cs
@@ -68,6 +68,12 @@ /// åæåå·®æä»¶ /// </summary> public string AnalysisDeviationFile { get; set; } = "AnalysisDeviation.json"; /// <summary> /// æµéåå·®æä»¶ /// </summary> public string FlowDeviationFile { get; set; } = "FlowDeviation.csv"; } } 01-api/Service/IStation.Service/05-service/00-basic/FlowDeviation.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,59 @@ namespace IStation.Service { /// <summary> /// /// </summary> public partial class FlowDeviation { private readonly string _filePath = Path.Combine( Settings.ParasHelper.LocalFile.DataFolderDirectory, Settings.ParasHelper.LocalFile.FlowDeviationFile); private Curve.CurveExpress _flowDiffCurve = null; private bool _isCurveLoaded = false; /// <summary> /// è·å /// </summary> public double GetFlowDiff(double pressure) { if (_flowDiffCurve == null) { if (_isCurveLoaded) return 0; _isCurveLoaded = true; if (!File.Exists(_filePath)) return default; var ptList = new List<Curve.CurvePoint>(); using StreamReader reader = new StreamReader(_filePath); reader.ReadLine(); string line; while ((line = reader.ReadLine()) != null) { string[] values = line.Split(','); var xStr = values[0]; var yStr = values[1]; var pX = double.Parse(xStr); var pY = double.Parse(yStr); pY = Math.Abs(pY); ptList.Add(new CurvePoint(pX, pY)); } if (ptList.Any()) { _flowDiffCurve = Curve.FitHelper.BuildCurveExpress(ptList); } } var flowDiff = _flowDiffCurve.GetFitPointY(pressure); return flowDiff; } } } 01-api/Service/IStation.Service/07-helper/02-schedule/ScheduleHelper.cs
@@ -25,12 +25,14 @@ private readonly decimal _frequency_max = 50; private readonly decimal _frequency_space = 1;//é¢çé´é private readonly double _start_stop_loss_coefficient = 0.95;//æ³µå¯åæå¤±ç³»æ° private readonly double _start_stop_loss_coefficient = 0.9;//æ³µå¯åæå¤±ç³»æ° private double _sel_opt_flow_excess = 1;//å¯éæ¹æ¡çæµéä½é private readonly double _sel_opt_pump_pressure_excess = 0;//å¯éæ¹æ¡çåæ³µæ¬ç¨é»è®¤æ¬åä½é private double _station_target_flow_diff = 0; // ç«ç¹ç®æ æµéå·®å¼ private double _sel_opt_flow_deviation_ratio = 0.05;//å¯éæ¹æ¡çæµéåå·®æ¯ private readonly double _sel_opt_flow_deviation_ratio = 0.05;//å¯éæ¹æ¡çæµéåå·®æ¯ private readonly double _sel_opt_reasonable_flow_deviation_ratio = 0.005;//åççæ¹æ¡çæµéåå·®æ¯ private readonly Service.AnalysisParameter _service_analysis_parameter = new(); @@ -51,12 +53,14 @@ private List<Model.AnalysisDeviation> _analysis_deviation_list = null;//åæåå·® #endregion /// <summary> /// åå§å /// </summary> public void Initial(List<int> current_open_flag_list, Model.ScheduleConfig schedule_config, List<Model.AnalysisDeviation> analysis_deviation_list) public void Initial(List<int> current_open_flag_list, Model.ScheduleConfig schedule_config, List<Model.AnalysisDeviation> analysis_deviation_list, double station_target_flow_diff = 0) { _current_open_flag_list = current_open_flag_list; _min_open_count = 1; @@ -70,6 +74,7 @@ _frequency_limit_list = null; _flag_cumulative_runtime_dict = null; _priority_open_flag_list = null; _station_target_flow_diff = 0; if (schedule_config != null) { _min_open_count = schedule_config.MinOpenCount; @@ -86,7 +91,7 @@ } _analysis_deviation_list = analysis_deviation_list; _station_target_flow_diff = station_target_flow_diff; } @@ -109,6 +114,7 @@ ) { target_flow+=_station_target_flow_diff; #region åå§ååæ° if (pump_list == null || !pump_list.Any()) { 01-api/Service/IStation.Service/paras_schedule_settings.json
@@ -12,7 +12,8 @@ "ScheduleConfigFile": "ScheduleConfig.json", "HydraulicModelFile": "HydraulicModel.inp", "AnalysisFactorFile": "AnalysisFactor.json", "AnalysisDeviationFile": "AnalysisDeviation.json" "AnalysisDeviationFile": "AnalysisDeviation.json", "FlowDeviationFile": "FlowDeviation.csv" }, "DataBase": { "DbType": "SQLite", 01-api/_Expand/IStation.Win.Schedule/bjMain.cs
@@ -83,8 +83,8 @@ { return; } var deline = new DateTime(2024,12,1); var deline2 = new DateTime(2025,1,1); var deline = new DateTime(2025,2,12); var deline2 = new DateTime(2025,5,1); var time_list = _schedule_request_list.Where(x=>x.ReceptionTime>=deline&&x.ReceptionTime<= deline2).Select(x => x.ReceptionTime).OrderBy(x => x).ToList(); foreach (var item in time_list) @@ -157,57 +157,60 @@ } } double station2_target_flow_diff = 0; if (this.barCekCalcFlowDiff.Checked) { var ptList = new List<CurvePoint>(); try { var filePath = @"D:\WorkCode\Project\ChDt1\Schedule.Ch.V1.0\02-desktop\Desktop\IStation.Test\bin\Debug\net6.0-windows\stationcsv\characteristic_curve.csv"; using (StreamReader reader = new StreamReader(filePath)) { reader.ReadLine(); string line; while ((line = reader.ReadLine()) != null) { // æéå·å鿝ä¸è¡ string[] values = line.Split(','); var xStr = values[0]; var yStr = values[1]; station2_target_flow_diff = new Service.FlowDeviation().GetFlowDiff(target_pressure2); AlertTool.ShowInfo(this, "颿µæµé缺失", $"{station2_target_flow_diff:N1}"); //var ptList = new List<CurvePoint>(); //try //{ // var filePath = @"D:\WorkCode\Project\ChDt1\Schedule.Ch.V1.0\02-desktop\Desktop\IStation.Test\bin\Debug\net6.0-windows\stationcsv\characteristic_curve.csv"; // using (StreamReader reader = new StreamReader(filePath)) // { // reader.ReadLine(); // string line; // while ((line = reader.ReadLine()) != null) // { // // æéå·å鿝ä¸è¡ // string[] values = line.Split(','); // var xStr = values[0]; // var yStr = values[1]; var pX = double.Parse(xStr); var pY = double.Parse(yStr); // var pX = double.Parse(xStr); // var pY = double.Parse(yStr); pY = Math.Abs(pY); ptList.Add(new CurvePoint(pX, pY)); // pY = Math.Abs(pY); // ptList.Add(new CurvePoint(pX, pY)); } } } catch (Exception ex) { Console.WriteLine("读åæä»¶æ¶åºé: " + ex.Message); } // } // } //} //catch (Exception ex) //{ // Console.WriteLine("读åæä»¶æ¶åºé: " + ex.Message); //} var x = ptList.Select(x => x.X).ToArray(); var y = ptList.Select(x => x.Y).ToArray(); //var x = ptList.Select(x => x.X).ToArray(); //var y = ptList.Select(x => x.Y).ToArray(); // å¤é¡¹å¼åå½çé¶æ°ï¼ä¾å¦ï¼äºæ¬¡å¤é¡¹å¼ï¼ int degree = 3; //// å¤é¡¹å¼åå½çé¶æ°ï¼ä¾å¦ï¼äºæ¬¡å¤é¡¹å¼ï¼ //int degree = 3; // æåå¤é¡¹å¼å彿¨¡å double[] coefficients = NonlinearRegressionHelper.FitPolynomial(x, y, degree); //// æåå¤é¡¹å¼å彿¨¡å //double[] coefficients = NonlinearRegressionHelper.FitPolynomial(x, y, degree); // ä½¿ç¨æ¨¡åè¿è¡é¢æµ double xNew = target_pressure2; double yPredicted = NonlinearRegressionHelper.PredictPolynomial(xNew, coefficients); //// ä½¿ç¨æ¨¡åè¿è¡é¢æµ //double xNew = target_pressure2; //double yPredicted = NonlinearRegressionHelper.PredictPolynomial(xNew, coefficients); target_flow2 += yPredicted; AlertTool.ShowInfo(this, "颿µæµé缺失", $"{yPredicted:N1}"); //station2_target_flow_diff = yPredicted; //AlertTool.ShowInfo(this, "颿µæµé缺失", $"{yPredicted:N1}"); // è®¡ç® R² å MSE double rSquared = NonlinearRegressionHelper.CalculateRSquared(x, y, coefficients); double mse = NonlinearRegressionHelper.CalculateMSE(x, y, coefficients); //// è®¡ç® R² å MSE //double rSquared = NonlinearRegressionHelper.CalculateRSquared(x, y, coefficients); //double mse = NonlinearRegressionHelper.CalculateMSE(x, y, coefficients); } @@ -221,7 +224,7 @@ helper.Initial(station1_open_flag_list, station1_schedule_config, analysis_deviation_list); var optimal_combine1 = helper.GetOptAnaCombine(station1, station1_flag_inlet_water_level_dict, target_flow1, target_pressure1); helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list); helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list, station2_target_flow_diff); var optimal_combine2 = helper.GetOptAnaCombine(station2, station2_flag_inlet_water_level_dict, target_flow2, target_pressure2); conclusion_list = new List<Model.ScheduleConclusion>(); 02-desktop/Desktop/IStation.Test/Program.cs
@@ -14,7 +14,7 @@ { //Station1Helper.Start(); //1 æ°æ®ä¿®æ£ //Station2Helper.Start(); //2 模åä¿®æ£ // 3 pythonä¿®æ£ // 3 pythonä¿®æ£ ,ç®åæäºæ°æ®é®é¢è¿éè¦è§£å³ //Completion(); //4 ä¿®æ£åç¸ä¼¼æ¢ç®ä¿®æ£ //StationCombineHelper.Start(1);// 5 ç»ååå·®ä¿®æ£ @@ -22,7 +22,7 @@ // 6 åææ³µé¢è°±ç³»æ° // 7 Station2TotalFlowDiffHelper.Start();// 8 è¡¥å ¨æµéåå·® // Station2TotalFlowDiffHelper.Start();// 8 è¡¥å ¨æµéåå·® + python Console.WriteLine(); Console.WriteLine("ok");