Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘乐
hydraulicModel
Commits
bb696b4b
Commit
bb696b4b
authored
Sep 27, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,遗传算法框架构建
parent
6da0e985
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
0 deletions
+148
-0
genetic.cpp
pandaAlgorithm/genetic.cpp
+53
-0
genetic.h
pandaAlgorithm/genetic.h
+80
-0
pandaAlgorithm.vcxproj
pandaAlgorithm/pandaAlgorithm.vcxproj
+4
-0
pandaAlgorithm.vcxproj.filters
pandaAlgorithm/pandaAlgorithm.vcxproj.filters
+11
-0
No files found.
pandaAlgorithm/genetic.cpp
0 → 100644
View file @
bb696b4b
#include "genetic.h"
Genetic
::
Genetic
()
{
}
Genetic
::~
Genetic
()
{
}
void
Genetic
::
initPop
()
{
}
void
Genetic
::
fitNess
()
{
}
void
Genetic
::
select
()
{
}
void
Genetic
::
coding
()
{
}
void
Genetic
::
decoding
()
{
}
void
Genetic
::
crossover
()
{
}
void
Genetic
::
variation
()
{
}
void
Genetic
::
update
()
{
}
\ No newline at end of file
pandaAlgorithm/genetic.h
0 → 100644
View file @
bb696b4b
#pragma once
/**
遗传算法对象
*/
class
Genetic
{
public
:
Genetic
();
~
Genetic
();
/**
*@brief 初始化种群
*/
void
initPop
();
/**
*@brief 计算种群自适应度
*/
void
fitNess
();
/**
*@brief 选择
*/
void
select
();
/**
*@brief 编码
*/
void
coding
();
/**
*@brief 解码
*/
void
decoding
();
/**
*@brief 交叉
*/
void
crossover
();
/**
*@brief 选择
*/
void
variation
();
/**
*@brief 更新种群
*/
void
update
();
void
setNumPop
(
int
numPop
)
{
mNumPop
=
numPop
;
}
int
numPop
()
const
{
return
mNumPop
;
}
void
rseRtangeL
(
int
range
)
{
mIrangeL
=
range
;
}
int
rangeL
()
const
{
return
mIrangeL
;
}
void
setRangeR
(
int
range
)
{
mIrangeR
=
range
;
}
int
rangeR
()
const
{
return
mIrangeR
;
}
// 设置编码长度
void
setLength
(
int
len
)
{
mLength
=
len
;
}
int
length
()
const
{
return
mLength
;
}
void
setIteration
(
int
iterator
)
{
mIteration
=
iterator
;
}
int
iteration
()
const
{
return
mIteration
;
}
// 杂焦虑
double
crossoverRate
()
const
{
return
mCrossoverRate
;
}
double
selectRate
()
const
{
return
mSelectRate
;
}
double
variationRate
()
const
{
return
mVariationRate
;
}
private
:
int
mNumPop
=
100
;
//初始种群大小
int
mIrangeL
=
-
1
;
// 问题解区间
int
mIrangeR
=
2
;
int
mLength
=
22
;
// 二进制编码长度
int
mIteration
=
10000
;
// 迭代次数
double
mCrossoverRate
=
0
.
7
;
// 杂交率
double
mSelectRate
=
0
.
5
;
// 选择率
double
mVariationRate
=
0
.
001
;
//变异率
};
pandaAlgorithm/pandaAlgorithm.vcxproj
View file @
bb696b4b
...
@@ -144,6 +144,10 @@
...
@@ -144,6 +144,10 @@
</Link>
</Link>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"genetic.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"genetic.cpp"
/>
</ItemGroup>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
<ImportGroup
Label=
"ExtensionTargets"
>
...
...
pandaAlgorithm/pandaAlgorithm.vcxproj.filters
View file @
bb696b4b
...
@@ -14,4 +14,14 @@
...
@@ -14,4 +14,14 @@
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</Filter>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"genetic.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"genetic.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment