Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘乐
hydraulicModel
Commits
d32ecb9c
Commit
d32ecb9c
authored
Oct 20, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 添加目标函数定义
parent
dd384c8d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
179 additions
and
17 deletions
+179
-17
.gitignore
.gitignore
+1
-0
FirstOptScheduling.cpp
pandaAlgorithm/FirstOptScheduling.cpp
+68
-0
FirstOptScheduling.h
pandaAlgorithm/FirstOptScheduling.h
+30
-1
OptScheduling.cpp
pandaAlgorithm/OptScheduling.cpp
+8
-2
OptScheduling.h
pandaAlgorithm/OptScheduling.h
+30
-2
OptSchedulingGenetic.h
pandaAlgorithm/OptSchedulingGenetic.h
+2
-1
genetic.h
pandaAlgorithm/genetic.h
+6
-1
CivHydrCompute.cpp
pandaAnalysis/CivHydrCompute.cpp
+34
-10
No files found.
.gitignore
View file @
d32ecb9c
...
...
@@ -5,3 +5,4 @@
/.vs/hydraulicModel/v16
/temp/EPNAET2/x64/Release
/temp
/funcDemo
pandaAlgorithm/FirstOptScheduling.cpp
View file @
d32ecb9c
...
...
@@ -9,3 +9,70 @@ FirstOptScheduling::~FirstOptScheduling()
{
}
double
FirstOptScheduling
::
pressureDifference
(
const
std
::
vector
<
double
>&
HC
,
const
std
::
vector
<
double
>&
HF
)
{
if
(
HC
.
size
()
!=
HF
.
size
())
return
0
;
size_t
total
=
HC
.
size
();
double
result
=
0.0
;
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
result
+=
(
HC
[
i
]
-
HF
[
i
]);
}
return
result
;
}
double
FirstOptScheduling
::
pumpPower
(
const
PumpStruct
&
pumpParam
)
{
std
::
vector
<
double
>
s1
=
pumpParam
.
mS1
;
double
a
=
pumpParam
.
a
;
int
total
=
s1
.
size
();
double
result
=
0.0
;
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
result
+=
s1
[
i
];
// 第i个泵站的定速泵和调速泵的总数
int
columns
=
pumpParam
.
mK
[
i
]
+
pumpParam
.
mP
[
i
];
double
temp
=
0.0
;
for
(
int
j
=
0
;
j
<
columns
;
j
++
)
{
temp
+=
(
(
a
*
pumpParam
.
mNS
[
i
][
j
]
*
pumpParam
.
mQS
[
i
][
j
]
\
*
pumpParam
.
mHS
[
i
][
j
])
/
(
pumpParam
.
mK
[
i
][
j
]
*
pumpParam
.
mY
[
i
][
j
]));
}
temp
*=
pumpParam
.
mS2
[
i
];
result
+=
temp
;
}
return
result
;
}
double
FirstOptScheduling
::
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
)
{
if
(
Q
.
size
()
!=
S3
.
size
())
return
0
;
int
total
=
Q
.
size
();
double
result
=
0
;
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
result
+=
(
Q
[
i
]
*
S3
[
i
]);
}
return
result
;
}
double
FirstOptScheduling
::
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
)
{
size_t
total
=
Q
.
size
();
double
result
=
0
;
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
result
+=
Q
[
i
];
}
return
std
::
abs
(
result
-
Qd
);
}
\ No newline at end of file
pandaAlgorithm/FirstOptScheduling.h
View file @
d32ecb9c
#pragma once
#include "pandaAlgorithm.h"
#include "OptScheduling.h"
#include <vector>
class
PANDAALGORITHM_API
FirstOptScheduling
/**
*@brief 直接优化调度
*/
class
PANDAALGORITHM_API
FirstOptScheduling
:
public
OptScheduling
{
public
:
FirstOptScheduling
();
~
FirstOptScheduling
();
/**
* @brief 供需压差函数
* @param [in] HC[i]: 测压点i预测压力值
* @param [in] HF[I]: 测压点i要求的最低供水服务压力。
* @return
*/
virtual
double
pressureDifference
(
const
std
::
vector
<
double
>&
HC
,
const
std
::
vector
<
double
>&
HF
);
/**
* @brief 水泵供水功耗
* @param
* @param
* @return
*/
virtual
double
pumpPower
(
const
PumpStruct
&
pumpParam
);
/**
* @brief 制水成本
* @param [vector<double>] Q[i] 第i个泵站供水量
* @param [vector<double>] S3[i] 第i个泵站的制水成本,单位: 元/m3
* @return
*/
virtual
double
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
);
virtual
double
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
);
};
pandaAlgorithm/OptScheduling.cpp
View file @
d32ecb9c
...
...
@@ -16,14 +16,20 @@ double OptScheduling::pressureDifference(const std::vector<double>& HC, const st
return
res
;
}
double
OptScheduling
::
pumpPower
()
double
OptScheduling
::
pumpPower
(
const
PumpStruct
&
pumpParam
)
{
double
res
=
0
;
return
res
;
}
double
OptScheduling
::
waterProductionCost
()
double
OptScheduling
::
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
)
{
double
res
=
0
;
return
res
;
}
double
OptScheduling
::
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
)
{
double
res
=
0
;
return
res
;
...
...
pandaAlgorithm/OptScheduling.h
View file @
d32ecb9c
#pragma once
#include "pandaAlgorithm.h"
#include <vector>
#include <map>
class
PANDAALGORITHM_API
OptScheduling
{
...
...
@@ -8,6 +9,24 @@ public:
explicit
OptScheduling
();
virtual
~
OptScheduling
();
/**
水泵参数
*/
struct
PumpStruct
{
double
a
;
// 换算系数
std
::
vector
<
double
>
mS1
;
// 第i泵站的基本电费
std
::
vector
<
double
>
mS2
;
// 别第i泵站的电度电价
std
::
vector
<
std
::
vector
<
int
>>
mNS
;
// 第i个泵站第j种泵的开机台数
std
::
vector
<
std
::
vector
<
double
>>
mQS
;
// 第i个泵站第j中泵的供水量
std
::
vector
<
std
::
vector
<
double
>>
mHS
;
// 第i泵站第j种水泵的计算扬
std
::
vector
<
std
::
vector
<
double
>>
mY
;
// 第i泵站第j种水泵的计算效率,可由水泵Q~v曲线拟合其关系式
std
::
vector
<
std
::
vector
<
double
>>
mX
;
// 第两i站第j水泵机组的传动效率
std
::
vector
<
int
>
mK
;
// 第i泵站中定速泵的台数
std
::
vector
<
int
>
mP
;
//第i泵站中调速泵的台数
};
/**
* @brief 供需压差函数
* @param [in] HC[i]: 测压点i预测压力值
...
...
@@ -22,7 +41,7 @@ public:
* @param
* @return
*/
virtual
double
pumpPower
();
virtual
double
pumpPower
(
const
PumpStruct
&
pumpParam
);
/**
* @brief 制水成本
...
...
@@ -30,5 +49,13 @@ public:
* @param
* @return
*/
virtual
double
waterProductionCost
();
virtual
double
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
);
/**
* @brief 供需水量
* @param [vector<double>] Q[i] 第 i 个泵站调度供水量
* @param [double] Qd 总需水量,预测
* @return
*/
virtual
double
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
);
};
\ No newline at end of file
pandaAlgorithm/OptSchedulingGenetic.h
View file @
d32ecb9c
...
...
@@ -48,7 +48,8 @@ public:
virtual
void
variation
();
/**
*@brief 更新种群
*@brief 更新种
*
*/
virtual
void
update
();
...
...
pandaAlgorithm/genetic.h
View file @
d32ecb9c
...
...
@@ -67,11 +67,16 @@ public:
// 杂焦虑
double
crossoverRate
()
const
{
return
mCrossoverRate
;
}
void
setCrossverRate
(
double
verRate
)
{
mCrossoverRate
=
verRate
;
}
double
selectRate
()
const
{
return
mSelectRate
;
}
void
setSelectRate
(
double
selRate
)
{
mSelectRate
=
selRate
;
}
double
variationRate
()
const
{
return
mVariationRate
;
}
void
setVariationRate
(
double
rate
)
{
mVariationRate
=
rate
;
}
private
:
int
mNumPop
=
100
;
//初始种群大小
int
mNumPop
=
100
;
//
初始种群大小
int
mIrangeL
=
-
1
;
// 问题解区间
int
mIrangeR
=
2
;
int
mLength
=
22
;
// 二进制编码长度
...
...
pandaAnalysis/CivHydrCompute.cpp
View file @
d32ecb9c
...
...
@@ -295,14 +295,13 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT
CivDate
civDate
;
nowDate
=
civDate
.
getDate
();
int
baseTime
=
CivCommonUtils
::
currentHour
();
int
baseTime
=
0
;
//
CivCommonUtils::currentHour();
int
a
=
baseTime
+
time
;
int
modulus
=
a
%
24
;
int
yu
=
a
/
24
;
if
(
yu
>
0
)
{
civDate
.
addDate
();
nowDate
=
civDate
.
getDate
();
a
=
modulus
;
...
...
@@ -313,7 +312,7 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT
else
nowTime
=
(
std
::
to_string
(
a
)
+
":00:00"
);
nowTime
=
nowDate
+
" "
+
nowTime
;
nowTime
=
nowDate
+
" "
+
nowTime
;
}
void
CivHydrCompute
::
getNodeResult
(
short
time
)
...
...
@@ -330,11 +329,12 @@ void CivHydrCompute::getNodeResult(short time)
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
ENgetnodetype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_JUNCTION
)
continue
;
switch
(
*
typeCode
)
{
case
EN_JUNCTION
:
// 用户节点
{
NodeResultItem
nodeItem
;
ENgetnodeid
(
i
,
nodeItem
.
szNo
);
// 编号
ENgetnodevalue
(
i
,
EN_HEAD
,
&
nodeItem
.
dHead
);
// 水头
ENgetnodevalue
(
i
,
EN_PRESSURE
,
&
nodeItem
.
dPressure
);
// 压力
...
...
@@ -345,7 +345,16 @@ void CivHydrCompute::getNodeResult(short time)
nodeItem
.
dTime
=
nowTime
;
nodeItem
.
dModifyTime
=
CurrentTime
;
mResultCache
.
addNodeItems
(
time
,
nodeItem
);
}
break
;
case
EN_TANK
:
// 水厂
{
}
break
;
default
:
break
;
}
}
free
(
typeCode
);
}
...
...
@@ -364,9 +373,11 @@ void CivHydrCompute::getLinkResult(short time)
{
LinkResultItem
linkItem
;
ENgetlinktype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_PIPE
)
continue
;
switch
(
*
typeCode
)
{
case
EN_PIPE
:
{
ENgetlinkid
(
i
,
linkItem
.
szNo
);
// 编号
ENgetlinkvalue
(
i
,
EN_FLOW
,
&
linkItem
.
dFlow
);
// 流量
ENgetlinkvalue
(
i
,
EN_VELOCITY
,
&
linkItem
.
dVelocity
);
// 流速
...
...
@@ -385,7 +396,21 @@ void CivHydrCompute::getLinkResult(short time)
linkItem
.
dModifyTime
=
CurrentTime
;
// 放到缓存类中
mResultCache
.
addLinkItems
(
time
,
linkItem
);
mResultCache
.
addLinkItems
(
time
,
linkItem
);
}
break
;
case
EN_PUMP
:
{
ENgetlinkid
(
i
,
linkItem
.
szNo
);
// 编号
ENgetlinkvalue
(
i
,
EN_ENERGY
,
&
linkItem
.
dFlow
);
// 水泵耗能
}
break
;
default
:
break
;
}
}
free
(
typeCode
);
}
...
...
@@ -408,7 +433,6 @@ void CivHydrCompute::getNodeQuality(short time)
mResultCache
.
addNodeQuality
(
quality
,
time
,
No
);
}
}
free
(
typeCode
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment