Commit dd384c8d authored by 刘乐's avatar 刘乐

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

parent 073ea36f
......@@ -72,6 +72,7 @@ int main(int argc, char* argv[])
context.setHydrTest(new CivWaterSupplyScopeTest());
context.contextTest(findUri);
break;
case 7://6.测试水源供水范围
context.setHydrTest(new CivProjSimulationTest());
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 @@
#include "pandaAlgorithm.h"
/**
遗传算法对象
遗传算法接口
*/
class PANDAALGORITHM_API Genetic
{
public:
Genetic();
~Genetic();
virtual ~Genetic();
/**
*@brief 初始化种群
*/
void initPop();
virtual void initPop();
/**
*@brief 计算种群自适应度
*/
void fitNess();
virtual void fitNess();
/**
*@brief 选择
*/
void select();
virtual void select();
/**
*@brief 编码
*/
void coding();
virtual void coding();
/**
*@brief 解码
*/
void decoding();
virtual void decoding();
/**
*@brief 交叉
*/
void crossover();
virtual void crossover();
/**
*@brief 选择
*/
void variation();
virtual void variation();
/**
*@brief 更新种群
*/
void update();
virtual void update();
void setNumPop(int numPop) { mNumPop = numPop; }
int numPop() const { return mNumPop; }
......@@ -71,7 +71,7 @@ public:
double variationRate() const { return mVariationRate; }
private:
int mNumPop = 100; //初始种群大小
int mNumPop = 100; //初始种群大小
int mIrangeL = -1; // 问题解区间
int mIrangeR = 2;
int mLength = 22; // 二进制编码长度
......
......@@ -151,12 +151,14 @@ copy genetic.h $(OutDir)..\include /y</Command>
<ClInclude Include="FirstOptScheduling.h" />
<ClInclude Include="genetic.h" />
<ClInclude Include="OptScheduling.h" />
<ClInclude Include="OptSchedulingGenetic.h" />
<ClInclude Include="pandaAlgorithm.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="FirstOptScheduling.cpp" />
<ClCompile Include="genetic.cpp" />
<ClCompile Include="OptScheduling.cpp" />
<ClCompile Include="OptSchedulingGenetic.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -27,6 +27,9 @@
<ClInclude Include="FirstOptScheduling.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="OptSchedulingGenetic.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="genetic.cpp">
......@@ -38,5 +41,8 @@
<ClCompile Include="FirstOptScheduling.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="OptSchedulingGenetic.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</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