Commit dd384c8d authored by 刘乐's avatar 刘乐

1, 直接优化调度接口添加

parent 073ea36f
...@@ -72,6 +72,7 @@ int main(int argc, char* argv[]) ...@@ -72,6 +72,7 @@ int main(int argc, char* argv[])
context.setHydrTest(new CivWaterSupplyScopeTest()); context.setHydrTest(new CivWaterSupplyScopeTest());
context.contextTest(findUri); context.contextTest(findUri);
break; break;
case 7://6.测试水源供水范围 case 7://6.测试水源供水范围
context.setHydrTest(new CivProjSimulationTest()); context.setHydrTest(new CivProjSimulationTest());
context.contextTest(findUri); context.contextTest(findUri);
......
#include "OptSchedulingGenetic.h"
OptSchedulingGenetic::OptSchedulingGenetic(std::shared_ptr<OptScheduling*>& optPtr)
:mOptPtr(optPtr)
{
}
OptSchedulingGenetic::~OptSchedulingGenetic()
{
}
void OptSchedulingGenetic::initPop()
{
}
void OptSchedulingGenetic::fitNess()
{
}
void OptSchedulingGenetic::select()
{
}
void OptSchedulingGenetic::coding()
{
}
void OptSchedulingGenetic::decoding()
{
}
void OptSchedulingGenetic::crossover()
{
}
void OptSchedulingGenetic::variation()
{
}
void OptSchedulingGenetic::update()
{
}
#pragma once
#include "genetic.h"
#include "OptScheduling.h"
#include "pandaAlgorithm.h"
#include<memory>
/**
* 具体的遗传优化算法
*/
class PANDAALGORITHM_API OptSchedulingGenetic :public Genetic
{
public:
explicit OptSchedulingGenetic(std::shared_ptr<OptScheduling*> &optPtr);
~OptSchedulingGenetic();
/**
*@brief 初始化种群
*/
virtual void initPop();
/**
*@brief 计算种群自适应度
*/
virtual void fitNess();
/**
*@brief 选择
*/
virtual void select();
/**
*@brief 编码
*/
virtual void coding();
/**
*@brief 解码
*/
virtual void decoding();
/**
*@brief 交叉
*/
virtual void crossover();
/**
*@brief 选择
*/
virtual void variation();
/**
*@brief 更新种群
*/
virtual void update();
private:
std::shared_ptr<OptScheduling*> mOptPtr;
};
...@@ -2,52 +2,52 @@ ...@@ -2,52 +2,52 @@
#include "pandaAlgorithm.h" #include "pandaAlgorithm.h"
/** /**
遗传算法对象 遗传算法接口
*/ */
class PANDAALGORITHM_API Genetic class PANDAALGORITHM_API Genetic
{ {
public: public:
Genetic(); Genetic();
~Genetic(); virtual ~Genetic();
/** /**
*@brief 初始化种群 *@brief 初始化种群
*/ */
void initPop(); virtual void initPop();
/** /**
*@brief 计算种群自适应度 *@brief 计算种群自适应度
*/ */
void fitNess(); virtual void fitNess();
/** /**
*@brief 选择 *@brief 选择
*/ */
void select(); virtual void select();
/** /**
*@brief 编码 *@brief 编码
*/ */
void coding(); virtual void coding();
/** /**
*@brief 解码 *@brief 解码
*/ */
void decoding(); virtual void decoding();
/** /**
*@brief 交叉 *@brief 交叉
*/ */
void crossover(); virtual void crossover();
/** /**
*@brief 选择 *@brief 选择
*/ */
void variation(); virtual void variation();
/** /**
*@brief 更新种群 *@brief 更新种群
*/ */
void update(); virtual void update();
void setNumPop(int numPop) { mNumPop = numPop; } void setNumPop(int numPop) { mNumPop = numPop; }
int numPop() const { return mNumPop; } int numPop() const { return mNumPop; }
......
...@@ -151,12 +151,14 @@ copy genetic.h $(OutDir)..\include /y</Command> ...@@ -151,12 +151,14 @@ copy genetic.h $(OutDir)..\include /y</Command>
<ClInclude Include="FirstOptScheduling.h" /> <ClInclude Include="FirstOptScheduling.h" />
<ClInclude Include="genetic.h" /> <ClInclude Include="genetic.h" />
<ClInclude Include="OptScheduling.h" /> <ClInclude Include="OptScheduling.h" />
<ClInclude Include="OptSchedulingGenetic.h" />
<ClInclude Include="pandaAlgorithm.h" /> <ClInclude Include="pandaAlgorithm.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="FirstOptScheduling.cpp" /> <ClCompile Include="FirstOptScheduling.cpp" />
<ClCompile Include="genetic.cpp" /> <ClCompile Include="genetic.cpp" />
<ClCompile Include="OptScheduling.cpp" /> <ClCompile Include="OptScheduling.cpp" />
<ClCompile Include="OptSchedulingGenetic.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
<ClInclude Include="FirstOptScheduling.h"> <ClInclude Include="FirstOptScheduling.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="OptSchedulingGenetic.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="genetic.cpp"> <ClCompile Include="genetic.cpp">
...@@ -38,5 +41,8 @@ ...@@ -38,5 +41,8 @@
<ClCompile Include="FirstOptScheduling.cpp"> <ClCompile Include="FirstOptScheduling.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="OptSchedulingGenetic.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
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