From 8c68ab4be4bff7981e745cc2b41c7bba5257a2d3 Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期三, 16 四月 2025 20:37:38 +0800 Subject: [PATCH] 流量偏差 辅助类 --- 01-api/_Expand/IStation.Win.Schedule/bjMain.cs | 89 +++++++++++++++++++++++--------------------- 1 files changed, 46 insertions(+), 43 deletions(-) diff --git a/01-api/_Expand/IStation.Win.Schedule/bjMain.cs b/01-api/_Expand/IStation.Win.Schedule/bjMain.cs index 8f2144d..3fda114 100644 --- a/01-api/_Expand/IStation.Win.Schedule/bjMain.cs +++ b/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>(); -- Gitblit v1.9.3