⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directedgeneratinggeneticalgorithm.java

📁 著名的开源仿真软件yale
💻 JAVA
字号:
/* *  YALE - Yet Another Learning Environment *  Copyright (C) 2002, 2003 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,  *          Katharina Morik, Oliver Ritthoff *      Artificial Intelligence Unit *      Computer Science Department *      University of Dortmund *      44221 Dortmund,  Germany *  email: yale@ls8.cs.uni-dortmund.de *  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.operator.FatalException;import edu.udo.cs.yale.generator.*;import edu.udo.cs.yale.tools.LogService;import edu.udo.cs.yale.operator.features.*;import java.util.ArrayList;import java.util.List;import java.util.ListIterator;/** By using a generating genetic algorithm which generates new *  attributes and do not only select them it can happen that many *  irrelevant attributes are generated. In addition, these individuals *  can be randomly generated and deleted several times. *  <br/> *  It might be a good idea to make the generating genetic algorithm a *  sort of smarter by using an information gain criterion to decide, which *  attribute should be selected or should be used to generate another *  one. With the new regression information gain criterion this is *  possible for regression problems too. *  <br/> *  The attributes get their information gain values. Then the more *  informative attributes will be preferably selected and used for *  generating new attributes. Therefore it is postulated that it is *  better to generate new attributes from the informative ones. * *  @yale.xmlclass DirectedGeneratingGeneticAlgorithm *  @author ingo *  @version $Id: DirectedGeneratingGeneticAlgorithm.java,v 2.3 2003/04/04 11:59:28 fischer Exp $ */public class DirectedGeneratingGeneticAlgorithm extends GeneratingGeneticAlgorithm {    /** Ruft <tt>initApply()</tt> der Oberklasse auf und setzt noch entsprechende Parameter. Zus&auml;tzlich wird noch      *  InformationGain in die preEvaluation - Liste gepackt.     */    public void initApply() throws OperatorException {	super.initApply();	if (getNumberOfOperators() != 3) {	    throw new FatalException("DirectedGeneratingGeneticAlgorithm needs three operators: " + 				     "a normal GGA experiment chain, a learner and a model applier to find the information gain!");	}	//addPostEvaluationPopulationOperator(new RemoveUnusedAttributes());    }    PopulationOperator[] getPreProcessingPopulationOperators() {	// ratio gain	boolean ratioGain = getParameterAsBoolean("use_ratio_gain");	// epsilon	double epsilon = getParameterAsDouble("epsilon");	// usePredictedLabel	boolean usePredictedLabel = getParameterAsBoolean("use_predicted_label");	return new PopulationOperator[] {  	    new InformationGain(getOperator(1), getOperator(2), epsilon, 				usePredictedLabel, ratioGain) 		};    }    /** Liefert den Mutations <tt>PopulationOperator</tt>, kann von Unterklassen &uuml;berschireben werden.     */    PopulationOperator getMutationPopulationOperator() {	double pMutation   = getParameterAsDouble("p_mutation");	double leftBound   = getParameterAsDouble("lower_mutation_bound");	double rightBound  = getParameterAsDouble("upper_mutation_bound");	return new DirectedMutation(pMutation, leftBound, rightBound);    }    /** Liefert den generierenden <tt>PopulationOperator</tt>, kann von Unterklassen &uuml;berschrieben werden.     */    PopulationOperator getGeneratingPopulationOperator() {	int    noOfNewAttributes = getParameterAsInt("max_number_of_new_attributes"); 	double pGenerate         = getParameterAsDouble("p_generate");		// erzeugt die Generatoren	ArrayList generators = new ArrayList();		if (getParameterAsBoolean("reciprocal_value")) {	    FeatureGenerator g =  new ReciprocalValueGenerator(true);	    generators.add(g);	}	if (getParameterAsBoolean("function_characteristica")) {	    FeatureGenerator g =  new FunctionCharacteristicaGenerator();	    generators.add(g);	}	if (getParameterAsBoolean("use_plus")) {	    FeatureGenerator g =  new BasicArithmeticOperationGenerator(0, true);	    generators.add(g);	}	if (getParameterAsBoolean("use_diff")) {	    FeatureGenerator g =  new BasicArithmeticOperationGenerator(1, true);	    generators.add(g);	}	if (getParameterAsBoolean("use_mult")) {	    FeatureGenerator g =  new BasicArithmeticOperationGenerator(2, true);	    generators.add(g);	}	if (getParameterAsBoolean("use_div")) {	    FeatureGenerator g =  new BasicArithmeticOperationGenerator(3, true);	    generators.add(g);	}	if (generators.size()==0) {	    LogService.logMessage("No FeatureGenerators specified for " + getName() + ".", LogService.WARNING);	} 		double leftBound   = getParameterAsDouble("lower_generation_bound");	double rightBound  = getParameterAsDouble("upper_generation_bound");	// fuegt das Generieren in die PreEval - Liste ein.	return new DirectedAttributeGenerator(pGenerate, noOfNewAttributes, generators, leftBound, rightBound);    }     public List getParameterTypes() {	List types = super.getParameterTypes();	types.add(new ParameterTypeDouble("lower_generation_bound", "Lower bound for the generation probability.", 0, 1, 0.1));	types.add(new ParameterTypeDouble("upper_generation_bound", "Upper bound for the generation probability.", 0, 1, 0.9));	types.add(new ParameterTypeBoolean("use_ratio_gain", "If set to true the ratio gain criterion is used.", true));	types.add(new ParameterTypeDouble("epsilon", "Variation range of attribute values for the attribute information gain.", 0, 1, 0.1));	types.add(new ParameterTypeBoolean("use_predicted_label", "If set to true, the predicted label is used for the attribute information gain.", true));	types.add(new ParameterTypeDouble("lower_mutation_bound", "Lower bound for the mutation probability.", 0, 1, 0.1));	types.add(new ParameterTypeDouble("upper_mutation_bound", "Upper bound for the mutation probability.", 0, 1, 0.9));	types.add(new ParameterTypeBoolean("reciprocal_value", "Generate reciprocal values.", true));	types.add(new ParameterTypeBoolean("function_charactersitica", "Generate function characteristica (for C9).", false));	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));	return types;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -