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

一些小改动

parent 7ba722aa
......@@ -21,7 +21,7 @@ int main(int argc, char* argv[])
{
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);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
......
......@@ -141,6 +141,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
<PostBuildEvent>
<Command>copy pandaAlgorithm.h $(OutDir)..\include /y
......
......@@ -20,7 +20,7 @@ CivBaseInpBuilder::~CivBaseInpBuilder()
void CivBaseInpBuilder::preHandleLikelyPipe()
{
mHelper->handleValve();
mHelper->handlePump();
// mHelper->handlePump();
}
void CivBaseInpBuilder::buildNode()
......
......@@ -5,6 +5,8 @@
#include "CivPumpHelper.h"
#include "CivSchedulingCompute.h"
#include "Genome.h"
#include "CivReportReader.h"
#include "CivCommonUtils.h"
......@@ -67,8 +69,29 @@ bool CivOptSchedEngine::optimalScheduling()
vector<map<string, int>>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()
// 结束计算
schedulingCompute.close();
return true;
}
......
......@@ -57,16 +57,12 @@ private:
// 初始中群大小
int popsize;
// 变异率
double mMutRate;
// 交叉率
double mCrossRate;
//基因编码长度
int mGenLength;
// 针对浮点数编码
double mLeftPoint;
double mRightPoint;
......
#include "CivReportReader.h"
#include "StringUtils.h"
#include "CivReport.h"
#include<fstream>
#include<iostream>
......@@ -7,20 +10,27 @@ 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());
// жȡ
string sLine;
int lineNumber = 0;
while (getline(reader, sLine))
{
StringUtils::trim(sLine);
if (sLine.find(EnergyHead))
{
}
lineNumber++;
}
reader.close();
......
......@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <map>
#include "CivReport.h"
using namespace std;
......@@ -15,9 +16,11 @@ class CivReportReader
public:
CivReportReader();
bool open(const string& reportFile);
// 加载读取水力计算报告文件
void open(const string& reportFile);
void readEnergy(const string& pumpSn, string& enery);
// 读取水泵消耗的能量值
float readEnergy(const string& pumpSn);
private:
vector<EnergyStruct> mEnergys; // 能耗读取
......
......@@ -10,7 +10,7 @@ CivSchedulingCompute::CivSchedulingCompute()
mBinFile = CivCommonUtils::getExePath() + "\\test.bin";
}
bool CivSchedulingCompute::openFile(string& inpFILE)
bool CivSchedulingCompute::openFile(const string& inpFILE)
{
char inpFile[256];
strcpy_s(inpFile, inpFILE.c_str());
......
#pragma once
#include <map>
#include<vector>
#include <string>
using namespace std;
......@@ -15,7 +16,7 @@ public:
void setMonitors(const vector<string>& monitor);
// 读入inp文件
bool openFile(string& inpFILE);
bool openFile(const string& inpFILE);
// 水力计算
bool calculate();
......
......@@ -145,7 +145,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<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>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
......
......@@ -3,6 +3,8 @@
#include "CivPgDbConnection.h"
#include "CivTableFields.h"
#include "StringUtils.h"
#include <vector>
#include<string>
CivInpHelperAbs::CivInpHelperAbs(const std::string& uri)
{
......@@ -125,9 +127,17 @@ bool CivInpHelperAbs::getCurves(CivCurves& curves)
CivCurves::CurvesTable cTable;
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.XCoord = map.find(fields[1])->second;
cTable.YCoord = map.find(fields[2])->second;
cTable.XCoord = res[0];
cTable.YCoord = res[1];
curves.addItem(cTable);
}
......
......@@ -21,11 +21,9 @@ void StringUtils::split(std::string sourceStr, std::vector<std::string>& res, co
void StringUtils::trim(std::string & s)
{
if (!s.empty())
{
s.erase(0, s.find_first_not_of(" "));
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