-
Notifications
You must be signed in to change notification settings - Fork 0
/
player0.java
67 lines (57 loc) · 1.88 KB
/
player0.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
import org.vu.contest.ContestSubmission;
import org.vu.contest.ContestEvaluation;
// import contest.ContestSubmission;
// import contest.ContestEvaluation;
import java.util.Random;
import java.util.Properties;
public class player0 implements ContestSubmission
{
Random rnd_;
ContestEvaluation evaluation_;
private int evaluations_limit_;
public player0()
{
rnd_ = new Random();
}
public void setSeed(long seed)
{
// Set seed of algortihms random process
rnd_.setSeed(seed);
}
public void setEvaluation(ContestEvaluation evaluation)
{
// Set evaluation problem used in the run
evaluation_ = evaluation;
// Get evaluation properties
Properties props = evaluation.getProperties();
// Get evaluation limit
evaluations_limit_ = Integer.parseInt(props.getProperty("Evaluations"));
// Property keys depend on specific evaluation
// E.g. double param = Double.parseDouble(props.getProperty("property_name"));
boolean isMultimodal = Boolean.parseBoolean(props.getProperty("Multimodal"));
boolean hasStructure = Boolean.parseBoolean(props.getProperty("Regular"));
boolean isSeparable = Boolean.parseBoolean(props.getProperty("Separable"));
// Do sth with property values, e.g. specify relevant settings of your algorithm
if(isMultimodal){
// Do sth
}else{
// Do sth else
}
}
public void run()
{
// Run your algorithm here
int evals = 0;
// init population
// calculate fitness
while(evals<evaluations_limit_){
// Select parents
// Apply crossover / mutation operators
double child[] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
// Check fitness of unknown fuction
Double fitness = (double) evaluation_.evaluate(child);
evals++;
// Select survivors
}
}
}