From b62f5f0104845c2a3a74707792ebf28a506e24f1 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期一, 17 六月 2024 02:21:26 +0800 Subject: [PATCH] core升级 --- Hydraulic/Hydro.CommonBase/ParamModel.cs | 91 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 76 insertions(+), 15 deletions(-) diff --git a/Hydraulic/Hydro.CommonBase/ParamModel.cs b/Hydraulic/Hydro.CommonBase/ParamModel.cs index 3851824..f92314d 100644 --- a/Hydraulic/Hydro.CommonBase/ParamModel.cs +++ b/Hydraulic/Hydro.CommonBase/ParamModel.cs @@ -18,6 +18,7 @@ namespace Hydro.CommonBase { + [Serializable] public class GeneticParams { static int Count = 0; @@ -97,6 +98,47 @@ public bool isNeedOutput = true; public double CurrentTotalDemand = -1; + public GeneticParams DeepCopy() + { + var copy = new GeneticParams(this.Level); + copy.list_BestEnerge = this.list_BestEnerge?.ToList(); + copy.list_AvgHz = this.list_AvgHz?.ToList(); + copy.ranges = this.ranges?.Select(range => new DRange(range.Min, range.Max))?.ToList(); + copy.DLengths = this.DLengths?.ToList(); + copy.accuracys = this.accuracys?.ToList(); + copy.Dependencies = this.Dependencies?.ToList(); + copy.list_AtemtpArr = this.list_AtemtpArr?.ToArray(); + copy.SolutionSaveName = this.SolutionSaveName; + copy.populationSize = this.populationSize; + copy.iterations = this.iterations; + copy.populationSize_full = this.populationSize_full; + copy.iterations_full = this.iterations_full; + copy.Upopulations = this.Upopulations?.ToList(); + copy.selectionMethod = this.selectionMethod; + copy.optimizationMode = this.optimizationMode; + copy.强制重计算 = this.强制重计算; + copy.iterations_min = this.iterations_min; + copy.accuracyNum = this.accuracyNum; + copy.MaxRobot = this.MaxRobot; + copy.RuningRobot = this.RuningRobot; + copy.num = this.num; + copy.BestOptValue = this.BestOptValue; + copy.tolerance = tolerance==null?null: new DRange(this.tolerance.Min, this.tolerance.Max); + copy.onFinished = this.onFinished; + copy.onError = this.onError; + copy.onReportProgress = this.onReportProgress; + copy.setVars = this.setVars; + copy.Db = this.Db; // Assuming Db is a reference type + copy.SolutionDBHelper = this.SolutionDBHelper; // Assuming SolutionDBHelper is a reference type + copy.GlobalConfig = this.GlobalConfig.DeepCopyByBin<GlobalConfig>(); // Assuming GlobalConfig has a copy constructor + copy.isInited = this.isInited; + copy.Quene = this.Quene; // Assuming Quene has a copy constructor + copy.ID = this.ID; + copy.isNeedOutput = this.isNeedOutput; + copy.CurrentTotalDemand = this.CurrentTotalDemand; + + return copy; + } } public class Result { @@ -447,7 +489,7 @@ this.SearchRange = point.SearchRange; this.isNeedtoSave = point.isNeedtoSave; this.SaveKey = point.SaveKey; - if (point.Pattern!=null) this.Pattern= point.Pattern.ToList().ToArray(); + if (point.Pattern!=null) this.Pattern= point.Pattern.ToArray(); } public string Name; @@ -689,10 +731,24 @@ [Serializable] public class variable: Ivariable { - public static List<string> list_indicatorTypeName; + public static List<string> list_indicatorTypeName + { + get + { + if (_list_indicatorTypeName == null) + { + _list_indicatorTypeName = new List<string>() { "已知压力", "节点用水量", "节点用水模式", "水池水位", "水泵转速比", "管线阻力系数", "阀门开度", "水泵开关", "阀门开关", "管线开关", "管线直径", "管线长度", "总水量", "节点压力", "节点自由压力", "节点需水量", "节点标高", "节点水龄", "节点水质", "管线流量", "管线流速", "水头损失", "当前状态", "水泵能耗", "水泵开关", "水泵转速比", "初始及运行传参", "初始传参", "运行传参", "种群生成器", "方案筛选器", "计算前处理", "结果处理", "当量分配", "随机分配" }; + } + return _list_indicatorTypeName; + } + + } + + private static List<string> _list_indicatorTypeName = null; public static List<string> listUsedInitValue = new List<string>() { "初始计算值", "变化值", "绝对变化值" }; - public static List<string> list_输入值 = new List<string>() { "基准值(界面)", "定义值", "基准值(接口)", "模式系数(界面)", "模式系数(接口)" }; + //public static List<string> list_输入值 = new List<string>() { "基准值(界面)", "定义值", "基准值(接口)", "模式系数(界面)", "模式系数(接口)" }; + public static HashSet<string> list_输入值 = new HashSet<string>() { "基准值(界面)", "定义值", "基准值(接口)", "模式系数(界面)", "模式系数(接口)" }; public static List<string> listUsedScadaValue = new List<string> { "定义值", "基准值(接口)" }; public static List<string> list_接口输出值 = new List<string>() { "表达式计算", "计算值", "变化值", "初始计算值", "子方案值" }; @@ -770,10 +826,12 @@ public int arrgFuncType; public string defaultExpress; private int _indicatorType; + public string IndicatorType { get { + if (_indicatorType<0) { return list_indicatorTypeName[0]; @@ -807,11 +865,11 @@ { get { - return _Values.ToArray(); + return _Values; } private set { - _Values = value.ToArray(); + _Values = value; } } @@ -855,9 +913,11 @@ /// </summary> public string Value_Set(int period,double value) { + _Values[period] = value; + return null; string result = null; double formatValue = value; - if (value!=double.NaN) formatValue = Math.Round(value, 小数位数); + //if (value!=double.NaN) formatValue = Math.Round(value, 小数位数); /*[Cloudflight修改]2024-6-3 解锁 */ @@ -875,10 +935,11 @@ { set { - lock (this) - { - _Values = value; - } + //lock (this) + //{ + // _Values = value; + //} + _Values = value; } } @@ -1061,18 +1122,18 @@ // Value0 = result; // return result; //} - public double? GetLogicValue(int? period=0) + public double GetLogicValue(int period=0) { - if (period != null && period >= 0) - return LogicValues[period.Value]; + if ( period >= 0 && period<LogicValues.Length) + return LogicValues[period]; else - return LogicValue; + return double.NaN; } public double[] GetShowValue_Arr() { - if (list_输入值.IndexOf(expressType) >= 0) + if (variable.list_输入值.Contains(expressType)) //return LogicPattern; return Values; else -- Gitblit v1.9.3