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
618d8082
Commit
618d8082
authored
Nov 30, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 优化调度接口修改和优化
parent
8b64e676
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
170 additions
and
67 deletions
+170
-67
CivHydrTest.cpp
funcDemo/CivHydrTest.cpp
+5
-2
FirstOptScheduling.cpp
pandaAlgorithm/FirstOptScheduling.cpp
+3
-3
FirstOptScheduling.h
pandaAlgorithm/FirstOptScheduling.h
+2
-0
OptScheduling.cpp
pandaAlgorithm/OptScheduling.cpp
+1
-0
OptScheduling.h
pandaAlgorithm/OptScheduling.h
+5
-0
CivHydrCompute.cpp
pandaAnalysis/CivHydrCompute.cpp
+53
-35
CivHydrCompute.h
pandaAnalysis/CivHydrCompute.h
+2
-0
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+3
-0
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+3
-1
CivInpConvertor.cpp
pandaAnalysis/CivInpConvertor.cpp
+8
-7
CivInpConvertor.h
pandaAnalysis/CivInpConvertor.h
+4
-0
CivOptSchedEngine.cpp
pandaAnalysis/CivOptSchedEngine.cpp
+22
-7
CivSchedulingCompute.cpp
pandaAnalysis/CivSchedulingCompute.cpp
+4
-3
CivSchedulingCompute.h
pandaAnalysis/CivSchedulingCompute.h
+1
-0
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+12
-0
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+1
-0
CivInpDbHelper.cpp
pandaDbManager/CivInpDbHelper.cpp
+31
-9
CivCommonUtils.h
pandaLog/CivCommonUtils.h
+10
-0
No files found.
funcDemo/CivHydrTest.cpp
View file @
618d8082
...
@@ -41,15 +41,18 @@ void CivConQuaTest::test(char* uri)
...
@@ -41,15 +41,18 @@ void CivConQuaTest::test(char* uri)
// 追踪分析
// 追踪分析
void
CivConTrackTest
::
test
(
char
*
uri
)
void
CivConTrackTest
::
test
(
char
*
uri
)
{
{
char
result
[
1024
*
512
];
char
result
[
1024
*
512
];
char
sn
[
64
];
char
sn
[
64
];
strcpy_s
(
sn
,
"5
fbaaf9e-dfcf-4e97-9fb1-31d03293f654
"
);
strcpy_s
(
sn
,
"5
c8afd3e-b361-4458-b5ca-6891ec80ae8c
"
);
int
succ
=
trackingSimulation
(
uri
,
sn
,
6
,
result
);
memset
(
result
,
0
,
sizeof
(
result
)
/
sizeof
(
char
));
int
succ
=
trackingSimulation
(
uri
,
sn
,
1
,
result
);
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
succ
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
succ
<<
std
::
endl
;
}
}
void
CivUpstreamTrackingTest
::
test
(
char
*
uri
)
void
CivUpstreamTrackingTest
::
test
(
char
*
uri
)
...
...
pandaAlgorithm/FirstOptScheduling.cpp
View file @
618d8082
...
@@ -92,7 +92,7 @@ double FirstOptScheduling::objectiveFunction(float cost, const map<string, doubl
...
@@ -92,7 +92,7 @@ double FirstOptScheduling::objectiveFunction(float cost, const map<string, doubl
continue
;
continue
;
map
<
string
,
double
>::
iterator
maxIter
=
mMaxMonitorVals
.
find
(
key
);
map
<
string
,
double
>::
iterator
maxIter
=
mMaxMonitorVals
.
find
(
key
);
if
(
maxIter
==
mMaxMonitorVals
.
end
())
if
(
maxIter
==
mMaxMonitorVals
.
end
())
continue
;
continue
;
float
minVal
=
minIter
->
second
;
float
minVal
=
minIter
->
second
;
...
@@ -101,11 +101,11 @@ double FirstOptScheduling::objectiveFunction(float cost, const map<string, doubl
...
@@ -101,11 +101,11 @@ double FirstOptScheduling::objectiveFunction(float cost, const map<string, doubl
if
(
val
<
minVal
)
if
(
val
<
minVal
)
{
{
sum
+=
((
minVal
-
val
)
/
maxMinDiff
);
sum
+=
((
val
-
minVal
)
/
maxMinDiff
);
}
}
else
if
(
val
>
maxVal
)
else
if
(
val
>
maxVal
)
{
{
sum
+=
((
val
-
maxVal
)
/
maxMinDiff
);
sum
+=
((
maxVal
-
val
)
/
maxMinDiff
);
}
}
}
}
...
...
pandaAlgorithm/FirstOptScheduling.h
View file @
618d8082
...
@@ -43,4 +43,6 @@ public:
...
@@ -43,4 +43,6 @@ public:
virtual
double
waterProductionCost
(
const
vector
<
double
>&
Q
,
const
vector
<
double
>&
S3
);
virtual
double
waterProductionCost
(
const
vector
<
double
>&
Q
,
const
vector
<
double
>&
S3
);
virtual
double
waterSupplyAndDemand
(
const
vector
<
double
>&
Q
,
const
double
&
Qd
);
virtual
double
waterSupplyAndDemand
(
const
vector
<
double
>&
Q
,
const
double
&
Qd
);
};
};
pandaAlgorithm/OptScheduling.cpp
View file @
618d8082
...
@@ -44,6 +44,7 @@ double OptScheduling::waterSupplyAndDemand(const std::vector<double>& Q, const d
...
@@ -44,6 +44,7 @@ double OptScheduling::waterSupplyAndDemand(const std::vector<double>& Q, const d
void
OptScheduling
::
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
)
void
OptScheduling
::
setMaxMonitorVals
(
const
map
<
string
,
double
>&
maxMonitors
)
{
{
mMaxMonitorVals
=
maxMonitors
;
mMaxMonitorVals
=
maxMonitors
;
}
}
void
OptScheduling
::
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
)
void
OptScheduling
::
setMinMonitorsVals
(
const
map
<
string
,
double
>&
minMonitors
)
...
...
pandaAlgorithm/OptScheduling.h
View file @
618d8082
...
@@ -84,6 +84,10 @@ protected:
...
@@ -84,6 +84,10 @@ protected:
// 设置的监测点的调度最大值
// 设置的监测点的调度最大值
map
<
string
,
double
>
mMaxMonitorVals
;
map
<
string
,
double
>
mMaxMonitorVals
;
double
mMaxVals
;
// 监测点最大值
double
mMinVals
;
// 监测点最小是
// 设置的监测点的调度最小值
// 设置的监测点的调度最小值
map
<
string
,
double
>
mMinMonitorVals
;
map
<
string
,
double
>
mMinMonitorVals
;
};
};
\ No newline at end of file
pandaAnalysis/CivHydrCompute.cpp
View file @
618d8082
...
@@ -6,9 +6,9 @@
...
@@ -6,9 +6,9 @@
CivHydrCompute
::
CivHydrCompute
()
CivHydrCompute
::
CivHydrCompute
()
{
{
mInFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
mInFile
=
"
test.inp"
;
mRptFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.rpt"
;
mRptFile
=
"
test.rpt"
;
mBinFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.bin"
;
mBinFile
=
"
test.bin"
;
}
}
bool
CivHydrCompute
::
qualityCompute
()
bool
CivHydrCompute
::
qualityCompute
()
...
@@ -51,6 +51,7 @@ bool CivHydrCompute::qualityCompute()
...
@@ -51,6 +51,7 @@ bool CivHydrCompute::qualityCompute()
return
false
;
return
false
;
}
}
mResultCache
.
clear
();
do
do
{
{
...
@@ -117,6 +118,11 @@ bool CivHydrCompute::qualityCompute()
...
@@ -117,6 +118,11 @@ bool CivHydrCompute::qualityCompute()
return
true
;
return
true
;
}
}
void
CivHydrCompute
::
clearCache
()
{
mResultCache
.
clear
();
}
bool
CivHydrCompute
::
hdyrCompute
()
bool
CivHydrCompute
::
hdyrCompute
()
{
{
short
hydCode
=
1
;
short
hydCode
=
1
;
...
@@ -135,6 +141,7 @@ bool CivHydrCompute::hdyrCompute()
...
@@ -135,6 +141,7 @@ bool CivHydrCompute::hdyrCompute()
errcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
errcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
if
(
errcode
>
0
)
if
(
errcode
>
0
)
{
{
...
@@ -232,8 +239,7 @@ bool CivHydrCompute::chlorineCompute()
...
@@ -232,8 +239,7 @@ bool CivHydrCompute::chlorineCompute()
ENclose
();
ENclose
();
return
false
;
return
false
;
}
}
do
do
{
{
int
nLinkCount
;
int
nLinkCount
;
...
@@ -299,29 +305,15 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT
...
@@ -299,29 +305,15 @@ void CivHydrCompute::dateAndTime(int time,std::string& nowDate,std::string& nowT
{
{
CivDate
civDate
;
CivDate
civDate
;
nowDate
=
civDate
.
getDate
();
nowDate
=
civDate
.
getDate
();
nowTime
=
nowDate
+
" "
+
to_string
(
time
)
+
":00:00"
;
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
;
}
if
(
modulus
<
10
)
nowTime
=
(
"0"
+
std
::
to_string
(
a
)
+
":00:00"
);
else
nowTime
=
(
std
::
to_string
(
a
)
+
":00:00"
);
nowTime
=
nowDate
+
" "
+
nowTime
;
}
}
void
CivHydrCompute
::
getNodeResult
(
short
time
)
void
CivHydrCompute
::
getNodeResult
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
// 计算节点
// 计算节点
int
nNodeCount
;
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
...
@@ -366,6 +358,10 @@ void CivHydrCompute::getNodeResult(short time)
...
@@ -366,6 +358,10 @@ void CivHydrCompute::getNodeResult(short time)
void
CivHydrCompute
::
getLinkResult
(
short
time
)
void
CivHydrCompute
::
getLinkResult
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
int
nLinkCount
;
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
...
@@ -422,6 +418,10 @@ void CivHydrCompute::getLinkResult(short time)
...
@@ -422,6 +418,10 @@ void CivHydrCompute::getLinkResult(short time)
void
CivHydrCompute
::
getNodeQuality
(
short
time
)
void
CivHydrCompute
::
getNodeQuality
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
int
nNodeCount
;
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
...
@@ -444,6 +444,10 @@ void CivHydrCompute::getNodeQuality(short time)
...
@@ -444,6 +444,10 @@ void CivHydrCompute::getNodeQuality(short time)
void
CivHydrCompute
::
getLinkQuality
(
short
time
)
void
CivHydrCompute
::
getLinkQuality
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
int
nLinkCount
;
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
...
@@ -465,6 +469,11 @@ void CivHydrCompute::getLinkQuality(short time)
...
@@ -465,6 +469,11 @@ void CivHydrCompute::getLinkQuality(short time)
void
CivHydrCompute
::
getNodeChlorine
(
short
time
)
void
CivHydrCompute
::
getNodeChlorine
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
int
nNodeCount
;
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
...
@@ -489,6 +498,11 @@ void CivHydrCompute::getNodeChlorine(short time)
...
@@ -489,6 +498,11 @@ void CivHydrCompute::getNodeChlorine(short time)
void
CivHydrCompute
::
getLinkChlorine
(
short
time
)
void
CivHydrCompute
::
getLinkChlorine
(
short
time
)
{
{
if
(
time
<=
0
)
return
;
time
-=
1
;
int
nLinkCount
;
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
...
@@ -540,17 +554,21 @@ void CivHydrCompute::getTrackingResult(const std::string& uri,std::string& jsonR
...
@@ -540,17 +554,21 @@ void CivHydrCompute::getTrackingResult(const std::string& uri,std::string& jsonR
for
(
int
j
=
0
;
j
<
total
;
j
++
)
for
(
int
j
=
0
;
j
<
total
;
j
++
)
{
{
std
::
string
sn
=
pipeS
[
j
];
std
::
string
sn
=
pipeS
[
j
];
PipeCoord
pipe
=
pipeCoords
.
find
(
sn
)
->
second
;
auto
iter
=
pipeCoords
.
find
(
sn
);
if
(
iter
!=
pipeCoords
.
end
())
jsonResult
.
append
(
"[["
);
{
jsonResult
.
append
(
pipe
.
startX
);
PipeCoord
pipe
=
iter
->
second
;
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
startY
);
jsonResult
.
append
(
"[["
);
jsonResult
.
append
(
"],["
);
jsonResult
.
append
(
pipe
.
startX
);
jsonResult
.
append
(
pipe
.
endX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
startY
);
jsonResult
.
append
(
pipe
.
endY
);
jsonResult
.
append
(
"],["
);
jsonResult
.
append
(
"]],"
);
jsonResult
.
append
(
pipe
.
endX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
endY
);
jsonResult
.
append
(
"]],"
);
}
}
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
...
...
pandaAnalysis/CivHydrCompute.h
View file @
618d8082
...
@@ -37,6 +37,8 @@ public:
...
@@ -37,6 +37,8 @@ public:
void
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItem
);
void
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItem
);
void
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItem
);
void
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItem
);
void
clearCache
();
private
:
private
:
void
getNodeResult
(
short
time
);
void
getNodeResult
(
short
time
);
void
getLinkResult
(
short
time
);
void
getLinkResult
(
short
time
);
...
...
pandaAnalysis/CivHydrFuncInter.cpp
View file @
618d8082
...
@@ -32,6 +32,9 @@ bool PANDANALYSIS_API trackingSimulation(char* uri, char* sN, int hours, char* r
...
@@ -32,6 +32,9 @@ bool PANDANALYSIS_API trackingSimulation(char* uri, char* sN, int hours, char* r
std
::
string
uriStr
=
uri
;
std
::
string
uriStr
=
uri
;
std
::
string
sNStr
=
sN
;
std
::
string
sNStr
=
sN
;
// 先清空掉输出空间的
memset
(
result
,
0
,
sizeof
(
result
)
/
sizeof
(
char
));
if
(
uriStr
.
empty
()
||
sNStr
.
empty
())
if
(
uriStr
.
empty
()
||
sNStr
.
empty
())
return
false
;
return
false
;
...
...
pandaAnalysis/CivHydrSimulation.cpp
View file @
618d8082
...
@@ -89,7 +89,7 @@ bool CivHydrSimulation::qualitySimulation()
...
@@ -89,7 +89,7 @@ bool CivHydrSimulation::qualitySimulation()
return
true
;
return
true
;
}
}
bool
CivHydrSimulation
::
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
)
bool
CivHydrSimulation
::
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
)
{
{
CivInpConvertor
convertor
(
mUri
);
CivInpConvertor
convertor
(
mUri
);
...
@@ -101,6 +101,8 @@ bool CivHydrSimulation::trackingSimulation(char* snNode, int hours,std::string&
...
@@ -101,6 +101,8 @@ bool CivHydrSimulation::trackingSimulation(char* snNode, int hours,std::string&
if
(
inpFileS
.
empty
())
if
(
inpFileS
.
empty
())
return
false
;
return
false
;
// 先清除一次已经计算的缓存数据
mHydrCompute
.
clearCache
();
if
(
!
mHydrCompute
.
qualityCompute
())
if
(
!
mHydrCompute
.
qualityCompute
())
{
{
return
false
;
return
false
;
...
...
pandaAnalysis/CivInpConvertor.cpp
View file @
618d8082
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
CivInpConvertor
::
CivInpConvertor
(
const
std
::
string
&
uri
)
CivInpConvertor
::
CivInpConvertor
(
const
std
::
string
&
uri
)
:
mUri
(
uri
)
:
mUri
(
uri
)
{
{
mInpFileName
=
"test.inp"
;
mProjInpFileName
=
"ptest.inp"
;
}
}
CivInpConvertor
::~
CivInpConvertor
()
CivInpConvertor
::~
CivInpConvertor
()
...
@@ -41,7 +42,7 @@ std::string CivInpConvertor::convertPorjInp(const std::string& projCode, const s
...
@@ -41,7 +42,7 @@ std::string CivInpConvertor::convertPorjInp(const std::string& projCode, const s
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"ptest.inp"
;
std
::
string
inpFile
=
mProjInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
@@ -59,7 +60,7 @@ std::string CivInpConvertor::convertBaseInp()
...
@@ -59,7 +60,7 @@ std::string CivInpConvertor::convertBaseInp()
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"test.inp"
;
std
::
string
inpFile
=
mInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
@@ -87,7 +88,7 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn, const std::s
...
@@ -87,7 +88,7 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn, const std::s
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"test.inp"
;
std
::
string
inpFile
=
mInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
@@ -107,7 +108,7 @@ std::string CivInpConvertor::convertAnalysisInp()
...
@@ -107,7 +108,7 @@ std::string CivInpConvertor::convertAnalysisInp()
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"test.inp"
;
std
::
string
inpFile
=
mInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
@@ -130,7 +131,7 @@ std::string CivInpConvertor::convertResidualInp()
...
@@ -130,7 +131,7 @@ std::string CivInpConvertor::convertResidualInp()
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"test.inp"
;
std
::
string
inpFile
=
mInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
@@ -154,7 +155,7 @@ std::string CivInpConvertor::convertNotPorjInp(const std::string& simulTime)
...
@@ -154,7 +155,7 @@ std::string CivInpConvertor::convertNotPorjInp(const std::string& simulTime)
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
director
.
create
();
director
.
create
();
std
::
string
inpFile
=
"test.inp"
;
std
::
string
inpFile
=
mInpFileName
;
if
(
!
builder
->
getNewInp
(
inpFile
))
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
delete
builder
;
...
...
pandaAnalysis/CivInpConvertor.h
View file @
618d8082
...
@@ -47,4 +47,7 @@ public:
...
@@ -47,4 +47,7 @@ public:
private
:
private
:
std
::
string
mUri
;
std
::
string
mUri
;
std
::
string
mInpFileName
;
std
::
string
mProjInpFileName
;
};
};
\ No newline at end of file
pandaAnalysis/CivOptSchedEngine.cpp
View file @
618d8082
...
@@ -18,7 +18,11 @@ CivOptSchedEngine::CivOptSchedEngine(const string& uri)
...
@@ -18,7 +18,11 @@ CivOptSchedEngine::CivOptSchedEngine(const string& uri)
bool
CivOptSchedEngine
::
optimalScheduling
(
int
time
)
bool
CivOptSchedEngine
::
optimalScheduling
(
int
time
)
{
{
// 计算初始化
// 计算初始化
beginCompute
();
if
(
!
beginCompute
())
{
return
false
;
}
// 开始遗传算法
// 开始遗传算法
std
::
shared_ptr
<
OptScheduling
>
optScheduling
(
new
FirstOptScheduling
());
std
::
shared_ptr
<
OptScheduling
>
optScheduling
(
new
FirstOptScheduling
());
...
@@ -29,14 +33,14 @@ bool CivOptSchedEngine::optimalScheduling(int time)
...
@@ -29,14 +33,14 @@ bool CivOptSchedEngine::optimalScheduling(int time)
genAlg
.
setPumpVec
(
mPumpVec
);
genAlg
.
setPumpVec
(
mPumpVec
);
// 种群初始化
// 种群初始化
popsize
=
2
0
;
popsize
=
1
0
;
genAlg
.
init
(
popsize
,
mMutRate
,
mCrossRate
,
mGenLength
,
0
,
1
);
genAlg
.
init
(
popsize
,
mMutRate
,
mCrossRate
,
mGenLength
,
0
,
1
);
// 开始迭代计算
// 开始迭代计算
int
index
=
0
;
int
index
=
0
;
// 迭代次数
// 迭代次数
int
generation
=
10
0
;
int
generation
=
2
0
;
mSchedulingCompute
->
clearLastVals
();
mSchedulingCompute
->
clearLastVals
();
while
(
index
++
<
generation
)
while
(
index
++
<
generation
)
...
@@ -79,7 +83,7 @@ bool CivOptSchedEngine::optimalScheduling(int time)
...
@@ -79,7 +83,7 @@ bool CivOptSchedEngine::optimalScheduling(int time)
// 计算个体自适度
// 计算个体自适度
double
fitness
=
genAlg
.
fitnessfunction
(
cost
,
monitorCalcMapValues
);
double
fitness
=
genAlg
.
fitnessfunction
(
cost
,
monitorCalcMapValues
);
if
(
fitness
>
1
)
if
(
fitness
>
=
1
)
fitness
=
0
;
fitness
=
0
;
logStr
.
append
(
" 适应度值:"
+
to_string
(
fitness
));
logStr
.
append
(
" 适应度值:"
+
to_string
(
fitness
));
...
@@ -113,9 +117,10 @@ bool CivOptSchedEngine::optimalScheduling(int time)
...
@@ -113,9 +117,10 @@ bool CivOptSchedEngine::optimalScheduling(int time)
string
infoStr
=
"最优水泵组合值:"
;
string
infoStr
=
"最优水泵组合值:"
;
for
(
int
i
=
0
;
i
<
totalGenVec
;
i
++
)
for
(
int
i
=
0
;
i
<
totalGenVec
;
i
++
)
{
{
infoStr
.
append
(
mPumpVec
[
i
]
+
":
"
+
to_string
(
genVec
[
i
])
);
infoStr
.
append
(
mPumpVec
[
i
]
+
":
"
+
to_string
(
genVec
[
i
])
+
" "
);
mPumpBestSpeed
.
insert
(
pair
<
string
,
double
>
(
mPumpVec
[
i
],
genVec
[
i
]));
mPumpBestSpeed
.
insert
(
pair
<
string
,
double
>
(
mPumpVec
[
i
],
genVec
[
i
]));
}
}
infoStr
.
append
(
" 最佳适应度:"
+
to_string
(
genome
.
fitness
));
CivSysLog
::
getInstance
()
->
error
(
infoStr
,
"CivOptSchedEngine"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
error
(
infoStr
,
"CivOptSchedEngine"
,
__FUNCTION__
);
mSchedulingCompute
->
clearLastVals
();
mSchedulingCompute
->
clearLastVals
();
...
@@ -195,6 +200,12 @@ bool CivOptSchedEngine::beginCompute()
...
@@ -195,6 +200,12 @@ bool CivOptSchedEngine::beginCompute()
// 获取水泵个数,根据水泵个数确定基因编码长度
// 获取水泵个数,根据水泵个数确定基因编码长度
CivPumpHelper
pumpHelper
(
mUri
);
CivPumpHelper
pumpHelper
(
mUri
);
mGenLength
=
pumpHelper
.
getPumpNumbers
();
mGenLength
=
pumpHelper
.
getPumpNumbers
();
if
(
mGenLength
<=
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"CivOptSchedEngine"
,
"获取不到水泵"
,
__FUNCTION__
);
return
false
;
}
// 获取本点号和code的映射
// 获取本点号和code的映射
map
<
string
,
string
>
snToCodeMap
;
map
<
string
,
string
>
snToCodeMap
;
...
@@ -214,8 +225,12 @@ bool CivOptSchedEngine::beginCompute()
...
@@ -214,8 +225,12 @@ bool CivOptSchedEngine::beginCompute()
// 构造水力计算对象
// 构造水力计算对象
mSchedulingCompute
->
setMonitors
(
mMonitorsVec
);
mSchedulingCompute
->
setMonitors
(
mMonitorsVec
);
mSchedulingCompute
->
openFile
(
inpFile
);
if
(
!
mSchedulingCompute
->
openFile
(
inpFile
))
{
CivSysLog
::
getInstance
()
->
info
(
inpFile
,
"CivOptSchedEngine"
,
__FUNCTION__
);
return
false
;
}
// 原始管网计算一次水力,保留调度前的水力计算结果
// 原始管网计算一次水力,保留调度前的水力计算结果
if
(
!
mSchedulingCompute
->
calculate
())
if
(
!
mSchedulingCompute
->
calculate
())
return
false
;
return
false
;
...
...
pandaAnalysis/CivSchedulingCompute.cpp
View file @
618d8082
...
@@ -7,14 +7,15 @@
...
@@ -7,14 +7,15 @@
CivSchedulingCompute
::
CivSchedulingCompute
(
SchdulingType
schedulingType
)
CivSchedulingCompute
::
CivSchedulingCompute
(
SchdulingType
schedulingType
)
:
mChdulingType
(
schedulingType
)
:
mChdulingType
(
schedulingType
)
{
{
mRptFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.rpt"
;
mRptFile
=
"test.rpt"
;
mBinFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.bin"
;
mBinFile
=
"test.bin"
;
mInpFile
=
"test.inp"
;
}
}
bool
CivSchedulingCompute
::
openFile
(
const
string
&
inpFILE
)
bool
CivSchedulingCompute
::
openFile
(
const
string
&
inpFILE
)
{
{
char
inpFile
[
256
];
char
inpFile
[
256
];
strcpy_s
(
inpFile
,
inpFILE
.
c_str
());
strcpy_s
(
inpFile
,
mInpFile
.
c_str
());
char
rptFile
[
128
];
char
rptFile
[
128
];
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
...
...
pandaAnalysis/CivSchedulingCompute.h
View file @
618d8082
...
@@ -64,6 +64,7 @@ private:
...
@@ -64,6 +64,7 @@ private:
private
:
private
:
std
::
string
mRptFile
;
std
::
string
mRptFile
;
std
::
string
mBinFile
;
std
::
string
mBinFile
;
std
::
string
mInpFile
;
// 水泵编号和code的映射
// 水泵编号和code的映射
vector
<
string
>
mMonitors
;
vector
<
string
>
mMonitors
;
...
...
pandaAnalysis/CivSimulResultCache.cpp
View file @
618d8082
...
@@ -14,6 +14,15 @@ void CivSimulResultCache::addNodeQuality(float quality, int interval, const std:
...
@@ -14,6 +14,15 @@ void CivSimulResultCache::addNodeQuality(float quality, int interval, const std:
mNodeItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
mNodeItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
}
}
CivSimulResultCache
::~
CivSimulResultCache
()
{
mNodeItemsMap
.
clear
();
mLinkItemsMap
.
clear
();
mTankItemsMap
.
clear
();
mNodeCodeSnMap
.
clear
();
mLineCodeSnMap
.
clear
();
}
void
CivSimulResultCache
::
addLinkQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
)
void
CivSimulResultCache
::
addLinkQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
)
{
{
if
(
mLinkItemsMap
.
find
(
interval
)
==
mLinkItemsMap
.
end
())
if
(
mLinkItemsMap
.
find
(
interval
)
==
mLinkItemsMap
.
end
())
...
@@ -115,6 +124,9 @@ void CivSimulResultCache::getPipeItemByInterval(int time, LinkResultItems& linkI
...
@@ -115,6 +124,9 @@ void CivSimulResultCache::getPipeItemByInterval(int time, LinkResultItems& linkI
void
CivSimulResultCache
::
getCodeToSnMap
(
const
std
::
string
&
uri
)
void
CivSimulResultCache
::
getCodeToSnMap
(
const
std
::
string
&
uri
)
{
{
if
(
mNodeCodeSnMap
.
size
()
>
0
||
mLineCodeSnMap
.
size
()
>
0
)
return
;
CivSimulResDbHelper
helper
(
uri
);
CivSimulResDbHelper
helper
(
uri
);
helper
.
getNodeCodeSnMap
(
mNodeCodeSnMap
);
helper
.
getNodeCodeSnMap
(
mNodeCodeSnMap
);
helper
.
getLinCodeSnMap
(
mLineCodeSnMap
);
helper
.
getLinCodeSnMap
(
mLineCodeSnMap
);
...
...
pandaAnalysis/CivSimulResultCache.h
View file @
618d8082
...
@@ -13,6 +13,7 @@ using namespace std;
...
@@ -13,6 +13,7 @@ using namespace std;
class
CivSimulResultCache
class
CivSimulResultCache
{
{
public
:
public
:
~
CivSimulResultCache
();
/**
/**
*@brief 缓存节点水质
*@brief 缓存节点水质
*@param quality:存储的值
*@param quality:存储的值
...
...
pandaDbManager/CivInpDbHelper.cpp
View file @
618d8082
...
@@ -340,7 +340,10 @@ void CivInpDbHelper::handleValve()
...
@@ -340,7 +340,10 @@ void CivInpDbHelper::handleValve()
CivPipe
::
Table
pipeStruct
;
CivPipe
::
Table
pipeStruct
;
pipeStruct
.
ID
=
pipe
.
find
(
"编号"
)
->
second
;
pipeStruct
.
ID
=
pipe
.
find
(
"编号"
)
->
second
;
pipeStruct
.
code
=
pipe
.
find
(
"code"
)
->
second
;
if
(
pipe
.
find
(
"code"
)
!=
pipe
.
end
())
pipeStruct
.
code
=
pipe
.
find
(
"code"
)
->
second
;
pipeStruct
.
Node1
=
pipe
.
find
(
"起始节点"
)
->
second
;
pipeStruct
.
Node1
=
pipe
.
find
(
"起始节点"
)
->
second
;
pipeStruct
.
Node2
=
pipe
.
find
(
"终止节点"
)
->
second
;
pipeStruct
.
Node2
=
pipe
.
find
(
"终止节点"
)
->
second
;
pipeStruct
.
Length
=
pipe
.
find
(
"管长"
)
->
second
;
pipeStruct
.
Length
=
pipe
.
find
(
"管长"
)
->
second
;
...
@@ -368,15 +371,34 @@ void CivInpDbHelper::handleValve()
...
@@ -368,15 +371,34 @@ void CivInpDbHelper::handleValve()
std
::
map
<
std
::
string
,
std
::
string
>
pipe
=
downPipes
[
i
];
std
::
map
<
std
::
string
,
std
::
string
>
pipe
=
downPipes
[
i
];
CivPipe
::
Table
pipeStruct
;
CivPipe
::
Table
pipeStruct
;
pipeStruct
.
ID
=
pipe
.
find
(
"编号"
)
->
second
;
pipeStruct
.
code
=
pipe
.
find
(
"code"
)
->
second
;
auto
iterEnd
=
pipe
.
end
();
pipeStruct
.
Node1
=
pipe
.
find
(
"起始节点"
)
->
second
;
pipeStruct
.
Node2
=
pipe
.
find
(
"终止节点"
)
->
second
;
if
(
pipe
.
find
(
"编号"
)
!=
iterEnd
)
pipeStruct
.
Length
=
pipe
.
find
(
"管长"
)
->
second
;
pipeStruct
.
ID
=
pipe
.
find
(
"编号"
)
->
second
;
pipeStruct
.
Diameter
=
pipe
.
find
(
"管径"
)
->
second
;
pipeStruct
.
Roughness
=
pipe
.
find
(
"摩阻系数"
)
->
second
;
if
(
pipe
.
find
(
"code"
)
!=
iterEnd
)
pipeStruct
.
code
=
pipe
.
find
(
"code"
)
->
second
;
if
(
pipe
.
find
(
"起始节点"
)
!=
iterEnd
)
pipeStruct
.
Node1
=
pipe
.
find
(
"起始节点"
)
->
second
;
if
(
pipe
.
find
(
"终止节点"
)
!=
iterEnd
)
pipeStruct
.
Node2
=
pipe
.
find
(
"终止节点"
)
->
second
;
if
(
pipe
.
find
(
"管长"
)
!=
iterEnd
)
pipeStruct
.
Length
=
pipe
.
find
(
"管长"
)
->
second
;
if
(
pipe
.
find
(
"管径"
)
!=
iterEnd
)
pipeStruct
.
Diameter
=
pipe
.
find
(
"管径"
)
->
second
;
if
(
pipe
.
find
(
"摩阻系数"
)
!=
iterEnd
)
pipeStruct
.
Roughness
=
pipe
.
find
(
"摩阻系数"
)
->
second
;
pipeStruct
.
Status
=
"Open"
;
pipeStruct
.
Status
=
"Open"
;
pipeStruct
.
MinorLoss
=
pipe
.
find
(
"局损系数"
)
->
second
;
if
(
pipe
.
find
(
"局损系数"
)
!=
iterEnd
)
pipeStruct
.
MinorLoss
=
pipe
.
find
(
"局损系数"
)
->
second
;
mPipesVec
.
push_back
(
pipeStruct
);
mPipesVec
.
push_back
(
pipeStruct
);
}
}
...
...
pandaLog/CivCommonUtils.h
View file @
618d8082
...
@@ -4,6 +4,16 @@
...
@@ -4,6 +4,16 @@
#include<vector>
#include<vector>
#include "pandaLog.h"
#include "pandaLog.h"
#ifdef _WIN32
#define SEP "\\\\"
#else
#define SEP "/"
#endif // _WIN32
// 字符串转编码
// 字符串转编码
#define TransUTFCoding(name) CivCommonUtils::string_To_UTF8(name)
#define TransUTFCoding(name) CivCommonUtils::string_To_UTF8(name)
#define UTFTransCoding(name) CivCommonUtils::UTF8_To_string(name)
#define UTFTransCoding(name) CivCommonUtils::UTF8_To_string(name)
...
...
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