Commit 50cbba70 authored by 刘乐's avatar 刘乐

1, 优化调度接口bug修改

parent bb927ba0
...@@ -11,8 +11,10 @@ CivHydrTest::~CivHydrTest() ...@@ -11,8 +11,10 @@ CivHydrTest::~CivHydrTest()
// 优化调度测试 // 优化调度测试
void CivOptSchedulingTest::test(char* uri) void CivOptSchedulingTest::test(char* uri)
{ {
std::string condtionMap = "{\"JD0000159\":{\"min\":20,\"max\":48},\"JD0000324\":{\"min\":20,\"max\":48},\"JD0000416\":{\"min\":20,\"max\":48},\"JD0000422\":{\"min\":20,\"max\":48},\"JD0000457\":{\"min\":20,\"max\":48},\"JD0000532\":{\"min\":20,\"max\":48},\"JD0000538\":{\"min\":20,\"max\":48},\"JD0000582\":{\"min\":20,\"max\":48},\"JD0000648\":{\"min\":20,\"max\":48},\"JD0000652\":{\"min\":20,\"max\":48},\"JD0000665\":{\"min\":20,\"max\":48},\"JD0000703\":{\"min\":20,\"max\":48},\"JD0000724\":{\"min\":20,\"max\":48}}"; std::string condtionMap = "{\"bcdd358e-1925-47be-8e20-d93999e33c1c\":{\"min\":30, \"max\" : 40}, \
int time = 9; \"fd605205-c10e-4f7e-81a4-89c88166e763\" : {\"min\":50, \"max\" : 60}, \"c446cc2c-4110-406a-bda1-4f9544e38cb4\" : {\"min\":70, \"max\" : 80}}";
// std::string condtionMap = "{\"JD0000159\":{\"min\":20,\"max\":48},\"JD0000324\":{\"min\":20,\"max\":48},\"JD0000416\":{\"min\":20,\"max\":48},\"JD0000422\":{\"min\":20,\"max\":48},\"JD0000457\":{\"min\":20,\"max\":48},\"JD0000532\":{\"min\":20,\"max\":48},\"JD0000538\":{\"min\":20,\"max\":48},\"JD0000582\":{\"min\":20,\"max\":48},\"JD0000648\":{\"min\":20,\"max\":48},\"JD0000652\":{\"min\":20,\"max\":48},\"JD0000665\":{\"min\":20,\"max\":48},\"JD0000703\":{\"min\":20,\"max\":48},\"JD0000724\":{\"min\":20,\"max\":48}}";
int time = 17;
char* condition = const_cast<char*>(condtionMap.c_str()); char* condition = const_cast<char*>(condtionMap.c_str());
......
...@@ -209,7 +209,8 @@ double GenAlg::fitnessfunction(float cost, map<string, double>& monitorValues) ...@@ -209,7 +209,8 @@ double GenAlg::fitnessfunction(float cost, map<string, double>& monitorValues)
{ {
// 计算适应 // 计算适应
double objVal = mOptScheduling->objectiveFunction(cost, monitorValues); double objVal = mOptScheduling->objectiveFunction(cost, monitorValues);
return objVal;
return objVal > 0?objVal:0.0;
} }
void GenAlg::decoding(vector<map<string, float>>& genVals) void GenAlg::decoding(vector<map<string, float>>& genVals)
...@@ -235,7 +236,7 @@ void GenAlg::updateGenomeFitNess(int index, double fitNess) ...@@ -235,7 +236,7 @@ void GenAlg::updateGenomeFitNess(int index, double fitNess)
if (index < 0 || index >= vecPop.size()) if (index < 0 || index >= vecPop.size())
return; return;
vecPop[index].fitness = fitNess; vecPop[index].fitness = fitNess>0?fitNess:0.0;
} }
void GenAlg::crossover(const vector<Genome>& parent, vector<Genome>& son) void GenAlg::crossover(const vector<Genome>& parent, vector<Genome>& son)
......
...@@ -216,13 +216,14 @@ void CivOptSchedEngine::schedulingResultToJson(string& json) ...@@ -216,13 +216,14 @@ void CivOptSchedEngine::schedulingResultToJson(string& json)
if (monitorIter != mMonitorsSnMap.end()) if (monitorIter != mMonitorsSnMap.end())
{ {
monitorName = monitorIter->second; monitorName = monitorIter->second;
json.append("\"" + monitorName + "\":[");
json.append(to_string(beforeMonitorVal));
json.append(",");
json.append(to_string(afterMonitorvVal));
json.append("],");
} }
json.append("\""+monitorName+"\":[");
json.append(to_string(beforeMonitorVal));
json.append(",");
json.append(to_string(afterMonitorvVal));
json.append("],");
} }
json = json.substr(0, json.length() - 1); json = json.substr(0, json.length() - 1);
json.append("}"); json.append("}");
......
...@@ -134,7 +134,19 @@ void CivPumpHelper::getMonitors(vector<string>& monitors,map<string,string>& mon ...@@ -134,7 +134,19 @@ void CivPumpHelper::getMonitors(vector<string>& monitors,map<string,string>& mon
map<string, string> tempMap = tempMapVec[i]; map<string, string> tempMap = tempMapVec[i];
string szNo = tempMap.find("本点号")->second; string szNo = tempMap.find("本点号")->second;
string code = tempMap.find("code")->second; string code = tempMap.find("code")->second;
monitors.push_back(szNo);
monitorMap.insert(pair<string, string>(szNo, code)); auto mIter = std::find(monitors.begin(), monitors.end(), szNo);
if (mIter != monitors.end())
{
monitorMap.insert(pair<string, string>(szNo, code));
}
mIter = std::find(monitors.begin(), monitors.end(), code);
if (mIter != monitors.end())
{
monitorMap.insert(pair<string, string>(szNo, code));
}
} }
} }
\ No newline at end of file
#pragma once #pragma once
#include "pandaInpCore.h"
/** /**
inpļ inpļ
*/ */
class CivInpExporter class PANDAINPCORE_API CivInpExporter
{ {
public: public:
CivInpExporter(); CivInpExporter();
......
#include "CivInpImpoter.h" #include "CivInpImpoter.h"
#include "CivSysLog.h" // #include "CivSysLog.h"
#include <stdio.h> #include <stdio.h>
CivInpImpoter::CivInpImpoter() CivInpImpoter::CivInpImpoter()
...@@ -14,7 +14,7 @@ CivInpImpoter::~CivInpImpoter() ...@@ -14,7 +14,7 @@ CivInpImpoter::~CivInpImpoter()
int CivInpImpoter::handleline(int linenum, char* text) int CivInpImpoter::handleline(int linenum, char* text)
{ {
printf("line[%d]=[%s]\n", linenum, text); printf("line[%d]=%s\n", linenum, text);
return 0; return 0;
} }
...@@ -23,13 +23,13 @@ bool CivInpImpoter::load(const std::string& inppath) ...@@ -23,13 +23,13 @@ bool CivInpImpoter::load(const std::string& inppath)
FILE* fp; FILE* fp;
int linenum; int linenum;
char* p, buf[1024]; char* p, buf[1024];
CivSysLog::getInstance()->info("开始解析:"+inppath, "CivInpImpoter", __FUNCTION__); // CivSysLog::getInstance()->info("开始解析:"+inppath, "CivInpImpoter", __FUNCTION__);
// 打开文件 // 打开文件
fp = fopen(inppath.c_str(), "r"); fp = fopen(inppath.c_str(), "r");
if (fp == NULL) if (fp == NULL)
{ {
std::string errInfo = "打开文件: " + inppath + "失败!"; /* std::string errInfo = "打开文件: " + inppath + "失败!";
CivSysLog::getInstance()->error(errInfo, "CivInpImpoter", __FUNCTION__); CivSysLog::getInstance()->error(errInfo, "CivInpImpoter", __FUNCTION__);*/
return false; return false;
} }
...@@ -55,8 +55,8 @@ bool CivInpImpoter::load(const std::string& inppath) ...@@ -55,8 +55,8 @@ bool CivInpImpoter::load(const std::string& inppath)
// 处理解析的行数据 // 处理解析的行数据
if (handleline(linenum, p) != 0) { if (handleline(linenum, p) != 0) {
std::string errInfo = "不能解析第:" + std::to_string(linenum) + "行,跳过"; /* std::string errInfo = "不能解析第:" + std::to_string(linenum) + "行,跳过";
CivSysLog::getInstance()->warning(errInfo, "CivInpImpoter", __FUNCTION__); CivSysLog::getInstance()->warning(errInfo, "CivInpImpoter", __FUNCTION__);*/
continue; continue;
} }
} }
......
#pragma once #pragma once
#include "pandaInpCore.h"
#include <string> #include <string>
/** /**
inp文件导入类 inp文件导入类
*/ */
class CivInpImpoter class PANDAINPCORE_API CivInpImpoter
{ {
public: public:
CivInpImpoter(); CivInpImpoter();
......
#pragma once #pragma once
#include "CivInpSubject.h" #include "CivInpSubject.h"
#include "pandaInpCore.h"
#include <list> #include <list>
class CivInpSubject; class CivInpSubject;
...@@ -13,13 +15,13 @@ public: ...@@ -13,13 +15,13 @@ public:
virtual ~CivInpObserver(); virtual ~CivInpObserver();
/** /**
*@brief 状态更新,具体子类实现 * @brief 状态更新,具体子类实现
* @param [sub] 给观察者 * @param [sub] 给观察者
*/ */
virtual void update(CivInpSubject* sub) = 0; virtual void update(CivInpSubject* sub) = 0;
/** /**
*@brief 登记被观察的对象 * @brief 登记被观察的对象
* @param [subject] 具体的被观察者 * @param [subject] 具体的被观察者
*/ */
void subject(CivInpSubject* subject); void subject(CivInpSubject* subject);
......
#include <iostream>
#include "CivInpImpoter.h"
int main(char* argc, char** argv)
{
CivInpImpoter importer;
if (!importer.load("D:\\work\\hydr\\hModelProgram\\Program\\test.inp"))
{
}
getchar();
return 0;
}
\ No newline at end of file
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;PANDAINPCORE_DLL;PANDAINPCORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;PANDAINPCORE_DLL;PANDAINPCORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>pandaLog.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary> <ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
<ClCompile Include="CivInpObserver.cpp" /> <ClCompile Include="CivInpObserver.cpp" />
<ClCompile Include="CivInpSubject.cpp" /> <ClCompile Include="CivInpSubject.cpp" />
<ClCompile Include="CivInpVector.cpp" /> <ClCompile Include="CivInpVector.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
<ClCompile Include="CivInpExporter.cpp"> <ClCompile Include="CivInpExporter.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="main.cpp">
<Filter>头文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivInpExporter.h"> <ClInclude Include="CivInpExporter.h">
......
...@@ -12,10 +12,12 @@ public: ...@@ -12,10 +12,12 @@ public:
virtual void OnFinalMessage(HWND hWnd); virtual void OnFinalMessage(HWND hWnd);
virtual void InitWindow(); virtual void InitWindow();
virtual LRESULT ResponseDefaultKeyEvent(WPARAM wParam); virtual LRESULT ResponseDefaultKeyEvent(WPARAM wParam);
virtual CDuiString GetSkinFile(); virtual CDuiString GetSkinFile();
virtual CDuiString GetSkinFolder(); virtual CDuiString GetSkinFolder();
virtual UILIB_RESOURCETYPE GetResourceType() const; virtual UILIB_RESOURCETYPE GetResourceType() const;
virtual CControlUI* CreateControl(LPCTSTR pstrClass); virtual CControlUI* CreateControl(LPCTSTR pstrClass);
virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
......
#pragma once #pragma once
#include "pandaWaterCore.h"
class CivConnection; class CivConnection;
/** /**
属性表类 属性表类
*/ */
class CivAttributeTable class PANDAWATERCORELIB_API CivAttributeTable
{ {
public: public:
// 属性表类型 // 属性表类型
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <string> #include <string>
#include <map> #include <map>
#include "CivVariant.h" #include "CivVariant.h"
#include "pandaWaterCore.h"
using namespace std; using namespace std;
...@@ -10,7 +11,7 @@ class CivVariant; ...@@ -10,7 +11,7 @@ class CivVariant;
/** /**
属性类 属性类
*/ */
class CivAttributes class PANDAWATERCORELIB_API CivAttributes
{ {
public: public:
typedef pair<string, CivVariant> Pair; typedef pair<string, CivVariant> Pair;
......
...@@ -2,16 +2,17 @@ ...@@ -2,16 +2,17 @@
#include "CivAttributes.h" #include "CivAttributes.h"
#include "CivGeometry.h" #include "CivGeometry.h"
#include "pandaWaterCore.h"
/** /**
要素类 要素类
*/ */
class CivFeature class PANDAWATERCORELIB_API CivFeature
{ {
public: public:
typedef int FeatureId; typedef int FeatureId;
CivFeature(const CivGeometry& geom ); explicit CivFeature(const CivGeometry& geom );
CivFeature() = default; CivFeature() = default;
~CivFeature(); ~CivFeature();
/** /**
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
#include <map> #include <map>
#include "CivPoint.h" #include "CivPoint.h"
#include "pandaWaterCore.h"
typedef std::string String; typedef std::string String;
/** /**
空间几何体对象 空间几何体对象
*/ */
class CivGeometry class PANDAWATERCORELIB_API CivGeometry
{ {
public: public:
// 几何体类型 // 几何体类型
...@@ -33,7 +34,10 @@ public: ...@@ -33,7 +34,10 @@ public:
// 几何体类型 // 几何体类型
GeometryType type() const { return mGeometryType; } GeometryType type() const { return mGeometryType; }
/*几何体对象序列化*/ /**
* @brief 几何体对象序列化
* @param [text] 根据文本文件生成集合体对象
*/
String toJson() const; String toJson() const;
private: private:
......
#pragma once #pragma once
#include "pandaWaterCore.h"
/** /**
Ԫ Ԫ
*/ */
class CivMetaType { class PANDAWATERCORELIB_API CivMetaType {
public: public:
enum Type enum Type
{ {
......
#pragma once #pragma once
#include "pandaWaterCore.h"
/** /**
*/ */
class CivPoint class PANDAWATERCORELIB_API CivPoint
{ {
public: public:
/** /**
......
#pragma once #pragma once
#include "CivMetaType.h" #include "CivMetaType.h"
#include "pandaWaterCore.h"
/** /**
ԭ ԭ
*/ */
class CivVariant class PANDAWATERCORELIB_API CivVariant
{ {
public: public:
typedef CivMetaType::Type Type; typedef CivMetaType::Type Type;
......
#pragma once #pragma once
# if defined(PANDAWATERCORELIB_EXPORTS) # if defined(PANDAWATERCORELIB_EXPORTS)
# if defined(_MSC_VER) # if defined(_MSC_VER)
# define PANDAWATERCORELIB_API __declspec(dllexport) # define PANDAWATERCORELIB_API __declspec(dllexport)
......
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