📄 abstractgeneratinggeneticalgorithm.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.operator.features.ga;
import edu.udo.cs.yale.operator.parameter.*;
import edu.udo.cs.yale.operator.OperatorException;
import edu.udo.cs.yale.generator.*;
import edu.udo.cs.yale.operator.features.*;
import edu.udo.cs.yale.tools.LogService;
import java.util.ArrayList;
import java.util.List;
/** In contrast to its superclass {@link GeneticAlgorithm}, the {@link GeneratingGeneticAlgorithm}
* generates new attributes and thus can change the length of an individual. Therfore specialized mutation
* and crossover operators are being applied. Generators are chosen at random from a list of generators
* specified by boolean parameters. <br/>
*
* Since this operator does not contain algorithms to extract features from value series, it is restricted
* to example sets with only single attributes. For automatic feature extraction from values series the
* value series plugin for Yale written by Ingo Mierswa should be used. It is available at
* <a href="http://yale.cs.uni-dortmund.de">http://yale.cs.uni-dortmund.de</a>
*
* @yale.reference Ritthoff/etal/2001a
* @yale.xmlclass GeneratingGeneticAlgorithm
* @author ingo
* @version $Id: AbstractGeneratingGeneticAlgorithm.java,v 2.3 2004/08/27 11:57:36 ingomierswa Exp $
*/
public abstract class AbstractGeneratingGeneticAlgorithm extends AbstractGeneticAlgorithm {
/** Returns a specialized generating mutation, e.g. a <code>AttributeGenerator</code>. */
protected abstract PopulationOperator getGeneratingPopulationOperator();
protected List getPreProcessingPopulationOperators() {
List popOps = super.getPreProcessingPopulationOperators();
PopulationOperator generator = getGeneratingPopulationOperator();
if (generator != null)
popOps.add(generator);
return popOps;
}
/** Returns an <code>UnbalancedCrossover</code>. */
protected PopulationOperator getCrossoverPopulationOperator() {
double pCrossover = getParameterAsDouble("p_crossover");
int crossoverType = getParameterAsInt("crossover_type");
return new UnbalancedCrossover(crossoverType, pCrossover);
}
/** Returns a list with all generator which should be used. */
public List getGenerators() {
List generators = new ArrayList();
if (getParameterAsBoolean("use_plus"))
generators.add(new BasicArithmeticOperationGenerator(BasicArithmeticOperationGenerator.SUM));
if (getParameterAsBoolean("use_diff"))
generators.add(new BasicArithmeticOperationGenerator(BasicArithmeticOperationGenerator.DIFFERENCE));
if (getParameterAsBoolean("use_mult"))
generators.add(new BasicArithmeticOperationGenerator(BasicArithmeticOperationGenerator.PRODUCT));
if (getParameterAsBoolean("use_div"))
generators.add(new BasicArithmeticOperationGenerator(BasicArithmeticOperationGenerator.QUOTIENT));
if (getParameterAsBoolean("reciprocal_value")) generators.add(new ReciprocalValueGenerator());
return generators;
}
public List getParameterTypes() {
List types = super.getParameterTypes();
ParameterType type = new ParameterTypeDouble("p_crossover",
"Probability for an individual to be selected for crossover.",
0, 1, 0.5);
type.setExpert(false);
types.add(type);
types.add(new ParameterTypeCategory("crossover_type", "Type of the crossover.",
SelectionCrossover.CROSSOVER_TYPES, SelectionCrossover.UNIFORM));
types.add(new ParameterTypeBoolean("use_plus", "Generate sums.", true));
types.add(new ParameterTypeBoolean("use_diff", "Generate differences.", true));
types.add(new ParameterTypeBoolean("use_mult", "Generate products.", true));
types.add(new ParameterTypeBoolean("use_div", "Generate quotients.", true));
types.add(new ParameterTypeBoolean("reciprocal_value", "Generate reciprocal values.", false));
return types;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -