-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGene.java
134 lines (122 loc) · 2.5 KB
/
Gene.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Map;
import java.util.TreeMap;
public abstract class Gene {
protected Object value;
protected int fitness;
protected int age;
protected int matureAge;
protected int deathAge;
protected boolean aging;
protected boolean mature;
protected Object target;
public Gene(Object val, Object tar,boolean _aging) {
// TODO Auto-generated constructor stub
value=val;
target=tar;
aging=_aging;
age=0;
mature = false;
matureAge=5;
fitness_calculation();
}
public void birthday()
{
age++;
if(age>=matureAge)
mature = true;
}
public void fitness_calculation()//abstarct
{
System.out.println("Gene");
fitness=0;
}
public Gene mate(Gene gene)//abstarct
{
return null;
}
public void mutate()//abstarct
{
return;
}
public Gene getRandom() //abstarct
{
return null;
}
public static Comparator<Gene> compare()
{
Comparator<Gene> comp= new Comparator<Gene>() {
@Override
public int compare(Gene o1, Gene o2) {
// TODO Auto-generated method stub
if(o1.getFitness()<o2.getFitness())
return -1;
if(o1.getFitness()>o2.getFitness())
return 1;
return 0;
}
};
return comp;
}
// *
// *
//Setters and Getters nothing important here *
// *
// *
// *
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public int getFitness() {
return fitness;
}
public void setFitness(int fitness) {
this.fitness = fitness;
}
public Object getTarget() {
return target;
}
public void setTarget(Object target) {
this.target = target;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getMatureAge() {
return matureAge;
}
public void setMatureAge(int matureAge) {
this.matureAge = matureAge;
}
public boolean isAging() {
return aging;
}
public void setAging(boolean aging) {
this.aging = aging;
}
public boolean isMature()
{
return mature;
}
public int getDeathAge() {
return deathAge;
}
public void setDeathAge(int deathAge) {
this.deathAge = deathAge;
}
public Gene mate(Gene gene, Crossover option) {
// TODO Auto-generated method stub
return null;
}
public void mutate(Mutation mutation) {
// TODO Auto-generated method stub
}
}