-
Notifications
You must be signed in to change notification settings - Fork 3
/
PopulationGenerator.cs
40 lines (37 loc) · 1.11 KB
/
PopulationGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Text;
namespace SymbolicRegression
{
/// <summary>
/// 种群生成器接口
/// </summary>
interface IPopulationGenerator
{
List<IIndividual> Generate();
}
/// <summary>
/// GEP种群生成器
/// </summary>
class GEPPopulationGenerator : IPopulationGenerator
{
public int PopSize { get; set; }
public int HeadLen { get; set; }
public FunctionSet FunctionSet { get; set; }
public List<Point> Data { get; set; }
public double ConstMinVal { get; set; }
public double ConstMaxVal { get; set; }
public int OptimizeGenerationCount { get; set; }
public List<IIndividual> Generate()
{
List<IIndividual> pop = new List<IIndividual>();
for (int i = 0; i < PopSize; ++i)
{
GEPIndividual ind = new GEPIndividual(HeadLen, FunctionSet, ConstMinVal, ConstMaxVal, OptimizeGenerationCount);
ind.Optimize(Data);
pop.Add(ind);
}
return pop;
}
}
}