001 /**
002 * Copyright (C) 2007-2011, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program. If not, see <http://www.gnu.org/licenses/>.
018 */
019
020 package org.dllearner.core.configurators;
021
022 import org.dllearner.algorithms.gp.GP;
023 import org.dllearner.core.ComponentManager;
024 import org.dllearner.core.AbstractLearningProblem;
025 import org.dllearner.core.LearningProblemUnsupportedException;
026 import org.dllearner.core.AbstractReasonerComponent;
027
028 /**
029 * automatically generated, do not edit manually.
030 * run org.dllearner.scripts.ConfigJavaGenerator to update
031 **/
032 public class GPConfigurator implements Configurator {
033
034 private boolean reinitNecessary = false;
035 private GP gP;
036
037 /**
038 * @param gP see GP
039 **/
040 public GPConfigurator(GP gP){
041 this.gP = gP;
042 }
043
044 /**
045 * @param reasoningService see reasoningService
046 * @param learningProblem see learningProblem
047 * @throws LearningProblemUnsupportedException see
048 * @return GP
049 **/
050 public static GP getGP(AbstractLearningProblem learningProblem, AbstractReasonerComponent reasoningService) throws LearningProblemUnsupportedException{
051 GP component = ComponentManager.getInstance().learningAlgorithm(GP.class, learningProblem, reasoningService);
052 return component;
053 }
054
055 /**
056 * selectionType selection type.
057 * mandatory: false| reinit necessary: true
058 * default value: rankSelection
059 * @return String
060 **/
061 public String getSelectionType() {
062 return (String) ComponentManager.getInstance().getConfigOptionValue(gP, "selectionType") ;
063 }
064 /**
065 * tournamentSize tournament size (applies only to tournament selection).
066 * mandatory: false| reinit necessary: true
067 * default value: 3
068 * @return int
069 **/
070 public int getTournamentSize() {
071 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "tournamentSize") ;
072 }
073 /**
074 * elitism specifies whether to use elitism in selection.
075 * mandatory: false| reinit necessary: true
076 * default value: true
077 * @return boolean
078 **/
079 public boolean getElitism() {
080 return (Boolean) ComponentManager.getInstance().getConfigOptionValue(gP, "elitism") ;
081 }
082 /**
083 * algorithmType algorithm type.
084 * mandatory: false| reinit necessary: true
085 * default value: steadyState
086 * @return String
087 **/
088 public String getAlgorithmType() {
089 return (String) ComponentManager.getInstance().getConfigOptionValue(gP, "algorithmType") ;
090 }
091 /**
092 * mutationProbability mutation probability.
093 * mandatory: false| reinit necessary: true
094 * default value: 0.03
095 * @return double
096 **/
097 public double getMutationProbability() {
098 return (Double) ComponentManager.getInstance().getConfigOptionValue(gP, "mutationProbability") ;
099 }
100 /**
101 * crossoverProbability crossover probability.
102 * mandatory: false| reinit necessary: true
103 * default value: 0.95
104 * @return double
105 **/
106 public double getCrossoverProbability() {
107 return (Double) ComponentManager.getInstance().getConfigOptionValue(gP, "crossoverProbability") ;
108 }
109 /**
110 * hillClimbingProbability hill climbing probability.
111 * mandatory: false| reinit necessary: true
112 * default value: 0.0
113 * @return double
114 **/
115 public double getHillClimbingProbability() {
116 return (Double) ComponentManager.getInstance().getConfigOptionValue(gP, "hillClimbingProbability") ;
117 }
118 /**
119 * refinementProbability refinement operator probability (values higher than 0 turn this into a hybrid GP algorithm - see publication).
120 * mandatory: false| reinit necessary: true
121 * default value: 0.0
122 * @return double
123 **/
124 public double getRefinementProbability() {
125 return (Double) ComponentManager.getInstance().getConfigOptionValue(gP, "refinementProbability") ;
126 }
127 /**
128 * numberOfIndividuals number of individuals.
129 * mandatory: false| reinit necessary: true
130 * default value: 100
131 * @return int
132 **/
133 public int getNumberOfIndividuals() {
134 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "numberOfIndividuals") ;
135 }
136 /**
137 * numberOfSelectedIndividuals number of selected individuals.
138 * mandatory: false| reinit necessary: true
139 * default value: 92
140 * @return int
141 **/
142 public int getNumberOfSelectedIndividuals() {
143 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "numberOfSelectedIndividuals") ;
144 }
145 /**
146 * useFixedNumberOfGenerations specifies whether to use a fixed number of generations.
147 * mandatory: false| reinit necessary: true
148 * default value: false
149 * @return boolean
150 **/
151 public boolean getUseFixedNumberOfGenerations() {
152 return (Boolean) ComponentManager.getInstance().getConfigOptionValue(gP, "useFixedNumberOfGenerations") ;
153 }
154 /**
155 * generations number of generations (only valid if a fixed number of generations is used).
156 * mandatory: false| reinit necessary: true
157 * default value: 20
158 * @return int
159 **/
160 public int getGenerations() {
161 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "generations") ;
162 }
163 /**
164 * postConvergenceGenerations number of generations after which to stop if no improvement wrt. the best solution has been achieved.
165 * mandatory: false| reinit necessary: true
166 * default value: 50
167 * @return int
168 **/
169 public int getPostConvergenceGenerations() {
170 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "postConvergenceGenerations") ;
171 }
172 /**
173 * adc whether to use automatically defined concept (this invents new helper concepts, but enlarges the search space.
174 * mandatory: false| reinit necessary: true
175 * default value: false
176 * @return boolean
177 **/
178 public boolean getAdc() {
179 return (Boolean) ComponentManager.getInstance().getConfigOptionValue(gP, "adc") ;
180 }
181 /**
182 * initMinDepth minimum depth to use when creating the initial population.
183 * mandatory: false| reinit necessary: true
184 * default value: 4
185 * @return int
186 **/
187 public int getInitMinDepth() {
188 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "initMinDepth") ;
189 }
190 /**
191 * initMaxDepth maximum depth to use when creating the initial population.
192 * mandatory: false| reinit necessary: true
193 * default value: 6
194 * @return int
195 **/
196 public int getInitMaxDepth() {
197 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "initMaxDepth") ;
198 }
199 /**
200 * maxConceptLength maximum concept length (higher length means lowest possible fitness).
201 * mandatory: false| reinit necessary: true
202 * default value: 75
203 * @return int
204 **/
205 public int getMaxConceptLength() {
206 return (Integer) ComponentManager.getInstance().getConfigOptionValue(gP, "maxConceptLength") ;
207 }
208
209 /**
210 * @param selectionType selection type.
211 * mandatory: false| reinit necessary: true
212 * default value: rankSelection
213 **/
214 public void setSelectionType(String selectionType) {
215 ComponentManager.getInstance().applyConfigEntry(gP, "selectionType", selectionType);
216 reinitNecessary = true;
217 }
218 /**
219 * @param tournamentSize tournament size (applies only to tournament selection).
220 * mandatory: false| reinit necessary: true
221 * default value: 3
222 **/
223 public void setTournamentSize(int tournamentSize) {
224 ComponentManager.getInstance().applyConfigEntry(gP, "tournamentSize", tournamentSize);
225 reinitNecessary = true;
226 }
227 /**
228 * @param elitism specifies whether to use elitism in selection.
229 * mandatory: false| reinit necessary: true
230 * default value: true
231 **/
232 public void setElitism(boolean elitism) {
233 ComponentManager.getInstance().applyConfigEntry(gP, "elitism", elitism);
234 reinitNecessary = true;
235 }
236 /**
237 * @param algorithmType algorithm type.
238 * mandatory: false| reinit necessary: true
239 * default value: steadyState
240 **/
241 public void setAlgorithmType(String algorithmType) {
242 ComponentManager.getInstance().applyConfigEntry(gP, "algorithmType", algorithmType);
243 reinitNecessary = true;
244 }
245 /**
246 * @param mutationProbability mutation probability.
247 * mandatory: false| reinit necessary: true
248 * default value: 0.03
249 **/
250 public void setMutationProbability(double mutationProbability) {
251 ComponentManager.getInstance().applyConfigEntry(gP, "mutationProbability", mutationProbability);
252 reinitNecessary = true;
253 }
254 /**
255 * @param crossoverProbability crossover probability.
256 * mandatory: false| reinit necessary: true
257 * default value: 0.95
258 **/
259 public void setCrossoverProbability(double crossoverProbability) {
260 ComponentManager.getInstance().applyConfigEntry(gP, "crossoverProbability", crossoverProbability);
261 reinitNecessary = true;
262 }
263 /**
264 * @param hillClimbingProbability hill climbing probability.
265 * mandatory: false| reinit necessary: true
266 * default value: 0.0
267 **/
268 public void setHillClimbingProbability(double hillClimbingProbability) {
269 ComponentManager.getInstance().applyConfigEntry(gP, "hillClimbingProbability", hillClimbingProbability);
270 reinitNecessary = true;
271 }
272 /**
273 * @param refinementProbability refinement operator probability (values higher than 0 turn this into a hybrid GP algorithm - see publication).
274 * mandatory: false| reinit necessary: true
275 * default value: 0.0
276 **/
277 public void setRefinementProbability(double refinementProbability) {
278 ComponentManager.getInstance().applyConfigEntry(gP, "refinementProbability", refinementProbability);
279 reinitNecessary = true;
280 }
281 /**
282 * @param numberOfIndividuals number of individuals.
283 * mandatory: false| reinit necessary: true
284 * default value: 100
285 **/
286 public void setNumberOfIndividuals(int numberOfIndividuals) {
287 ComponentManager.getInstance().applyConfigEntry(gP, "numberOfIndividuals", numberOfIndividuals);
288 reinitNecessary = true;
289 }
290 /**
291 * @param numberOfSelectedIndividuals number of selected individuals.
292 * mandatory: false| reinit necessary: true
293 * default value: 92
294 **/
295 public void setNumberOfSelectedIndividuals(int numberOfSelectedIndividuals) {
296 ComponentManager.getInstance().applyConfigEntry(gP, "numberOfSelectedIndividuals", numberOfSelectedIndividuals);
297 reinitNecessary = true;
298 }
299 /**
300 * @param useFixedNumberOfGenerations specifies whether to use a fixed number of generations.
301 * mandatory: false| reinit necessary: true
302 * default value: false
303 **/
304 public void setUseFixedNumberOfGenerations(boolean useFixedNumberOfGenerations) {
305 ComponentManager.getInstance().applyConfigEntry(gP, "useFixedNumberOfGenerations", useFixedNumberOfGenerations);
306 reinitNecessary = true;
307 }
308 /**
309 * @param generations number of generations (only valid if a fixed number of generations is used).
310 * mandatory: false| reinit necessary: true
311 * default value: 20
312 **/
313 public void setGenerations(int generations) {
314 ComponentManager.getInstance().applyConfigEntry(gP, "generations", generations);
315 reinitNecessary = true;
316 }
317 /**
318 * @param postConvergenceGenerations number of generations after which to stop if no improvement wrt. the best solution has been achieved.
319 * mandatory: false| reinit necessary: true
320 * default value: 50
321 **/
322 public void setPostConvergenceGenerations(int postConvergenceGenerations) {
323 ComponentManager.getInstance().applyConfigEntry(gP, "postConvergenceGenerations", postConvergenceGenerations);
324 reinitNecessary = true;
325 }
326 /**
327 * @param adc whether to use automatically defined concept (this invents new helper concepts, but enlarges the search space.
328 * mandatory: false| reinit necessary: true
329 * default value: false
330 **/
331 public void setAdc(boolean adc) {
332 ComponentManager.getInstance().applyConfigEntry(gP, "adc", adc);
333 reinitNecessary = true;
334 }
335 /**
336 * @param initMinDepth minimum depth to use when creating the initial population.
337 * mandatory: false| reinit necessary: true
338 * default value: 4
339 **/
340 public void setInitMinDepth(int initMinDepth) {
341 ComponentManager.getInstance().applyConfigEntry(gP, "initMinDepth", initMinDepth);
342 reinitNecessary = true;
343 }
344 /**
345 * @param initMaxDepth maximum depth to use when creating the initial population.
346 * mandatory: false| reinit necessary: true
347 * default value: 6
348 **/
349 public void setInitMaxDepth(int initMaxDepth) {
350 ComponentManager.getInstance().applyConfigEntry(gP, "initMaxDepth", initMaxDepth);
351 reinitNecessary = true;
352 }
353 /**
354 * @param maxConceptLength maximum concept length (higher length means lowest possible fitness).
355 * mandatory: false| reinit necessary: true
356 * default value: 75
357 **/
358 public void setMaxConceptLength(int maxConceptLength) {
359 ComponentManager.getInstance().applyConfigEntry(gP, "maxConceptLength", maxConceptLength);
360 reinitNecessary = true;
361 }
362
363 /**
364 * true, if this component needs reinitializsation.
365 * @return boolean
366 **/
367 public boolean isReinitNecessary(){
368 return reinitNecessary;
369 }
370
371
372 }