Commit fcd5a414 authored by 刘乐's avatar 刘乐

1, 修改保存

parent 4805137f
......@@ -105,17 +105,6 @@ void GenAlg::select()
}
int GenAlg::nextRandom(int total, vector<int> visited)
{
int index = random(0, total);
std::vector<int>::iterator iter = std::find(visited.begin(), visited.end(), index);
if (iter != visited.end())
return nextRandom(total, visited);
visited.push_back(index);
return index;
}
void GenAlg::corssver()
{
// 染色体个数
......@@ -150,8 +139,7 @@ void GenAlg::crossover(vector<char>& chromo1, vector<char>& chromo2)
return;
int total = chromo1.size();
// 基因交叉重组
for (int i = 0; i < total; i++)
{
......@@ -270,12 +258,12 @@ void GenAlg::fitnessfunction()
}
void GenAlg::encoding()
void GenAlg::encoding(map<string, int>& phenotype, vector<char>& chromo)
{
}
void GenAlg::decoding()
void GenAlg::decoding(vector<char>& chromo, map<string, int>& phenotype)
{
}
\ No newline at end of file
......@@ -65,17 +65,22 @@ public:
// 计算个体自适应度
void fitnessfunction();
// 编码,
void encoding();
/**
* @brief 编码, 将水泵开关状态编码成二进制状态:0表示管,1表示开
* @param
*/
void encoding(map<string, int>& phenotype, vector<char>& chromo);
/**
* @brief 解码, 将二进制状态吗解码成水泵对应的状态
* @param
*/
void decoding(vector<char>& chromo,map<string,int>& phenotype);
// 解码
void decoding();
private:
// 产生[a,b)之间的浮点数
double random(int a=0, int b= RAND_MAX);
int nextRandom(int total, vector<int> visited);
// 两个染色体交叉运算
void crossover(vector<char>& chromo1, vector<char>& chromo2);
......
......@@ -3,6 +3,8 @@
#include <vector>
#include <map>
using namespace std;
class PANDAALGORITHM_API OptScheduling
{
public:
......@@ -59,4 +61,9 @@ public:
* @return
*/
virtual double waterSupplyAndDemand(const std::vector<double>& Q, const double& Qd );
protected:
};
\ No newline at end of file
......@@ -56,7 +56,7 @@ template <class VertexType, class EdgeType>
class ALGraph
{
public:
explicit ALGraph();
ALGraph();
~ALGraph();
void getVisitedResult(IN const VertexType& vetexType,OUT std::vector<VertexType>& vertex,OUT std::vector<EdgeType>& edges);
......
......@@ -11,7 +11,7 @@ class CivGraphJunction
public:
CivGraphJunction();
CivGraphJunction(std::string sN);
explicit CivGraphJunction(std::string sN);
CivGraphJunction(std::string sN, std::string xCoord, std::string yCoord);
bool operator== (const CivGraphJunction& j1);
......@@ -53,6 +53,7 @@ public:
CivGraphEdage(std::string sn, std::string length, std::vector<std::string> position);
friend bool operator==(const CivGraphEdage& left, const CivGraphEdage& right);
bool operator== (const CivGraphEdage& edage);
bool operator> (const CivGraphEdage& edage);
bool operator< (const CivGraphEdage& edage);
......@@ -71,10 +72,10 @@ public:
void setStartY(const std::string& startY) { mStartY = startY; }
void setEndX(const std::string& endX) { mEndX = endX; }
void setEndY(const std::string& endY) { mEndY = endY; }
private:
std::string mSN;// 编号
std::string mLength; // 管长
std::string mStartX;
std::string mStartY;
std::string mEndX;
......
#include "CivHydrScheduling.h"
CivHydrScheduling::CivHydrScheduling(SchedulingType schedulingType)
:mSchedulingType(schedulingType)
{
}
bool CivHydrScheduling::open()
{
}
bool CivHydrScheduling::close()
{
}
void CivHydrScheduling::updatePumpStatus(const map<string, int>& statusMap)
{
}
bool CivHydrScheduling::compute()
{
}
void CivHydrScheduling::setPressMonitors(vector<string>& monitors)
{
mPressMonitorMap = monitors;
}
void CivHydrScheduling::setFlowMonitor(vector<string>& monitors)
{
mFlowMonitorMap = monitors;
}
void CivHydrScheduling::monitorsValue(SchedulingType schedulingType, vector<map<string, double>>& simulMap)
{
switch (schedulingType)
{
case CivHydrScheduling::SchedulingFlow:
simulMap = mMonitorPressSmulVal;
break;
case CivHydrScheduling::SchedulingPressure:
simulMap = mMonitorFlowSmulVal;
break;
case CivHydrScheduling::SchedulingALL:
default:
break;
}
}
\ No newline at end of file
#pragma once
#include <map>
#include <string>
#include <vector>
using namespace std;
/**
优化调度水力计算
*/
class CivHydrScheduling
{
public:
// 调度类型:压力,为
enum SchedulingType
{
SchedulingFlow,
SchedulingPressure,
SchedulingALL
};
CivHydrScheduling(SchedulingType schedulingType);
/**
* 加载,打开 inp 文件
*/
bool open();
/**
*结束运算,关闭文件句柄
*/
bool close();
/**
* 动态更新水泵参数
*/
void updatePumpStatus(const map<string, int>& statusMap);
/**
* 执行一次水力计算
*/
bool compute();
/**
* 设置压力监测点
*/
void setPressMonitors(vector<string>& monitors);
/**
* 设置流量监测点
*/
void setFlowMonitor(vector<string>& monitors);
/**
* 获取监测点的模拟值
*/
void monitorsValue(SchedulingType schedulingType, vector<map<string, double>>& simulMap);
private:
// 调度类型: 压力,流量
SchedulingType mSchedulingType;
// 压力监测点
vector<string> mPressMonitorMap;
// 流量监测点
vector<string> mFlowMonitorMap;
// 压力监测监测点的模拟值
vector<map<string, double>> mMonitorPressSmulVal;
// 流量监测点模拟值
vector<map<string, double>> mMonitorFlowSmulVal;
};
......@@ -116,8 +116,10 @@ bool CivTrackingAnalysis::createGraphFrom()
return true;
}
bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& junctions,
const std::vector<CivGraphEdage>& pipes, std::string& jsonResult)
bool CivTrackingAnalysis::transformJson(
const std::vector<CivGraphJunction>& junctions,
const std::vector<CivGraphEdage>& pipes,
std::string& jsonResult)
{
// 管段
size_t pipesTotal = pipes.size();
......@@ -197,7 +199,8 @@ bool CivTrackingAnalysis::waterSupplyScopeAnalysis(const std::string& sN, std::s
return true;
}
bool CivTrackingAnalysis::upstreamTracking(const std::string& sN,
bool CivTrackingAnalysis::upstreamTracking(
const std::string& sN,
std::vector<CivGraphJunction>& junctions,
std::vector<CivGraphEdage>& pipes)
{
......@@ -212,7 +215,8 @@ bool CivTrackingAnalysis::upstreamTracking(const std::string& sN,
return true;
}
bool CivTrackingAnalysis::downstreamTracking(const std::string& sN,
bool CivTrackingAnalysis::downstreamTracking(
const std::string& sN,
std::vector<CivGraphJunction>& junctions,
std::vector<CivGraphEdage>& pipes)
{
......@@ -223,7 +227,8 @@ bool CivTrackingAnalysis::downstreamTracking(const std::string& sN,
return true;
}
bool CivTrackingAnalysis::waterSupplyScopeAnalysis(const std::string& sN,
bool CivTrackingAnalysis::waterSupplyScopeAnalysis(
const std::string& sN,
std::vector<CivGraphJunction>& junctions,
std::vector<CivGraphEdage>& pipes)
{
......
......@@ -39,9 +39,9 @@ public:
*@param uri 数据库连接地址
*/
bool createGraphFrom();
private:
/**
*@brief 节点和管段集合信息转换成json字符串
*@param junctions 节点信息集合
......
......@@ -22,6 +22,7 @@ public:
virtual void handlePump() = 0;
virtual void handleValve() = 0;
// 组件需要重载
virtual bool getNode(CivNode& node)=0 ;
virtual bool getPipe(CivPipe& pipe)=0 ;
......
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