| | |
| | | //using NPOI.SS.Formula.Eval; |
| | | using System.Runtime.Serialization; |
| | | using Newtonsoft.Json; |
| | | using Hydro.Core.Model; |
| | | using System.Collections.Concurrent; |
| | | using Dapper; |
| | | |
| | | namespace CommonBase |
| | | { |
| | |
| | | Count++; |
| | | } |
| | | |
| | | public GeneticParams(string ConfigPath, GeneticParams gParam) |
| | | { |
| | | if (gParam == null) gParam = new GeneticParams(0); |
| | | this.Level = gParam.Level; |
| | | this.ID = gParam.ID; |
| | | if (gParam.Db == null) gParam.Db = new Db(); |
| | | if (!string.IsNullOrEmpty(ConfigPath)) gParam.Db.Init(ConfigPath); |
| | | this.Db = gParam.Db; |
| | | if (gParam.Quene!=null) gParam.Quene.Dispose(); |
| | | gParam.Quene = new Quene(); |
| | | this.Quene= gParam.Quene; |
| | | //获取全局默认设置 |
| | | var globalConfig = gParam.Db.Connection.QueryFirstOrDefault<string>("SELECT FValue FROM MyConfig WHERE FKey='GlobalConfig'"); |
| | | gParam.GlobalConfig = JsonConvert.DeserializeObject<GlobalConfig>(globalConfig) ?? new GlobalConfig(); |
| | | this.GlobalConfig = gParam.GlobalConfig; |
| | | //return gParam; |
| | | } |
| | | public void Dispose() |
| | | { |
| | | onReportProgress = null; |
| | |
| | | |
| | | public int num; |
| | | public double BestOptValue; |
| | | public DoubleRange tolerance; |
| | | public MyDoubleRange tolerance; |
| | | public FinishEvent onFinished; |
| | | public FinishEvent onError; |
| | | public FinishEvent onReportProgress; |
| | | public SetEvent setVars; |
| | | |
| | | public Db Db; |
| | | //public SolutionDBHelper SolutionDBHelper = null; |
| | | public dynamic SolutionDBHelper = null; |
| | | public GlobalConfig GlobalConfig; |
| | | public Quene Quene; |
| | | public int Level; |
| | |
| | | public DateTime ScadaTime; |
| | | public List<TimePoint> TimePoints; |
| | | public double BestResult=double.MaxValue; |
| | | public void Dispose() |
| | | { |
| | | if (RequestQueues != null) |
| | | { |
| | | RequestQueues.Clear(); |
| | | RequestQueues = null; |
| | | } |
| | | if (RequestFinished != null) |
| | | { |
| | | RequestFinished.Clear(); |
| | | RequestFinished = null; |
| | | } |
| | | |
| | | if (ResultHash != null) |
| | | { |
| | | ResultHash.Clear(); |
| | | ResultHash = null; |
| | | } |
| | | if (ResultDictionary != null) |
| | | { |
| | | ResultDictionary.Clear(); |
| | | ResultDictionary = null; |
| | | } |
| | | if (ResultChrome != null) |
| | | { |
| | | ResultChrome.Clear(); |
| | | ResultChrome = null; |
| | | } |
| | | if (MissionQuene != null) |
| | | { |
| | | MissionQuene.Clear(); |
| | | MissionQuene = null; |
| | | } |
| | | if (TimePoints != null) |
| | | { |
| | | TimePoints.Clear(); |
| | | TimePoints = null; |
| | | } |
| | | |
| | | } |
| | | } |
| | | [Serializable] |
| | | |
| | |
| | | |
| | | public Guid ID; |
| | | public List<TimePoint> ScadaPoints { get; set; } = new List<TimePoint>(); |
| | | |
| | | public ConcurrentDictionary<string, TimePoint> dict_Scada_key = null; |
| | | public List<TimePoint> ConfigPoints { get; set; } = new List<TimePoint>(); |
| | | public List<TimePoint> ResultPoints { get; set; } = new List<TimePoint>(); |
| | | public double Fitness = -1; |
| | |
| | | } |
| | | } |
| | | |
| | | //[Serializable] |
| | | [Serializable] |
| | | |
| | | //public class TimePoint |
| | | //{ |
| | | // public TimePoint() |
| | | // { |
| | | public class TimePoint |
| | | { |
| | | public TimePoint() |
| | | { |
| | | |
| | | // } |
| | | // public TimePoint(string key, double value) |
| | | // { |
| | | // Key = key; |
| | | // Value = value; |
| | | // } |
| | | } |
| | | public TimePoint(string key, double value) |
| | | { |
| | | Key = key; |
| | | Value = value; |
| | | } |
| | | |
| | | // public string Name; |
| | | // public DateTime ValueTime { get; set; } |
| | | // public string Key { get; set; } |
| | | // public double Value { get; set; } |
| | | // public double[] Pattern { get; set; } = null; |
| | | // public string ModelObjectID { get; set; } |
| | | // public SettingCalcType CType { get; set; } = SettingCalcType.Add; |
| | | public string Name; |
| | | public DateTime ValueTime { get; set; } |
| | | public string Key { get; set; } |
| | | public double Value { get; set; } |
| | | public double[] Pattern { get; set; } = null; |
| | | public string ModelObjectID { get; set; } |
| | | public SettingCalcType CType { get; set; } = SettingCalcType.Add; |
| | | |
| | | // public double SearchRange = 0; |
| | | public double SearchRange = 0; |
| | | |
| | | // public bool isNeedtoSave = false; |
| | | public bool isNeedtoSave = false; |
| | | |
| | | // public string SaveKey = null; |
| | | public string SaveKey = null; |
| | | |
| | | // public override string ToString() |
| | | // { |
| | | // return $"{Name}\t[{Key}]\t{Value}"; |
| | | // } |
| | | //} |
| | | public override string ToString() |
| | | { |
| | | return $"{Name}\t[{Key}]\t{Value}"; |
| | | } |
| | | } |
| | | |
| | | |
| | | [Serializable] |
| | |
| | | public Dictionary<string, variable> dict_Name; |
| | | public Dictionary<int, variable> dict_ID; |
| | | |
| | | public string inputFileString; |
| | | //public string inputFileString; |
| | | |
| | | public void buildDict() |
| | | { |
| | |
| | | public class OBJFunction |
| | | { |
| | | public string Text_origin; |
| | | public string Text_change; |
| | | public string Text; |
| | | public string ExpressType; |
| | | public string Name; |
| | | |
| | | public double value; |
| | | public DoubleRange tolerance; |
| | | public MyDoubleRange tolerance; |
| | | public variable variable; |
| | | public List<variable> paramVariables; |
| | | public List<double> paramValues; |