using IStation.Algorithm;
|
using Yw.Untity;
|
|
namespace IStation
|
{
|
/// <summary>
|
/// 调度分析辅助类
|
/// </summary>
|
public partial class ScheduleHelper_Update
|
{
|
readonly decimal _frequency_min = 25;
|
readonly decimal _frequency_max = 50;
|
readonly decimal _frequency_space = 0.1m;//频率间隔
|
|
readonly double _start_stop_loss_coefficient = 0.95;//泵启停损失系数
|
|
readonly double _sel_opt_flow_deviation_ratio = 0.05;//可选方案的流量偏差比
|
readonly double _sel_opt_reasonable_flow_deviation_ratio = 0.005;//合理的方案的流量偏差比
|
|
readonly Service.AnalysisCombine _service_analysis_combine = new();
|
readonly Service.AnalysisConclusion _service_analysis_conclusion = new();
|
readonly Service.AnalysisLog _service_analysis_log = new();
|
|
|
int _min_open_count;
|
int _max_open_count;
|
List<int> _current_open_flag_list = null;// 当前开泵列表
|
List<int> _must_open_flag_list = null; // 必开泵列表
|
List<int> _must_close_flag_list = null; // 必关泵列表
|
List<List<int>> _forbidden_flag_combine_list = null; // 禁用泵组合
|
List<List<int>> _associative_flag_combine_list = null; // 关联泵组合
|
List<List<int>> _same_section_flag_combine_list = null; // 同段泵组合
|
List<Model.WaterSupplyLimit> _water_supply_limit_list = null; //供水限制列表
|
List<Model.FrequencyLimit> _frequency_limit_list = null; // 频率限制列表
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
public void Initial(List<int> current_open_flag_list, Model.ScheduleConfig schedule_config)
|
{
|
_min_open_count = schedule_config.MinOpenCount;
|
_max_open_count = schedule_config.MaxOpenCount;
|
_current_open_flag_list = current_open_flag_list;
|
_must_open_flag_list = null;
|
_must_close_flag_list = null;
|
_forbidden_flag_combine_list = null;
|
_associative_flag_combine_list = null;
|
_same_section_flag_combine_list = null;
|
_water_supply_limit_list = null;
|
_frequency_limit_list = null;
|
if (schedule_config != null)
|
{
|
_must_open_flag_list = schedule_config.MustOpenFlagList;
|
_must_close_flag_list = schedule_config.MustCloseFlagList;
|
_forbidden_flag_combine_list = schedule_config.ForbiddenFlagCombineList;
|
_associative_flag_combine_list = schedule_config.AssociativeFlagCombineList;
|
_same_section_flag_combine_list = schedule_config.SameSectionFlagCombineList;
|
_water_supply_limit_list = schedule_config.WaterSupplyLimitList;
|
_frequency_limit_list = schedule_config.FrequencyLimitList;
|
}
|
}
|
|
|
/// <summary>
|
/// 计算(待修改 进口水位 和频率)
|
/// </summary>
|
/// <param name="pump_list"></param>
|
/// <param name="same_type_flag_group_first"></param>
|
/// <param name="flag_inlet_water_level_dict"></param>
|
/// <param name="target_flow"></param>
|
/// <param name="target_head"></param>
|
/// <returns></returns>
|
public AnaOptimalCombine Calc(List<Model.Pump> pump_list, List<int> same_type_flag_group_first, Dictionary<int, double> flag_inlet_water_level_dict, double target_flow, double target_head)
|
{
|
var min_open_count = _min_open_count;
|
var max_open_count = _max_open_count;
|
var current_open_flag_list = _current_open_flag_list;
|
var must_open_flag_list = _must_open_flag_list;
|
var must_close_flag_list = _must_close_flag_list;
|
var forbidden_flag_combine_list = _forbidden_flag_combine_list;
|
var associative_flag_combine_list = _associative_flag_combine_list;
|
var same_section_flag_combine_list = _same_section_flag_combine_list;
|
var water_supply_limit_list = _water_supply_limit_list;
|
var frequency_limit_list = _frequency_limit_list;
|
|
if (pump_list == null || !pump_list.Any())
|
{
|
return default;
|
}
|
target_flow = Math.Round(target_flow, 1);
|
target_head = Math.Round(target_head, 1);
|
|
#region 存在-当前开泵列表
|
|
var exist_current_open_flag_list = current_open_flag_list != null && current_open_flag_list.Count > 0;
|
|
#endregion
|
|
#region 存在-必开泵列表
|
|
var must_open_flag_list_remark = string.Empty;
|
var exist_must_open_flag_list = must_open_flag_list != null && must_open_flag_list.Count > 0;
|
if (exist_must_open_flag_list)
|
{
|
must_open_flag_list = must_open_flag_list.OrderBy(x => x).ToList();
|
must_open_flag_list_remark = IntListHelper.ToString(must_open_flag_list);
|
}
|
|
#endregion
|
|
#region 存在-必关泵列表
|
|
var exist_must_close_flag_list = must_close_flag_list != null && must_close_flag_list.Count > 0;
|
|
#endregion
|
|
#region 存在-禁用组合
|
|
var exist_forbidden_flag_combine_list = forbidden_flag_combine_list != null && forbidden_flag_combine_list.Count > 0;
|
|
#endregion
|
|
#region 存在-关联组合
|
|
var exist_associative_flag_combine_list = associative_flag_combine_list != null && associative_flag_combine_list.Count > 0;
|
|
#endregion
|
|
#region 存在-同段泵组合
|
|
Dictionary<int, List<int[]>> same_section_combine_dict = new();
|
var exist_same_section_flag_combine_list = _same_section_flag_combine_list != null && _same_section_flag_combine_list.Count > 0;
|
if (exist_same_section_flag_combine_list)
|
{
|
for (int pump_count = 1; pump_count <= pump_list.Count; pump_count++)
|
{
|
same_section_combine_dict[pump_count] = new List<int[]>();
|
switch (pump_count)
|
{
|
case 2:
|
{
|
foreach (var same_section_flag_combine in same_section_flag_combine_list)
|
{
|
var combine_list = GetCombineList(same_section_flag_combine, 2);
|
same_section_combine_dict[pump_count].AddRange(combine_list);
|
}
|
}
|
break;
|
case 3:
|
{
|
foreach (var same_section in same_section_flag_combine_list)
|
{
|
var combine_list = GetCombineList(same_section, 3);
|
same_section_combine_dict[pump_count].AddRange(combine_list);
|
}
|
}
|
break;
|
case 4:
|
{
|
foreach (var same_section in same_section_flag_combine_list)
|
{
|
var combine_list3 = GetCombineList(same_section, 3);
|
same_section_combine_dict[pump_count].AddRange(combine_list3);
|
if (same_section.Count > 3)
|
{
|
var combine_list = GetCombineList(same_section, 4);
|
same_section_combine_dict[pump_count].AddRange(combine_list);
|
}
|
}
|
}
|
break;
|
case 5:
|
{
|
foreach (var same_section in same_section_flag_combine_list)
|
{
|
if (same_section.Count > 3)
|
{
|
var combine_list = GetCombineList(same_section, 4);
|
same_section_combine_dict[pump_count].AddRange(combine_list);
|
}
|
}
|
}
|
break;
|
case 6:
|
{
|
foreach (var same_section in same_section_flag_combine_list)
|
{
|
if (same_section.Count > 3)
|
{
|
var combine_list = GetCombineList(same_section, 4);
|
same_section_combine_dict[pump_count].AddRange(combine_list);
|
}
|
}
|
}
|
break;
|
default:
|
break;
|
}
|
}
|
}
|
#endregion
|
|
#region 存在-供水限制
|
|
var exist_water_supply_limit_list = water_supply_limit_list != null && water_supply_limit_list.Count > 0;
|
|
#endregion
|
|
#region 存在-频率限制
|
var frequency_limit_flag_dict = new Dictionary<int, Model.FrequencyLimit>();
|
var exist_frequency_limit_list = frequency_limit_list != null && frequency_limit_list.Count > 0;
|
if (exist_frequency_limit_list)
|
{
|
frequency_limit_flag_dict = frequency_limit_list.ToDictionary(x => x.Flag, x => x);
|
}
|
|
#endregion
|
|
#region 存在-优先度排序 暂未考虑
|
|
// var exist_priority_order_flag_list = priority_order_flag_list != null && priority_order_flag_list.Count > 0;
|
|
#endregion
|
|
var pump_bp_dict = pump_list.ToDictionary(x => x.Flag, x => x.IsBp);
|
var pump_nr_dict = pump_list.ToDictionary(x => x.Flag, x => x.Nr);
|
var pump_flag_list = pump_list.Select(x => x.Flag).ToList();
|
var optimal_combine_list = new List<AnaOptimalCombine>();
|
for (int pumpCount = _min_open_count; pumpCount <= _max_open_count; pumpCount++)
|
{
|
if (pumpCount == 1)
|
{
|
var max_total_flow = pump_list.Max(x => x.Qr);
|
if (max_total_flow < target_flow)
|
continue;
|
}
|
|
//供水限制
|
if (exist_water_supply_limit_list)
|
{
|
var exist_limit = false;
|
foreach (var limit in water_supply_limit_list)
|
{
|
if (target_flow >= limit.Min && target_flow <= limit.Max)
|
{
|
if (limit.PumpCount != pumpCount)
|
{
|
exist_limit = true;
|
break;
|
}
|
}
|
}
|
if (exist_limit)
|
continue;
|
}
|
|
var combine_list = GetCombineList(pump_flag_list, pumpCount);//排列组合
|
foreach (var combine in combine_list)
|
{
|
double combine_merit_ratio = 1;//组合择优率
|
|
//必开
|
if (exist_must_open_flag_list)
|
{
|
var combine_remark = IntListHelper.ToString(combine.OrderBy(x => x));
|
if (!combine_remark.Contains(must_open_flag_list_remark))
|
continue;
|
}
|
|
//必关
|
if (exist_must_close_flag_list)
|
{
|
var exist_intersected = combine.Intersect(must_close_flag_list).Count() > 0;
|
if (exist_intersected)
|
continue;
|
}
|
|
//禁用组合
|
if (exist_forbidden_flag_combine_list)
|
{
|
var exist_equal = false;
|
foreach (var flag_list in forbidden_flag_combine_list)
|
{
|
if (combine.SequenceEqual(flag_list))
|
{
|
exist_equal = true;
|
break;
|
}
|
}
|
if (exist_equal)
|
continue;
|
}
|
|
//同段泵组合
|
if (exist_same_section_flag_combine_list)
|
{
|
var exist_equal = false;
|
foreach (var flag_list in same_section_combine_dict[pumpCount])
|
{
|
//相同
|
if (combine.SequenceEqual(flag_list))
|
{
|
exist_equal = true;
|
break;
|
}
|
|
//包含
|
if (flag_list.Intersect(combine).Count() == flag_list.Length)
|
{
|
exist_equal = true;
|
break;
|
}
|
}
|
if (exist_equal)
|
continue;
|
}
|
|
//关联组合
|
if (exist_associative_flag_combine_list)
|
{
|
var exist_intersected = false;
|
foreach (var flag_list in associative_flag_combine_list)
|
{
|
var except_count = combine.Except(flag_list).Count();
|
if (except_count != flag_list.Count && except_count > 0)
|
{
|
exist_intersected = true;
|
}
|
}
|
if (exist_intersected)
|
continue;
|
}
|
|
int start_stop_count = 0;//启停数量
|
if (exist_current_open_flag_list)
|
{
|
var start_pump_count = combine.Except(current_open_flag_list).Count();
|
var close_pump_count = current_open_flag_list.Except(combine).Count();
|
start_stop_count = start_pump_count + close_pump_count;//启停数量
|
}
|
else
|
{
|
start_stop_count = combine.Count();
|
if (exist_must_open_flag_list)
|
{
|
start_stop_count = combine.Except(must_open_flag_list).Count();
|
}
|
}
|
|
var total_loss_ratio = Math.Pow(_start_stop_loss_coefficient, start_stop_count);//启停一次损失些能耗
|
combine_merit_ratio *= total_loss_ratio;
|
List<int> combine_flag_list_part1 = new();
|
List<int> combine_flag_list_part2 = new();
|
foreach (var pump in combine)
|
{
|
if (same_type_flag_group_first.Contains(pump))
|
{
|
combine_flag_list_part1.Add(pump);
|
}
|
else
|
{
|
combine_flag_list_part2.Add(pump);
|
}
|
}
|
|
//区分同型号泵
|
List<AnaFreCombine> fre_combine_list_part1 = new();
|
List<AnaFreCombine> fre_combine_list_part2 = new();
|
|
var combine_correction_factor_dict = GetCombineCorrectionFactor(combine);
|
if (combine_flag_list_part1.Count > 0)
|
{
|
var conclusion_list_dic = new Dictionary<int, List<Model.AnalysisConclusion>>();
|
foreach (var flag in combine_flag_list_part1)
|
{
|
var runFlag = RunFlagHelper.GetRunFlag(flag, pump_bp_dict[flag]);
|
if (conclusion_list_dic.ContainsKey(flag))
|
continue;
|
|
//进口水位
|
var inlet_water_level = flag_inlet_water_level_dict[flag];
|
|
//组合修正系数
|
var combine_correction_factor = combine_correction_factor_dict[flag];
|
var current_target_head = target_head - inlet_water_level + combine_correction_factor;
|
current_target_head = Math.Round(current_target_head, 1);
|
|
//频率限制
|
var conclusionList = new List<Model.AnalysisConclusion>();
|
if (exist_frequency_limit_list && frequency_limit_flag_dict.ContainsKey(flag))
|
{
|
var limit = frequency_limit_flag_dict[flag];
|
conclusionList = _service_analysis_conclusion.GetList(runFlag, limit.Min, limit.Max, current_target_head);
|
}
|
else
|
{
|
conclusionList = _service_analysis_conclusion.GetList(runFlag, current_target_head);
|
}
|
conclusion_list_dic[flag] = conclusionList;
|
}
|
|
if (conclusion_list_dic.Count < 1)
|
continue;
|
|
|
for (decimal fre = _frequency_max; fre >= _frequency_min; fre -= _frequency_space)
|
{
|
var freCombine = new AnaFreCombine();
|
freCombine.Frequency = (double)fre;
|
freCombine.Flags = new List<int>();
|
freCombine.FrePumps = new List<AnaFrePump>();
|
foreach (var item in conclusion_list_dic)
|
{
|
var conclusion = item.Value?.Find(x => x.Pump1 == (double)fre);
|
if (conclusion != null)
|
{
|
freCombine.Flags.Add(item.Key);
|
freCombine.Flow += conclusion.Flow;
|
freCombine.Power += conclusion.Power;
|
freCombine.RunCount++;
|
|
var fre_pump = new AnaFrePump();
|
fre_pump.Flag = item.Key;
|
fre_pump.Flow = conclusion.Flow;
|
fre_pump.Head = conclusion.Head;
|
fre_pump.Power = conclusion.Power;
|
fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
|
fre_pump.Frequency = freCombine.Frequency;
|
fre_pump.Speed = (double)fre / 50 * pump_nr_dict[item.Key];
|
freCombine.FrePumps.Add(fre_pump);
|
}
|
}
|
if (freCombine.Flags.Count < 1)
|
continue;
|
fre_combine_list_part1.Add(freCombine);
|
}
|
}
|
|
if (combine_flag_list_part2.Count > 0)
|
{
|
var conclusion_list_dic = new Dictionary<int, List<Model.AnalysisConclusion>>();
|
foreach (var flag in combine_flag_list_part2)
|
{
|
var runFlag = RunFlagHelper.GetRunFlag(flag, pump_bp_dict[flag]);
|
if (conclusion_list_dic.ContainsKey(flag))
|
continue;
|
|
//进口水位
|
var inlet_water_level = flag_inlet_water_level_dict[flag];
|
|
//组合修正系数
|
var combine_correction_factor = combine_correction_factor_dict[flag];
|
var current_target_head = target_head - inlet_water_level + combine_correction_factor;
|
current_target_head = Math.Round(current_target_head, 1);
|
|
//频率限制
|
var conclusionList = new List<Model.AnalysisConclusion>();
|
if (exist_frequency_limit_list && frequency_limit_flag_dict.ContainsKey(flag))
|
{
|
var limit = frequency_limit_flag_dict[flag];
|
conclusionList = _service_analysis_conclusion.GetList(runFlag, limit.Min, limit.Max, current_target_head);
|
}
|
else
|
{
|
conclusionList = _service_analysis_conclusion.GetList(runFlag, current_target_head);
|
}
|
conclusion_list_dic[flag] = conclusionList;
|
}
|
|
if (conclusion_list_dic.Count < 1)
|
{
|
continue;
|
}
|
|
for (decimal fre = _frequency_max; fre >= _frequency_min; fre -= _frequency_space)
|
{
|
var freCombine = new AnaFreCombine();
|
freCombine.Frequency = (double)fre;
|
freCombine.Flags = new List<int>();
|
freCombine.FrePumps = new List<AnaFrePump>();
|
foreach (var item in conclusion_list_dic)
|
{
|
var conclusion = item.Value?.Find(x => x.Pump1 == (double)fre);
|
if (conclusion != null)
|
{
|
freCombine.Flags.Add(item.Key);
|
freCombine.Flow += conclusion.Flow;
|
freCombine.Power += conclusion.Power;
|
freCombine.RunCount++;
|
|
var fre_pump = new AnaFrePump();
|
fre_pump.Flag = item.Key;
|
fre_pump.Flow = conclusion.Flow;
|
fre_pump.Head = conclusion.Head;
|
fre_pump.Power = conclusion.Power;
|
fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
|
fre_pump.Frequency = freCombine.Frequency;
|
fre_pump.Speed = (double)fre / 50 * pump_nr_dict[item.Key];
|
freCombine.FrePumps.Add(fre_pump);
|
}
|
}
|
if (freCombine.Flags.Count < 1)
|
continue;
|
fre_combine_list_part2.Add(freCombine);
|
}
|
}
|
|
if (fre_combine_list_part1.Count == 0 && fre_combine_list_part2.Count == 0)
|
continue;
|
|
double total_flow_deviation = target_flow;//总流量偏差
|
double total_power = double.MaxValue;//总功率
|
double total_flow = double.MaxValue;//总流量
|
|
AnaFreCombine optimal_combine_part1 = null;
|
AnaFreCombine optimal_combine_part2 = null;
|
if (fre_combine_list_part1.Count < 1 || fre_combine_list_part2.Count < 1)
|
{
|
if (fre_combine_list_part1.Count < 1)
|
{
|
fre_combine_list_part1 = fre_combine_list_part2;
|
}
|
for (int Index_part1 = 0; Index_part1 < fre_combine_list_part1.Count; Index_part1++)
|
{
|
var fre_combine1 = fre_combine_list_part1[Index_part1];
|
var current_flow = fre_combine1.Flow;
|
var current_power = fre_combine1.Power;
|
|
var diff_flow = Math.Abs(current_flow - target_flow);
|
if (diff_flow < total_flow_deviation)
|
{
|
optimal_combine_part1 = fre_combine1;
|
total_power = fre_combine1.Power;
|
total_flow = current_flow;
|
total_flow_deviation = diff_flow;
|
}
|
|
if (diff_flow < target_flow * 0.01 && current_power < total_power)
|
{
|
optimal_combine_part1 = fre_combine1;
|
total_power = fre_combine1.Power;
|
total_flow = current_flow;
|
}
|
}
|
}
|
else
|
{
|
for (int Index_part1 = 0; Index_part1 < fre_combine_list_part1.Count; Index_part1++)
|
{
|
for (int Index_part2 = 0; Index_part2 < fre_combine_list_part2.Count; Index_part2++)
|
{
|
var fre_combine1 = fre_combine_list_part1[Index_part1];
|
var fre_combine2 = fre_combine_list_part2[Index_part2];
|
|
var current_flow = fre_combine1.Flow + fre_combine2.Flow;
|
var current_power = fre_combine1.Power + fre_combine2.Power;
|
|
var diff_flow = Math.Abs(current_flow - target_flow);
|
if (diff_flow < total_flow_deviation)
|
{
|
optimal_combine_part1 = fre_combine1;
|
optimal_combine_part2 = fre_combine2;
|
total_power = fre_combine1.Power + fre_combine2.Power;
|
total_flow = current_flow;
|
total_flow_deviation = diff_flow;
|
}
|
|
if (diff_flow < target_flow * 0.01 && current_power < total_power)
|
{
|
optimal_combine_part1 = fre_combine1;
|
optimal_combine_part2 = fre_combine2;
|
total_power = fre_combine1.Power + fre_combine2.Power;
|
total_flow = current_flow;
|
}
|
|
}
|
}
|
}
|
if (total_flow < target_flow * 0.99)
|
continue;
|
|
if (optimal_combine_part1 == null && optimal_combine_part2 == null)
|
continue;
|
|
var total_flow_deviation_ratio = Math.Abs((1 - Math.Abs((total_flow / target_flow))));
|
if (total_flow_deviation_ratio > _sel_opt_flow_deviation_ratio)
|
continue;
|
if (total_flow_deviation_ratio > _sel_opt_reasonable_flow_deviation_ratio)
|
{
|
combine_merit_ratio -= total_flow_deviation_ratio;
|
}
|
|
|
var actual_target_head = target_head;
|
var inlet_water_head = flag_inlet_water_level_dict.Average(x => x.Value);
|
if (inlet_water_head > 0)
|
{
|
actual_target_head = target_head - inlet_water_head;
|
actual_target_head = Math.Round(actual_target_head, 2);
|
}
|
|
var efficiency = Curve.PumpCalculateHelper.CalculateE(total_flow, actual_target_head, total_power);
|
var wp = Curve.PumpCalculateHelper.CalculateWP(total_power, total_flow);
|
var uwp = Curve.PumpCalculateHelper.CalculateUWP(total_power, total_flow, actual_target_head);
|
|
#region 分析最优组合方案
|
|
var optimal_combine = new AnaOptimalCombine();
|
optimal_combine.Combines = new List<AnaFreCombine>();
|
optimal_combine.Flags = new List<int>();
|
if (optimal_combine_part1 != null)
|
{
|
optimal_combine.Combines.Add(optimal_combine_part1);
|
optimal_combine.Flags.AddRange(optimal_combine_part1.Flags);
|
}
|
if (optimal_combine_part2 != null)
|
{
|
optimal_combine.Combines.Add(optimal_combine_part2);
|
optimal_combine.Flags.AddRange(optimal_combine_part2.Flags);
|
}
|
optimal_combine.Flow = total_flow;
|
optimal_combine.Head = target_head;
|
optimal_combine.Power = total_power;
|
optimal_combine.Efficiency = efficiency;
|
optimal_combine.WP = wp;
|
optimal_combine.UWP = uwp;
|
|
optimal_combine.Flags = optimal_combine.Flags.OrderBy(x => x).ToList();
|
optimal_combine.FlagCount = optimal_combine.Flags.Count;
|
optimal_combine.Remark = IntListHelper.ToString(optimal_combine.Flags);
|
optimal_combine.MeritRatio = combine_merit_ratio;
|
optimal_combine_list.Add(optimal_combine);
|
|
#endregion
|
}
|
}
|
|
if (optimal_combine_list.Count < 1)
|
return default;
|
|
optimal_combine_list = optimal_combine_list.OrderByDescending(x => x.MeritRatio).ToList();
|
var opt = optimal_combine_list.First();
|
opt.Round();
|
return opt;
|
}
|
|
/// <summary>
|
/// 获取排列组合
|
/// </summary>
|
/// <param name="flags"></param>
|
/// <param name="count"></param>
|
/// <returns></returns>
|
private List<int[]> GetCombineList(List<int> flags, int count)
|
{
|
var combine = IStation.Curve.PermutationAndCombination<int>.GetCombination(flags.ToArray(), count);
|
return combine;
|
}
|
|
/// <summary>
|
/// 获取组合修正系数
|
/// </summary>
|
/// <param name="flags"></param>
|
/// <returns></returns>
|
private Dictionary<int, double> GetCombineCorrectionFactor(IEnumerable<int> flags)
|
{
|
var correction_factor_dict = new Dictionary<int, double>();
|
|
var r = new Random(0);
|
foreach (var flag in flags)
|
{
|
double factor = 0;
|
//factor += r.NextDouble();
|
correction_factor_dict.Add(flag, factor);
|
}
|
|
return correction_factor_dict;
|
}
|
|
private double _fre_diff_value = 3;
|
private bool IsFrequencyDiffTooLarge(IEnumerable<double> frequency_list)
|
{
|
if (frequency_list == null || !frequency_list.Any())
|
return true;
|
var max_frequency = frequency_list.Max();
|
var min_frequency = frequency_list.Min();
|
var diff_frequency = Math.Round(max_frequency - min_frequency, 1);
|
return diff_frequency > _fre_diff_value;
|
}
|
|
|
#region 添加项目 只有3台变频泵:AddAnaFreCombine
|
private AnaFreCombine AddAnaFreCombine3(double target_flow, Dictionary<int, List<Model.AnalysisConclusion>> conclusion_list_dic, Dictionary<int, double> pump_nr_dict)
|
{
|
var ana_cl_item1 = conclusion_list_dic.ElementAt(0);
|
var ana_cl_item2 = conclusion_list_dic.ElementAt(1);
|
var ana_cl_item3 = conclusion_list_dic.ElementAt(2);
|
|
var ana_pump1_flag = ana_cl_item1.Key;
|
var ana_pump2_flag = ana_cl_item2.Key;
|
var ana_pump3_flag = ana_cl_item3.Key;
|
|
var ana_cl_list_pump1 = ana_cl_item1.Value;
|
var ana_cl_list_pump2 = ana_cl_item2.Value;
|
var ana_cl_list_pump3 = ana_cl_item3.Value;
|
|
|
double total_flow_deviation = target_flow;//总流量偏差
|
double total_power = double.MaxValue;//总功率
|
double total_flow = double.MaxValue;//总流量
|
|
Model.AnalysisConclusion opt_cl_pump1 = null;
|
Model.AnalysisConclusion opt_cl_pump2 = null;
|
Model.AnalysisConclusion opt_cl_pump3 = null;
|
|
|
for (int Index_pump1 = 0; Index_pump1 < ana_cl_list_pump1.Count; Index_pump1++)
|
{
|
for (int Index_pump2 = 0; Index_pump2 < ana_cl_list_pump2.Count; Index_pump2++)
|
{
|
for (int Index_pump3 = 0; Index_pump3 < ana_cl_list_pump3.Count; Index_pump3++)
|
{
|
var cl_pump1 = ana_cl_list_pump1[Index_pump1];
|
var cl_pump2 = ana_cl_list_pump2[Index_pump2];
|
var cl_pump3 = ana_cl_list_pump3[Index_pump3];
|
var frequency_list = new List<double>()
|
{
|
cl_pump1.Pump1,
|
cl_pump2.Pump1,
|
cl_pump3.Pump1
|
};
|
|
if (IsFrequencyDiffTooLarge(frequency_list))
|
continue;
|
|
var current_flow = cl_pump1.Flow + cl_pump2.Flow + cl_pump3.Flow;
|
var current_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power;
|
|
var diff_flow = Math.Abs(current_flow - target_flow);
|
if (diff_flow < total_flow_deviation)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power;
|
total_flow = current_flow;
|
total_flow_deviation = diff_flow;
|
}
|
|
if (diff_flow < target_flow * 0.01 && current_power < total_power)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power;
|
total_flow = current_flow;
|
}
|
}
|
}
|
}
|
|
var opt_cl_dict = new Dictionary<int, Model.AnalysisConclusion>()
|
{
|
{ ana_pump1_flag,opt_cl_pump1},
|
{ ana_pump2_flag,opt_cl_pump2},
|
{ ana_pump3_flag,opt_cl_pump3}
|
};
|
|
var fre_combine = new AnaFreCombine();
|
fre_combine.Frequency = 0;
|
fre_combine.Flags = new List<int>();
|
fre_combine.FrePumps = new List<AnaFrePump>();
|
foreach (var item in opt_cl_dict)
|
{
|
var flag = item.Key;
|
var cl = item.Value;
|
fre_combine.Flags.Add(flag);
|
fre_combine.Flow += cl.Flow;
|
fre_combine.Power += cl.Power;
|
fre_combine.RunCount++;
|
|
var fre_pump = new AnaFrePump();
|
fre_pump.Flag = flag;
|
fre_pump.Flow = cl.Flow;
|
fre_pump.Head = cl.Head;
|
fre_pump.Power = cl.Power;
|
fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
|
fre_pump.Frequency = fre_combine.Frequency;
|
fre_pump.Speed = cl.Pump1 / 50 * pump_nr_dict[item.Key];
|
fre_combine.FrePumps.Add(fre_pump);
|
|
}
|
|
|
return fre_combine;
|
}
|
#endregion
|
|
#region 添加项目 只有4台变频泵:AddAnaFreCombine
|
private AnaFreCombine AddAnaFreCombine4(double target_flow, Dictionary<int, List<Model.AnalysisConclusion>> conclusion_list_dic, Dictionary<int, double> pump_nr_dict)
|
{
|
var ana_cl_item1 = conclusion_list_dic.ElementAt(0);
|
var ana_cl_item2 = conclusion_list_dic.ElementAt(1);
|
var ana_cl_item3 = conclusion_list_dic.ElementAt(2);
|
var ana_cl_item4 = conclusion_list_dic.ElementAt(3);
|
|
var ana_pump1_flag = ana_cl_item1.Key;
|
var ana_pump2_flag = ana_cl_item2.Key;
|
var ana_pump3_flag = ana_cl_item3.Key;
|
var ana_pump4_flag = ana_cl_item4.Key;
|
|
var ana_cl_list_pump1 = ana_cl_item1.Value;
|
var ana_cl_list_pump2 = ana_cl_item2.Value;
|
var ana_cl_list_pump3 = ana_cl_item3.Value;
|
var ana_cl_list_pump4 = ana_cl_item4.Value;
|
|
|
double total_flow_deviation = target_flow;//总流量偏差
|
double total_power = double.MaxValue;//总功率
|
double total_flow = double.MaxValue;//总流量
|
|
Model.AnalysisConclusion opt_cl_pump1 = null;
|
Model.AnalysisConclusion opt_cl_pump2 = null;
|
Model.AnalysisConclusion opt_cl_pump3 = null;
|
Model.AnalysisConclusion opt_cl_pump4 = null;
|
|
|
for (int Index_pump1 = 0; Index_pump1 < ana_cl_list_pump1.Count; Index_pump1++)
|
{
|
for (int Index_pump2 = 0; Index_pump2 < ana_cl_list_pump2.Count; Index_pump2++)
|
{
|
for (int Index_pump3 = 0; Index_pump3 < ana_cl_list_pump3.Count; Index_pump3++)
|
{
|
for (int Index_pump4 = 0; Index_pump4 < ana_cl_list_pump4.Count; Index_pump4++)
|
{
|
var cl_pump1 = ana_cl_list_pump1[Index_pump1];
|
var cl_pump2 = ana_cl_list_pump2[Index_pump2];
|
var cl_pump3 = ana_cl_list_pump3[Index_pump3];
|
var cl_pump4 = ana_cl_list_pump4[Index_pump4];
|
var frequency_list = new List<double>()
|
{
|
cl_pump1.Pump1,
|
cl_pump2.Pump1,
|
cl_pump3.Pump1,
|
cl_pump4.Pump1
|
};
|
if (IsFrequencyDiffTooLarge(frequency_list))
|
continue;
|
|
var current_flow = cl_pump1.Flow + cl_pump2.Flow + cl_pump3.Flow + cl_pump4.Flow;
|
var current_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power;
|
|
var diff_flow = Math.Abs(current_flow - target_flow);
|
if (diff_flow < total_flow_deviation)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
opt_cl_pump4 = cl_pump4;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power;
|
total_flow = current_flow;
|
total_flow_deviation = diff_flow;
|
}
|
|
if (diff_flow < target_flow * 0.01 && current_power < total_power)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
opt_cl_pump4 = cl_pump4;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power;
|
total_flow = current_flow;
|
}
|
}
|
}
|
}
|
}
|
|
var opt_cl_dict = new Dictionary<int, Model.AnalysisConclusion>()
|
{
|
{ ana_pump1_flag,opt_cl_pump1},
|
{ ana_pump2_flag,opt_cl_pump2},
|
{ ana_pump3_flag,opt_cl_pump3},
|
{ ana_pump4_flag,opt_cl_pump4},
|
};
|
|
var fre_combine = new AnaFreCombine();
|
fre_combine.Frequency = 0;
|
fre_combine.Flags = new List<int>();
|
fre_combine.FrePumps = new List<AnaFrePump>();
|
foreach (var item in opt_cl_dict)
|
{
|
var flag = item.Key;
|
var cl = item.Value;
|
fre_combine.Flags.Add(flag);
|
fre_combine.Flow += cl.Flow;
|
fre_combine.Power += cl.Power;
|
fre_combine.RunCount++;
|
|
var fre_pump = new AnaFrePump();
|
fre_pump.Flag = flag;
|
fre_pump.Flow = cl.Flow;
|
fre_pump.Head = cl.Head;
|
fre_pump.Power = cl.Power;
|
fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
|
fre_pump.Frequency = fre_combine.Frequency;
|
fre_pump.Speed = cl.Pump1 / 50 * pump_nr_dict[item.Key];
|
fre_combine.FrePumps.Add(fre_pump);
|
}
|
|
|
return fre_combine;
|
}
|
#endregion
|
|
#region 添加项目 只有5台变频泵:AddAnaFreCombine
|
private AnaFreCombine AddAnaFreCombine5(double target_flow, Dictionary<int, List<Model.AnalysisConclusion>> conclusion_list_dic, Dictionary<int, double> pump_nr_dict)
|
{
|
var ana_cl_item1 = conclusion_list_dic.ElementAt(0);
|
var ana_cl_item2 = conclusion_list_dic.ElementAt(1);
|
var ana_cl_item3 = conclusion_list_dic.ElementAt(2);
|
var ana_cl_item4 = conclusion_list_dic.ElementAt(3);
|
var ana_cl_item5 = conclusion_list_dic.ElementAt(4);
|
|
var ana_pump1_flag = ana_cl_item1.Key;
|
var ana_pump2_flag = ana_cl_item2.Key;
|
var ana_pump3_flag = ana_cl_item3.Key;
|
var ana_pump4_flag = ana_cl_item4.Key;
|
var ana_pump5_flag = ana_cl_item5.Key;
|
|
var ana_cl_list_pump1 = ana_cl_item1.Value;
|
var ana_cl_list_pump2 = ana_cl_item2.Value;
|
var ana_cl_list_pump3 = ana_cl_item3.Value;
|
var ana_cl_list_pump4 = ana_cl_item4.Value;
|
var ana_cl_list_pump5 = ana_cl_item5.Value;
|
|
|
double total_flow_deviation = target_flow;//总流量偏差
|
double total_power = double.MaxValue;//总功率
|
double total_flow = double.MaxValue;//总流量
|
|
Model.AnalysisConclusion opt_cl_pump1 = null;
|
Model.AnalysisConclusion opt_cl_pump2 = null;
|
Model.AnalysisConclusion opt_cl_pump3 = null;
|
Model.AnalysisConclusion opt_cl_pump4 = null;
|
Model.AnalysisConclusion opt_cl_pump5 = null;
|
|
|
for (int Index_pump1 = 0; Index_pump1 < ana_cl_list_pump1.Count; Index_pump1++)
|
{
|
for (int Index_pump2 = 0; Index_pump2 < ana_cl_list_pump2.Count; Index_pump2++)
|
{
|
for (int Index_pump3 = 0; Index_pump3 < ana_cl_list_pump3.Count; Index_pump3++)
|
{
|
for (int Index_pump4 = 0; Index_pump4 < ana_cl_list_pump4.Count; Index_pump4++)
|
{
|
for (int Index_pump5 = 0; Index_pump5 < ana_cl_list_pump5.Count; Index_pump5++)
|
{
|
var cl_pump1 = ana_cl_list_pump1[Index_pump1];
|
var cl_pump2 = ana_cl_list_pump2[Index_pump2];
|
var cl_pump3 = ana_cl_list_pump3[Index_pump3];
|
var cl_pump4 = ana_cl_list_pump4[Index_pump4];
|
var cl_pump5 = ana_cl_list_pump5[Index_pump5];
|
var frequency_list = new List<double>()
|
{
|
cl_pump1.Pump1,
|
cl_pump2.Pump1,
|
cl_pump3.Pump1,
|
cl_pump4.Pump1,
|
cl_pump5.Pump1,
|
};
|
if (IsFrequencyDiffTooLarge(frequency_list))
|
continue;
|
|
var current_flow = cl_pump1.Flow + cl_pump2.Flow + cl_pump3.Flow + cl_pump4.Flow + cl_pump5.Flow;
|
var current_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power + cl_pump5.Power;
|
|
var diff_flow = Math.Abs(current_flow - target_flow);
|
if (diff_flow < total_flow_deviation)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
opt_cl_pump4 = cl_pump4;
|
opt_cl_pump5 = cl_pump5;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power + cl_pump5.Power;
|
total_flow = current_flow;
|
total_flow_deviation = diff_flow;
|
}
|
|
if (diff_flow < target_flow * 0.01 && current_power < total_power)
|
{
|
opt_cl_pump1 = cl_pump1;
|
opt_cl_pump2 = cl_pump2;
|
opt_cl_pump3 = cl_pump3;
|
opt_cl_pump4 = cl_pump4;
|
opt_cl_pump5 = cl_pump5;
|
total_power = cl_pump1.Power + cl_pump2.Power + cl_pump3.Power + cl_pump4.Power + cl_pump5.Power;
|
total_flow = current_flow;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
var opt_cl_dict = new Dictionary<int, Model.AnalysisConclusion>()
|
{
|
{ ana_pump1_flag,opt_cl_pump1},
|
{ ana_pump2_flag,opt_cl_pump2},
|
{ ana_pump3_flag,opt_cl_pump3},
|
{ ana_pump4_flag,opt_cl_pump4},
|
{ ana_pump5_flag,opt_cl_pump5},
|
};
|
|
var fre_combine = new AnaFreCombine();
|
fre_combine.Frequency = 0;
|
fre_combine.Flags = new List<int>();
|
fre_combine.FrePumps = new List<AnaFrePump>();
|
foreach (var item in opt_cl_dict)
|
{
|
var flag = item.Key;
|
var cl = item.Value;
|
fre_combine.Flags.Add(flag);
|
fre_combine.Flow += cl.Flow;
|
fre_combine.Power += cl.Power;
|
fre_combine.RunCount++;
|
|
var fre_pump = new AnaFrePump();
|
fre_pump.Flag = flag;
|
fre_pump.Flow = cl.Flow;
|
fre_pump.Head = cl.Head;
|
fre_pump.Power = cl.Power;
|
fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
|
fre_pump.Frequency = fre_combine.Frequency;
|
fre_pump.Speed = cl.Pump1 / 50 * pump_nr_dict[item.Key];
|
fre_combine.FrePumps.Add(fre_pump);
|
}
|
|
|
return fre_combine;
|
}
|
#endregion
|
|
|
}
|
}
|