This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParameters.java
116 lines (81 loc) · 4.45 KB
/
Parameters.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
/******************************************************************************
* A Teaching GA Developed by Hal Stringer & Annie Wu, UCF
* Version 2, January 18, 2004
*******************************************************************************/
import java.io.*;
import java.util.*;
import java.text.*;
public class Parameters
{
/*******************************************************************************
* INSTANCE VARIABLES *
*******************************************************************************/
public static String expID;
public static String problemType;
public static String dataInputFileName;
public static int numRuns;
public static int generations;
public static int popSize;
public static int genCap;
public static int fitCap;
public static String minORmax;
public static int selectType;
public static int scaleType;
public static int xoverType;
public static double xoverRate;
public static int mutationType;
public static double mutationRate;
public static long seed;
public static int numGenes;
public static int geneSize;
/*******************************************************************************
* CONSTRUCTORS *
*******************************************************************************/
public Parameters(String parmfilename) throws java.io.IOException{
String readLine;
BufferedReader parmInput = new BufferedReader(new FileReader (parmfilename));
expID = parmInput.readLine().substring(30);
problemType = parmInput.readLine().substring(30);
dataInputFileName = parmInput.readLine().substring(30);
numRuns = Integer.parseInt(parmInput.readLine().substring(30).trim());
generations = Integer.parseInt(parmInput.readLine().substring(30).trim());
popSize = Integer.parseInt(parmInput.readLine().substring(30).trim());
selectType = Integer.parseInt(parmInput.readLine().substring(30).trim());
scaleType = Integer.parseInt(parmInput.readLine().substring(30).trim());
xoverType = Integer.parseInt(parmInput.readLine().substring(30).trim());
xoverRate = Double.parseDouble(parmInput.readLine().substring(30).trim());
mutationType = Integer.parseInt(parmInput.readLine().substring(30).trim());
mutationRate = Double.parseDouble(parmInput.readLine().substring(30).trim());
seed = Long.parseLong(parmInput.readLine().substring(30).trim());
numGenes = Integer.parseInt(parmInput.readLine().substring(30).trim());
geneSize = Integer.parseInt(parmInput.readLine().substring(30).trim());
parmInput.close();
if (scaleType==0 || scaleType==2) minORmax = "max";
else minORmax = "min";
}
/*******************************************************************************
* MEMBER METHODS *
*******************************************************************************/
/*******************************************************************************
* STATIC METHODS *
*******************************************************************************/
public static void outputParameters(FileWriter output) throws java.io.IOException{
output.write("Experiment ID : " + expID + "\n");
output.write("Problem Type : " + problemType + "\n");
output.write("Data Input File Name : " + dataInputFileName + "\n");
output.write("Number of Runs : " + numRuns + "\n");
output.write("Generations per Run : " + generations + "\n");
output.write("Population Size : " + popSize + "\n");
output.write("Selection Method : " + selectType + "\n");
output.write("Fitness Scaling Type : " + scaleType + "\n");
output.write("Min or Max Fitness : " + minORmax + "\n");
output.write("Crossover Type : " + xoverType + "\n");
output.write("Crossover Rate : " + xoverRate + "\n");
output.write("Mutation Type : " + mutationType + "\n");
output.write("Mutation Rate : " + mutationRate + "\n");
output.write("Random Number Seed : " + seed + "\n");
output.write("Number of Genes/Points : " + numGenes + "\n");
output.write("Size of Genes : " + geneSize + "\n");
output.write("\n\n");
}
} // End of Parameters.java **************************************************