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
fea0e9bf
Commit
fea0e9bf
authored
Oct 29, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,增加适应度函数计算函数
parent
6cb113e7
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
224 additions
and
10 deletions
+224
-10
FirstOptScheduling.cpp
pandaAlgorithm/FirstOptScheduling.cpp
+38
-2
FirstOptScheduling.h
pandaAlgorithm/FirstOptScheduling.h
+8
-2
GenAlg.cpp
pandaAlgorithm/GenAlg.cpp
+11
-0
GenAlg.h
pandaAlgorithm/GenAlg.h
+4
-0
OptScheduling.cpp
pandaAlgorithm/OptScheduling.cpp
+12
-1
OptScheduling.h
pandaAlgorithm/OptScheduling.h
+25
-4
pandaAlgorithm.vcxproj
pandaAlgorithm/pandaAlgorithm.vcxproj
+1
-1
CivReport.h
pandaAnalysis/CivReport.h
+58
-0
CivReportReader.cpp
pandaAnalysis/CivReportReader.cpp
+27
-0
CivReportReader.h
pandaAnalysis/CivReportReader.h
+27
-0
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+3
-0
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+10
-0
No files found.
pandaAlgorithm/FirstOptScheduling.cpp
View file @
fea0e9bf
...
...
@@ -50,7 +50,7 @@ double FirstOptScheduling::pumpPower(const PumpStruct& pumpParam)
return
result
;
}
double
FirstOptScheduling
::
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
)
double
FirstOptScheduling
::
waterProductionCost
(
const
vector
<
double
>&
Q
,
const
vector
<
double
>&
S3
)
{
if
(
Q
.
size
()
!=
S3
.
size
())
return
0
;
...
...
@@ -65,7 +65,7 @@ double FirstOptScheduling::waterProductionCost(const std::vector<double>& Q, con
return
result
;
}
double
FirstOptScheduling
::
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
)
double
FirstOptScheduling
::
waterSupplyAndDemand
(
const
vector
<
double
>&
Q
,
const
double
&
Qd
)
{
size_t
total
=
Q
.
size
();
double
result
=
0
;
...
...
@@ -75,4 +75,39 @@ double FirstOptScheduling::waterSupplyAndDemand(const std::vector<double>& Q, co
}
return
std
::
abs
(
result
-
Qd
);
}
double
FirstOptScheduling
::
objectiveFunction
(
float
cost
,
const
map
<
string
,
double
>&
monitorVals
)
{
// 适应度函数简易版
float
sum
=
0.0
;
map
<
string
,
double
>::
const_iterator
conIter
=
monitorVals
.
cbegin
();
for
(;
conIter
!=
monitorVals
.
cend
();
conIter
++
)
{
string
key
=
conIter
->
first
;
double
val
=
conIter
->
second
;
map
<
string
,
double
>::
iterator
minIter
=
mMinMonitorVals
.
find
(
key
);
if
(
minIter
==
mMinMonitorVals
.
end
())
continue
;
map
<
string
,
double
>::
iterator
maxIter
=
mMaxMonitorVals
.
find
(
key
);
if
(
maxIter
==
mMaxMonitorVals
.
end
())
continue
;
float
minVal
=
minIter
->
second
;
float
maxVal
=
maxIter
->
second
;
float
maxMinDiff
=
maxVal
-
minVal
;
if
(
val
<
minVal
)
{
sum
+=
((
minVal
-
val
)
/
maxMinDiff
);
}
else
if
(
val
>
maxVal
)
{
sum
+=
((
val
-
maxVal
)
/
maxMinDiff
);
}
}
return
1
/
(
C1
+
cost
)
*
(
1
+
sum
);
}
\ No newline at end of file
pandaAlgorithm/FirstOptScheduling.h
View file @
fea0e9bf
...
...
@@ -12,6 +12,12 @@ public:
FirstOptScheduling
();
~
FirstOptScheduling
();
/**
* @brief 目标函数,计算适应度值
* @param [in] monitorVals
*/
virtual
double
objectiveFunction
(
float
cost
,
const
map
<
string
,
double
>&
monitorVals
);
/**
* @brief 供需压差函数
* @param [in] HC[i]: 测压点i预测压力值
...
...
@@ -34,7 +40,7 @@ public:
* @param [vector<double>] S3[i] 第i个泵站的制水成本,单位: 元/m3
* @return
*/
virtual
double
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
);
virtual
double
waterProductionCost
(
const
vector
<
double
>&
Q
,
const
vector
<
double
>&
S3
);
virtual
double
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
);
virtual
double
waterSupplyAndDemand
(
const
vector
<
double
>&
Q
,
const
double
&
Qd
);
};
pandaAlgorithm/GenAlg.cpp
View file @
fea0e9bf
...
...
@@ -267,4 +267,14 @@ void GenAlg::encoding(map<string, int>& phenotype, vector<char>& chromo)
void
GenAlg
::
decoding
(
vector
<
char
>&
chromo
,
map
<
string
,
int
>&
phenotype
)
{
}
void
GenAlg
::
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
)
{
mOptScheduling
->
setMaxMonitorVals
(
maxMonitors
);
}
void
GenAlg
::
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
)
{
mOptScheduling
->
setMinMonitorsVals
(
minMonitors
);
}
\ No newline at end of file
pandaAlgorithm/GenAlg.h
View file @
fea0e9bf
...
...
@@ -78,6 +78,10 @@ public:
*/
void
decoding
(
vector
<
char
>&
chromo
,
map
<
string
,
int
>&
phenotype
);
void
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
);
void
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
);
private
:
// 产生[a,b)之间的浮点数
double
random
(
int
a
=
0
,
int
b
=
RAND_MAX
);
...
...
pandaAlgorithm/OptScheduling.cpp
View file @
fea0e9bf
...
...
@@ -10,7 +10,7 @@ OptScheduling::~OptScheduling()
}
double
OptScheduling
::
objectiveFunction
()
double
OptScheduling
::
objectiveFunction
(
float
cost
,
const
map
<
string
,
double
>&
monitorVals
)
{
double
res
=
0
;
return
res
;
...
...
@@ -39,4 +39,14 @@ double OptScheduling::waterSupplyAndDemand(const std::vector<double>& Q, const d
{
double
res
=
0
;
return
res
;
}
void
OptScheduling
::
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
)
{
mMaxMonitorVals
=
maxMonitors
;
}
void
OptScheduling
::
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
)
{
mMinMonitorVals
=
minMonitors
;
}
\ No newline at end of file
pandaAlgorithm/OptScheduling.h
View file @
fea0e9bf
...
...
@@ -2,6 +2,7 @@
#include "pandaAlgorithm.h"
#include <vector>
#include <map>
#include <string>
using
namespace
std
;
...
...
@@ -28,7 +29,11 @@ public:
std
::
vector
<
int
>
mP
;
//第i泵站中调速泵的台数
};
virtual
double
objectiveFunction
();
/**
* @brief 目标函数,计算适应度值
* @param [in] monitorVals
*/
virtual
double
objectiveFunction
(
float
cost
,
const
map
<
string
,
double
>&
monitorVals
);
/**
* @brief 供需压差函数
...
...
@@ -36,7 +41,7 @@ public:
* @param [in] HF[I]: 测压点i要求的最低供水服务压力。
* @return
*/
virtual
double
pressureDifference
(
const
std
::
vector
<
double
>&
HC
,
const
std
::
vector
<
double
>&
HF
);
virtual
double
pressureDifference
(
const
vector
<
double
>&
HC
,
const
vector
<
double
>&
HF
);
/**
* @brief 水泵供水功耗
...
...
@@ -52,7 +57,7 @@ public:
* @param
* @return
*/
virtual
double
waterProductionCost
(
const
std
::
vector
<
double
>&
Q
,
const
std
::
vector
<
double
>&
S3
);
virtual
double
waterProductionCost
(
const
vector
<
double
>&
Q
,
const
vector
<
double
>&
S3
);
/**
* @brief 供需水量
...
...
@@ -60,10 +65,25 @@ public:
* @param [double] Qd 总需水量,预测
* @return
*/
virtual
double
waterSupplyAndDemand
(
const
std
::
vector
<
double
>&
Q
,
const
double
&
Qd
);
virtual
double
waterSupplyAndDemand
(
const
vector
<
double
>&
Q
,
const
double
&
Qd
);
// 设置监测点的最大值
void
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
);
// 设置监测点的最小值
void
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
);
protected
:
// 惩罚因子1
double
C1
;
// 惩罚因子2
double
C2
;
// 设置的监测点的调度最大值
map
<
string
,
double
>
mMaxMonitorVals
;
// 设置的监测点的调度最小值
map
<
string
,
double
>
mMinMonitorVals
;
};
\ No newline at end of file
pandaAlgorithm/pandaAlgorithm.vcxproj
View file @
fea0e9bf
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
...
...
pandaAnalysis/CivReport.h
0 → 100644
View file @
fea0e9bf
#pragma once
#define EnergyHead "能量利用"
#define TotalEnergy "需电费"
#define TotalCost "总成本"
#define LineSeparator "----------------------------------------------------------------------"
#define NodeHead "节点结果"
#define PipeHead "管段结果"
#define Node "节点"
#define Demand "需水量"
#define TotalHead "总水头"
#define Pressure "压力"
#define Quality "水质"
#define Pipe "管段"
#define UnitHeadLoss "单位水头损失"
#define Flow "流量"
#define Velocity "流速"
#define Status "状态"
#define Open "打开"
#define Close "关闭"
#define Pump "水泵"
/***
模拟报告的一些数结构体
*/
// 管段模拟结果值
typedef
struct
PipeStruct
{
char
sz
[
128
];
float
flow
;
float
velocity
;
// 流速
float
unitHeadLosss
;
// 单位水头损失
char
status
[
256
];
// 状态
};
// 节点模拟结果值
typedef
struct
NodeStruct
{
char
sz
[
128
];
// id号
float
demand
;
float
totalHead
;
float
pressure
;
float
quality
;
};
// 能量报告结构体
typedef
struct
EnergyStruct
{
char
sz
[
128
];
float
percentage
;
// 百分比利用
float
averEffic
;
// 平均效率
float
kwm
;
// kw-hr
float
averKilowatt
;
// 平均千瓦
float
dayCost
;
// 成本/日
};
pandaAnalysis/CivReportReader.cpp
0 → 100644
View file @
fea0e9bf
#include "CivReportReader.h"
#include<fstream>
#include<iostream>
CivReportReader
::
CivReportReader
()
{
}
void
CivReportReader
::
readEnergy
(
const
string
&
pumpSn
,
string
&
enery
)
{
}
bool
CivReportReader
::
open
(
const
string
&
reportFile
)
{
ifstream
stream
(
reportFile
.
c_str
());
// жȡ
string
sLine
;
while
(
getline
(
stream
,
sLine
))
{
}
stream
.
close
();
}
pandaAnalysis/CivReportReader.h
0 → 100644
View file @
fea0e9bf
#pragma once
#include <string>
#include <vector>
#include <map>
#include "CivReport.h"
using
namespace
std
;
/**
读取模拟计算报告的
*/
class
CivReportReader
{
public
:
CivReportReader
();
bool
open
(
const
string
&
reportFile
);
void
readEnergy
(
const
string
&
pumpSn
,
string
&
enery
);
private
:
vector
<
EnergyStruct
>
mEnergys
;
// 能耗读取
vector
<
NodeStruct
>
mNodes
;
vector
<
PipeStruct
>
mPipes
;
};
\ No newline at end of file
pandaAnalysis/pandaAnalysis.vcxproj
View file @
fea0e9bf
...
...
@@ -172,6 +172,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile
Include=
"CivProjManager.cpp"
/>
<ClCompile
Include=
"CivProjSimulation.cpp"
/>
<ClCompile
Include=
"CivProjSmulResultCache.cpp"
/>
<ClCompile
Include=
"CivReportReader.cpp"
/>
<ClCompile
Include=
"CivSchedulingCompute.cpp"
/>
<ClCompile
Include=
"CivSimulResultCache.cpp"
/>
<ClCompile
Include=
"CivStopWaterAnalysis.cpp"
/>
...
...
@@ -196,6 +197,8 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude
Include=
"CivProjManager.h"
/>
<ClInclude
Include=
"CivProjSimulation.h"
/>
<ClInclude
Include=
"CivProjSmulResultCache.h"
/>
<ClInclude
Include=
"CivReport.h"
/>
<ClInclude
Include=
"CivReportReader.h"
/>
<ClInclude
Include=
"CivSchedulingCompute.h"
/>
<ClInclude
Include=
"CivSimulResultCache.h"
/>
<ClInclude
Include=
"CivStopWaterAnalysis.h"
/>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
fea0e9bf
...
...
@@ -78,6 +78,9 @@
<ClCompile
Include=
"CivSchedulingCompute.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivReportReader.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrFuncInter.h"
>
...
...
@@ -149,5 +152,11 @@
<ClInclude
Include=
"CivSchedulingCompute.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivReport.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivReportReader.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
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