Commit 0b99f27c authored by 刘乐's avatar 刘乐

一些小改动

parent 7ba722aa
...@@ -21,7 +21,7 @@ int main(int argc, char* argv[]) ...@@ -21,7 +21,7 @@ int main(int argc, char* argv[])
{ {
while (true) while (true)
{ {
const char* uri = "host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin"; const char* uri = "host=192.168.19.100 port=5432 dbname=JinXian3 user=postgres password=admin";
char* findUri = const_cast<char*>(uri); char* findUri = const_cast<char*>(uri);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
......
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>copy pandaAlgorithm.h $(OutDir)..\include /y <Command>copy pandaAlgorithm.h $(OutDir)..\include /y
......
...@@ -20,7 +20,7 @@ CivBaseInpBuilder::~CivBaseInpBuilder() ...@@ -20,7 +20,7 @@ CivBaseInpBuilder::~CivBaseInpBuilder()
void CivBaseInpBuilder::preHandleLikelyPipe() void CivBaseInpBuilder::preHandleLikelyPipe()
{ {
mHelper->handleValve(); mHelper->handleValve();
mHelper->handlePump(); // mHelper->handlePump();
} }
void CivBaseInpBuilder::buildNode() void CivBaseInpBuilder::buildNode()
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "CivPumpHelper.h" #include "CivPumpHelper.h"
#include "CivSchedulingCompute.h" #include "CivSchedulingCompute.h"
#include "Genome.h" #include "Genome.h"
#include "CivReportReader.h"
#include "CivCommonUtils.h"
...@@ -67,8 +69,29 @@ bool CivOptSchedEngine::optimalScheduling() ...@@ -67,8 +69,29 @@ bool CivOptSchedEngine::optimalScheduling()
vector<map<string, int>>monitorsMap; vector<map<string, int>>monitorsMap;
genAlg.decoding(monitorsMap); genAlg.decoding(monitorsMap);
size_t mSize = monitorsMap.size();
for (int i = 0; i < mSize; i++)
{
schedulingCompute.updatePumpStatus(monitorsMap[i]);
if (!schedulingCompute.calculate())
continue;
// 获取计算的监测点的值
vector<map<string, double>> monitorCalcMapValues;
schedulingCompute.getMonitorsValue(monitorCalcMapValues);
CivReportReader reportReader;
float cost = 0;
string rptPath = CivCommonUtils::getExePath() + "//test.rpt";
reportReader.open(rptPath);
// cost = reportReader.readEnergy();
//
// 计算个体自适度 // 计算个体自适度
// genAlg.fitnessfunction();
}
// 根据个体自适应度进行选择 // 根据个体自适应度进行选择
// 自适应交叉变异 // 自适应交叉变异
...@@ -92,6 +115,7 @@ bool CivOptSchedEngine::optimalScheduling() ...@@ -92,6 +115,7 @@ bool CivOptSchedEngine::optimalScheduling()
// 结束计算 // 结束计算
schedulingCompute.close(); schedulingCompute.close();
return true; return true;
} }
......
...@@ -57,16 +57,12 @@ private: ...@@ -57,16 +57,12 @@ private:
// 初始中群大小 // 初始中群大小
int popsize; int popsize;
// 变异率 // 变异率
double mMutRate; double mMutRate;
// 交叉率 // 交叉率
double mCrossRate; double mCrossRate;
//基因编码长度 //基因编码长度
int mGenLength; int mGenLength;
// 针对浮点数编码 // 针对浮点数编码
double mLeftPoint; double mLeftPoint;
double mRightPoint; double mRightPoint;
......
#include "CivReportReader.h" #include "CivReportReader.h"
#include "StringUtils.h"
#include "CivReport.h"
#include<fstream> #include<fstream>
#include<iostream> #include<iostream>
...@@ -7,21 +10,28 @@ CivReportReader::CivReportReader() ...@@ -7,21 +10,28 @@ CivReportReader::CivReportReader()
} }
void CivReportReader::readEnergy(const string& pumpSn, string& enery) float CivReportReader::readEnergy(const string& pumpSn)
{ {
float res = 0;
return res;
} }
bool CivReportReader::open(const string& reportFile) void CivReportReader::open(const string& reportFile)
{ {
ifstream reader(reportFile.c_str()); ifstream reader(reportFile.c_str());
// жȡ // жȡ
string sLine; string sLine;
int lineNumber = 0;
while (getline(reader, sLine)) while (getline(reader, sLine))
{
StringUtils::trim(sLine);
if (sLine.find(EnergyHead))
{ {
} }
lineNumber++;
}
reader.close(); reader.close();
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
#include "CivReport.h" #include "CivReport.h"
using namespace std; using namespace std;
...@@ -15,9 +16,11 @@ class CivReportReader ...@@ -15,9 +16,11 @@ class CivReportReader
public: public:
CivReportReader(); CivReportReader();
bool open(const string& reportFile); // 加载读取水力计算报告文件
void open(const string& reportFile);
void readEnergy(const string& pumpSn, string& enery); // 读取水泵消耗的能量值
float readEnergy(const string& pumpSn);
private: private:
vector<EnergyStruct> mEnergys; // 能耗读取 vector<EnergyStruct> mEnergys; // 能耗读取
......
...@@ -10,7 +10,7 @@ CivSchedulingCompute::CivSchedulingCompute() ...@@ -10,7 +10,7 @@ CivSchedulingCompute::CivSchedulingCompute()
mBinFile = CivCommonUtils::getExePath() + "\\test.bin"; mBinFile = CivCommonUtils::getExePath() + "\\test.bin";
} }
bool CivSchedulingCompute::openFile(string& inpFILE) bool CivSchedulingCompute::openFile(const string& inpFILE)
{ {
char inpFile[256]; char inpFile[256];
strcpy_s(inpFile, inpFILE.c_str()); strcpy_s(inpFile, inpFILE.c_str());
......
#pragma once #pragma once
#include <map> #include <map>
#include<vector>
#include <string> #include <string>
using namespace std; using namespace std;
...@@ -15,7 +16,7 @@ public: ...@@ -15,7 +16,7 @@ public:
void setMonitors(const vector<string>& monitor); void setMonitors(const vector<string>& monitor);
// 读入inp文件 // 读入inp文件
bool openFile(string& inpFILE); bool openFile(const string& inpFILE);
// 水力计算 // 水力计算
bool calculate(); bool calculate();
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpq.lib;pandaDbManager.lib;EPNAET2.lib;pandaLog.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libpq.lib;pandaDbManager.lib;EPNAET2.lib;pandaLog.lib;pandaAlgorithm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OUTDIR)..\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary> <ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link> </Link>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include "CivPgDbConnection.h" #include "CivPgDbConnection.h"
#include "CivTableFields.h" #include "CivTableFields.h"
#include "StringUtils.h" #include "StringUtils.h"
#include <vector>
#include<string>
CivInpHelperAbs::CivInpHelperAbs(const std::string& uri) CivInpHelperAbs::CivInpHelperAbs(const std::string& uri)
{ {
...@@ -125,9 +127,17 @@ bool CivInpHelperAbs::getCurves(CivCurves& curves) ...@@ -125,9 +127,17 @@ bool CivInpHelperAbs::getCurves(CivCurves& curves)
CivCurves::CurvesTable cTable; CivCurves::CurvesTable cTable;
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
std::string tempStr = map.find(fields[2])->second;
std::vector<std::string> res;
StringUtils::trim(tempStr);
StringUtils::split(tempStr, res, ",");
if (res.size() <= 1)
continue;
cTable.ID = map.find(fields[0])->second; cTable.ID = map.find(fields[0])->second;
cTable.XCoord = map.find(fields[1])->second; cTable.XCoord = res[0];
cTable.YCoord = map.find(fields[2])->second; cTable.YCoord = res[1];
curves.addItem(cTable); curves.addItem(cTable);
} }
......
...@@ -21,11 +21,9 @@ void StringUtils::split(std::string sourceStr, std::vector<std::string>& res, co ...@@ -21,11 +21,9 @@ void StringUtils::split(std::string sourceStr, std::vector<std::string>& res, co
void StringUtils::trim(std::string & s) void StringUtils::trim(std::string & s)
{ {
if (!s.empty()) if (!s.empty())
{ {
s.erase(0, s.find_first_not_of(" ")); s.erase(0, s.find_first_not_of(" "));
s.erase(s.find_last_not_of(" ") + 1); s.erase(s.find_last_not_of(" ") + 1);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment