From: <jen...@us...> - 2007-11-12 15:13:54
|
Revision: 282 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=282&view=rev Author: jenslehmann Date: 2007-11-12 07:13:50 -0800 (Mon, 12 Nov 2007) Log Message: ----------- - adapted genetic programming algorithm to work with new DL-Learner core - all configuration options of GP are now thread safe (removed option useMultiStructures) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 15:13:50 UTC (rev 282) @@ -2,9 +2,6 @@ import java.lang.reflect.Field; -import org.dllearner.algorithms.gp.GP.AlgorithmType; -import org.dllearner.algorithms.gp.GP.SelectionType; - public class Config { // standardmäßig wird bis Tiefe 7 gesucht // public static int maxLength = 7; @@ -195,46 +192,46 @@ // FPS funktioniert momentan noch nicht, es muss sichergestellt werden, // dass die Fitness positiv ist (momentan ist sie nie gr��er 0) - public static SelectionType selectionType = SelectionType.RANK_SELECTION; - - public static int tournamentSize = 3; - - public static boolean elitism = true; - - public static AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; - - public static double mutationProbability = 0.03d; - - public static double crossoverProbability = 0.95d; - - public static double hillClimbingProbability = 0.0d; - - public static double refinementProbability = 0.0; - - public static int numberOfIndividuals = 100; - - public static int numberOfSelectedIndividuals = 96; - - public static boolean useFixedNumberOfGenerations = false; - - public static int generations = 20; - - public static int postConvergenceGenerations = 50; - - public static boolean adc = false; - - public static int initMinDepth = 4; - - public static int initMaxDepth = 6; - - public static int maxConceptLength = 75; - - // bei true werden statt Disjunction MultiDisjunction und statt - // Conjunction - // MultiConjunction im GP benutzt (es gibt derzeit keinen Grund es auf - // false - // zu setzen) - public static boolean useMultiStructures = true; +// public static SelectionType selectionType = SelectionType.RANK_SELECTION; +// +// public static int tournamentSize = 3; +// +// public static boolean elitism = true; +// +// public static AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; +// +// public static double mutationProbability = 0.03d; +// +// public static double crossoverProbability = 0.95d; +// +// public static double hillClimbingProbability = 0.0d; +// +// public static double refinementProbability = 0.0; +// +// public static int numberOfIndividuals = 100; +// +// public static int numberOfSelectedIndividuals = 96; +// +// public static boolean useFixedNumberOfGenerations = false; +// +// public static int generations = 20; +// +// public static int postConvergenceGenerations = 50; +// +// public static boolean adc = false; +// +// public static int initMinDepth = 4; +// +// public static int initMaxDepth = 6; +// +// public static int maxConceptLength = 75; +// +// // bei true werden statt Disjunction MultiDisjunction und statt +// // Conjunction +// // MultiConjunction im GP benutzt (es gibt derzeit keinen Grund es auf +// // false +// // zu setzen) +// public static boolean useMultiStructures = true; } Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 15:13:50 UTC (rev 282) @@ -8,10 +8,7 @@ import java.util.Map; import java.util.Set; -import org.dllearner.algorithms.gp.GP.AlgorithmType; -import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.cli.ConfFileOption; -import org.dllearner.utilities.Datastructures; /** * Nach dem einlesen der Datei werden hier alle Konfigurationsoptionen @@ -372,20 +369,20 @@ private void applyIntOptions(String option, int value) { if (option.equals("maxLength")) ;//Config.maxLength = value; - else if (option.equals("gp.numberOfIndividuals")) - Config.GP.numberOfIndividuals = value; - else if (option.equals("gp.numberOfSelectedIndividuals")) - Config.GP.numberOfSelectedIndividuals = value; - else if (option.equals("gp.postConvergenceGenerations")) - Config.GP.postConvergenceGenerations = value; - else if (option.equals("gp.generations")) - Config.GP.generations = value; - else if (option.equals("gp.tournamentSize")) - Config.GP.tournamentSize = value; - else if (option.equals("gp.initMinDepth")) - Config.GP.initMinDepth = value; - else if (option.equals("gp.initMaxDepth")) - Config.GP.initMaxDepth = value; +// else if (option.equals("gp.numberOfIndividuals")) +// Config.GP.numberOfIndividuals = value; +// else if (option.equals("gp.numberOfSelectedIndividuals")) +// Config.GP.numberOfSelectedIndividuals = value; +// else if (option.equals("gp.postConvergenceGenerations")) +// Config.GP.postConvergenceGenerations = value; +// else if (option.equals("gp.generations")) +// Config.GP.generations = value; +// else if (option.equals("gp.tournamentSize")) +// Config.GP.tournamentSize = value; +// else if (option.equals("gp.initMinDepth")) +// Config.GP.initMinDepth = value; +// else if (option.equals("gp.initMaxDepth")) +// Config.GP.initMaxDepth = value; } private void applyDoubleOptions(String option, double value) { @@ -394,14 +391,14 @@ ; //Config.accuracyPenalty = value; else if (option.equals("errorPenalty")) ; //Config.errorPenalty = value; - else if (option.equals("gp.crossoverPercent")) - Config.GP.crossoverProbability = value / (double) 100; - else if (option.equals("gp.mutationPercent")) - Config.GP.mutationProbability = value / (double) 100; - else if (option.equals("gp.hillClimbingPercent")) - Config.GP.hillClimbingProbability = value / (double) 100; - else if (option.equals("gp.refinementPercent")) - Config.GP.refinementProbability = value / (double) 100; +// else if (option.equals("gp.crossoverPercent")) +// Config.GP.crossoverProbability = value / (double) 100; +// else if (option.equals("gp.mutationPercent")) +// Config.GP.mutationProbability = value / (double) 100; +// else if (option.equals("gp.hillClimbingPercent")) +// Config.GP.hillClimbingProbability = value / (double) 100; +// else if (option.equals("gp.refinementPercent")) +// Config.GP.refinementProbability = value / (double) 100; // else if (option.equals("refinement.horizontalExpansionFactor")) // Config.Refinement.horizontalExpansionFactor = value; else if (option.equals("percentPerLengthUnit")) @@ -419,8 +416,8 @@ ; // Config.una = Datastructures.strToBool(value); else if (option.equals("owa")) ; // Config.owa = Datastructures.strToBool(value); - else if (option.equals("gp.useFixedNumberOfGenerations")) - Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); +// else if (option.equals("gp.useFixedNumberOfGenerations")) +// Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); // else if (option.equals("scoreMethod")) { // if (value.equals("full")) // Config.scoreMethod = ScoreMethod.FULL; @@ -462,21 +459,21 @@ } else if (option.equals("digProtocolFile")) { // Config.digProtocolFile = new File(value); // } else if (option.equals("preprocessingModule")) { - // Config.preprocessingModule = value; - } else if (option.equals("gp.selectionType")) { - if (value.equals("fps")) - Config.GP.selectionType = SelectionType.FPS; - else if (value.equals("rankSelection")) - Config.GP.selectionType = SelectionType.RANK_SELECTION; - else - Config.GP.selectionType = SelectionType.TOURNAMENT_SELECTION; - } else if (option.equals("gp.algorithmType")) { - if (value.equals("steadyState")) - Config.GP.algorithmType = AlgorithmType.STEADY_STATE; - else - Config.GP.algorithmType = AlgorithmType.GENERATIONAL; - } else if (option.equals("gp.adc")) { - Config.GP.adc = Datastructures.strToBool(value); +// // Config.preprocessingModule = value; +// } else if (option.equals("gp.selectionType")) { +// if (value.equals("fps")) +// Config.GP.selectionType = SelectionType.FPS; +// else if (value.equals("rankSelection")) +// Config.GP.selectionType = SelectionType.RANK_SELECTION; +// else +// Config.GP.selectionType = SelectionType.TOURNAMENT_SELECTION; +// } else if (option.equals("gp.algorithmType")) { +// if (value.equals("steadyState")) +// Config.GP.algorithmType = AlgorithmType.STEADY_STATE; +// else +// Config.GP.algorithmType = AlgorithmType.GENERATIONAL; +// } else if (option.equals("gp.adc")) { +//// Config.GP.adc = Datastructures.strToBool(value); } else if (option.equals("refinement.heuristic")) { // if(value.equals("lexicographic")) // Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-11-12 15:13:50 UTC (rev 282) @@ -91,7 +91,7 @@ for(int i=0; i<numberOfTrees; i++) { // p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth); - p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth); + p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth, false); if(p.getFitness()>bestFitness) { bestFitness = p.getFitness(); bestScore = p.getScore(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-11-12 15:13:50 UTC (rev 282) @@ -20,22 +20,6 @@ package org.dllearner.algorithms.gp; -import static org.dllearner.Config.GP.algorithmType; -import static org.dllearner.Config.GP.crossoverProbability; -import static org.dllearner.Config.GP.elitism; -import static org.dllearner.Config.GP.generations; -import static org.dllearner.Config.GP.hillClimbingProbability; -import static org.dllearner.Config.GP.initMaxDepth; -import static org.dllearner.Config.GP.initMinDepth; -import static org.dllearner.Config.GP.mutationProbability; -import static org.dllearner.Config.GP.numberOfIndividuals; -import static org.dllearner.Config.GP.numberOfSelectedIndividuals; -import static org.dllearner.Config.GP.postConvergenceGenerations; -import static org.dllearner.Config.GP.refinementProbability; -import static org.dllearner.Config.GP.selectionType; -import static org.dllearner.Config.GP.tournamentSize; -import static org.dllearner.Config.GP.useFixedNumberOfGenerations; - import java.text.DecimalFormat; import java.util.Arrays; import java.util.Collection; @@ -45,10 +29,10 @@ import java.util.Set; import java.util.Map.Entry; -import org.dllearner.Config; import org.dllearner.algorithms.hybridgp.Psi; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; @@ -70,7 +54,7 @@ * */ public class GP extends LearningAlgorithm { - + // NumberFormat f; DecimalFormat df = new DecimalFormat("0.00"); @@ -103,6 +87,26 @@ FPS, TOURNAMENT_SELECTION}; + // configuration options + private SelectionType selectionType = SelectionType.RANK_SELECTION; + private int tournamentSize = 3; + private boolean elitism = true; + private AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; + private double mutationProbability = 0.03d; + private double crossoverProbability = 0.95d; + private double hillClimbingProbability = 0.0d; + private double refinementProbability = 0.0; + private int numberOfIndividuals = 100; + private int numberOfSelectedIndividuals = 96; + private boolean useFixedNumberOfGenerations = false; + private int generations = 20; + private int postConvergenceGenerations = 50; + private boolean adc = false; + private int initMinDepth = 4; + private int initMaxDepth = 6; + private int maxConceptLength = 75; +// private boolean useMultiStructures = true; + private Program[] individuals; private Program fittestIndividual; @@ -123,6 +127,8 @@ // private GeneticRefinementOperator psi; private Psi psi; + private ReasoningService rs; + /** * Creates an algorithm object. By default a steady state algorithm with * rank selection is used. This operates @@ -130,16 +136,17 @@ * 1.0 and a probability of mutation of 0.01. * */ - public GP(PosNegLP learningProblem) { + public GP(PosNegLP learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; + this.rs = rs; } - - public static Collection<Class<? extends LearningProblem>> supportedLearningAlgorithms() { + + public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); problems.add(PosNegLP.class); return problems; - } - + } + public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); StringConfigOption selectionType = new StringConfigOption("selectionType", "selection type", "rankSelection"); @@ -191,7 +198,7 @@ IntegerConfigOption max = new IntegerConfigOption("maxConceptLength", "maximum concept length (higher length means lowest possible fitness)", 75); max.setLowerLimit(1); options.add(max); - options.add(new BooleanConfigOption("useMultiStructures", "specifies whether to use e.g. (a AND b AND c) instead of ((A and b) and c) - there is no apparent reason to set this to false", true)); +// options.add(new BooleanConfigOption("useMultiStructures", "specifies whether to use e.g. (a AND b AND c) instead of ((A and b) and c) - there is no apparent reason to set this to false", true)); return options; } @@ -200,7 +207,53 @@ */ @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - // String name = entry.getOptionName(); + String name = entry.getOptionName(); + if(name.equals("selectionType")) { + String value = (String) entry.getValue(); + if(value.equals("fps")) + selectionType = SelectionType.FPS; + else if(value.equals("tournament")) + selectionType = SelectionType.TOURNAMENT_SELECTION; + else + selectionType = SelectionType.RANK_SELECTION; + } else if(name.equals("tournamentSize")) { + tournamentSize = (Integer) entry.getValue(); + } else if(name.equals("elitism")) { + elitism = (Boolean) entry.getValue(); + } else if(name.equals("algorithmType")) { + String value = (String) entry.getValue(); + if(value.equals("generational")) + algorithmType = AlgorithmType.GENERATIONAL; + else + algorithmType = AlgorithmType.STEADY_STATE; + } else if(name.equals("mutationProbability")) { + mutationProbability = (Double) entry.getValue(); + } else if(name.equals("crossoverProbability")) { + crossoverProbability = (Double) entry.getValue(); + } else if(name.equals("refinementProbability")) { + refinementProbability = (Double) entry.getValue(); + } else if(name.equals("hillClimbingProbability")) { + hillClimbingProbability = (Double) entry.getValue(); + } else if(name.equals("numberOfIndividuals")) { + numberOfIndividuals = (Integer) entry.getValue(); + } else if(name.equals("numberOfSelectedIndividuals")) { + numberOfSelectedIndividuals = (Integer) entry.getValue(); + } else if(name.equals("useFixedNumberOfGenerations")) { + useFixedNumberOfGenerations = (Boolean) entry.getValue(); + } else if(name.equals("generations")) { + generations = (Integer) entry.getValue(); + } else if(name.equals("postConvergenceGenerations")) { + postConvergenceGenerations = (Integer) entry.getValue(); + } else if(name.equals("adc")) { + adc = (Boolean) entry.getValue(); + } else if(name.equals("initMinDepth")) { + initMinDepth = (Integer) entry.getValue(); + } else if(name.equals("initMaxDepth")) { + initMaxDepth = (Integer) entry.getValue(); + } else if(name.equals("maxConceptLength")) { + maxConceptLength = (Integer) entry.getValue(); + } + } /* (non-Javadoc) @@ -208,6 +261,8 @@ */ @Override public void init() { + rs.prepareSubsumptionHierarchy(); + rs.prepareRoleHierarchy(); } @Override @@ -449,8 +504,8 @@ // alle Individuen auf maximale Konzeptlänge überprüfen um mögliche // Speicherprobleme zu verhindern for(int i=0; i<numberOfIndividuals; i++) { - if(individuals[i].getTree().getLength()>Config.GP.maxConceptLength) { - System.out.println("Warning: GP produced concept longer then " + Config.GP.maxConceptLength + ". Replacing it with TOP."); + if(individuals[i].getTree().getLength()>maxConceptLength) { + System.out.println("Warning: GP produced concept longer then " + maxConceptLength + ". Replacing it with TOP."); individuals[i] = GPUtilities.createProgram(learningProblem, new Top()); } } @@ -470,7 +525,7 @@ boolean betterValueFoundInPsiCache = false; double bestValue = bestScore.getScore(); - if(Config.GP.refinementProbability > 0) { + if(refinementProbability > 0) { // das Problem ist hier, dass die gecachte Score nicht unbedingt // der echten Score entsprechen muss, d.h. hier muss die // Konzeptlänge mit einberechnet werden => deswegen werden @@ -554,9 +609,9 @@ // int depth = rand.nextInt(initMaxDepth-initMinDepth)+initMinDepth; if(grow) - individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem,depth); + individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem,depth, adc); else - individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, depth); + individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, depth, adc); } /* @@ -809,7 +864,7 @@ System.out.println("Psi application time percentage: " + df.format(psiTimePercent) + "%; " + df.format(psiWOReasoningTimePercent) + "% excluding reasoning"); } - if(Config.GP.adc) + if(adc) System.out.println("ADC: " + fittestIndividual.getAdc()); // TODO: hier muss noch eine Zusammenfassung rein, die sowohl f�r zweiwertiges als auch // dreiwertiges Lernproblem funktioniert Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-11-12 15:13:50 UTC (rev 282) @@ -7,7 +7,6 @@ import java.util.SortedSet; import java.util.TreeMap; -import org.dllearner.Config; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.Score; @@ -16,8 +15,6 @@ import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Bottom; import org.dllearner.core.dl.Concept; -import org.dllearner.core.dl.Conjunction; -import org.dllearner.core.dl.Disjunction; import org.dllearner.core.dl.Exists; import org.dllearner.core.dl.FlatABox; import org.dllearner.core.dl.Individual; @@ -90,7 +87,7 @@ extendedHypothesis = hypothesis; Score score; - if(Config.GP.adc) + if(adc != null) // TODO: ADC-Support // score = learningProblem.computeScore(extendedHypothesis, adc); throw new RuntimeException("ADC not supported"); @@ -139,7 +136,7 @@ */ public static Program mutation(LearningProblem learningProblem, Program p) { mutation++; - if(Config.GP.adc) { + if(p.getAdc() != null) { // TODO: hier kann man noch mehr Feinabstimmung machen, d.h. // Mutation abh�ngig von Knotenanzahl if(Math.random()<0.5) { @@ -232,7 +229,7 @@ */ public static Program[] crossover(LearningProblem learningProblem, Program p1, Program p2) { crossover++; - if(Config.GP.adc) { + if(p1.getAdc() != null) { Concept[] pt; Program result[] = new Program[2]; @@ -318,7 +315,7 @@ // Knoten kopieren, damit er sich nicht ver�ndert (es wird sonst der // parent-Link ver�ndert) Concept treecloned = (Concept) p.getTree().clone(); - if(Config.GP.adc) + if(p.getAdc() != null) return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore()),p.getAdc()); else return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore())); @@ -424,20 +421,20 @@ // returnNode = new Disjunction(); // returnNode.addChild(new AtomicConcept(name)); // returnNode.addChild(node); - if(Config.GP.useMultiStructures) +// if(useMultiStructures) returnNode = new MultiDisjunction(new AtomicConcept(name),node); - else - returnNode = new Disjunction(new AtomicConcept(name),node); +// else +// returnNode = new Disjunction(new AtomicConcept(name),node); // wegen else if schlie�en sich die F�lle gegenseitig aus } else if(nr<sizeSum2) { name = bestNeighbours.get(2).get(nr-sizeSum1); // returnNode = new Conjunction(); // returnNode.addChild(new AtomicConcept(name)); // returnNode.addChild(node); - if(Config.GP.useMultiStructures) +// if(useMultiStructures) returnNode = new MultiConjunction(new AtomicConcept(name),node); - else - returnNode = new Conjunction(new AtomicConcept(name),node); +// else +// returnNode = new Conjunction(new AtomicConcept(name),node); } else if(nr<sizeSum3) { name = bestNeighbours.get(3).get(nr-sizeSum2); // returnNode = new Exists(new AtomicRole(name)); @@ -621,8 +618,8 @@ * @param depth Depth of the tree. * @return The created program. */ - public static Program createFullRandomProgram(LearningProblem learningProblem, int depth) { - if(Config.GP.adc) { + public static Program createFullRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC return createProgram(learningProblem, createFullRandomTree(learningProblem, depth, true), createFullRandomTree(learningProblem, depth, false)); @@ -644,15 +641,15 @@ if(nr == 0 || nr == 1) { Concept child2 = createFullRandomTree(learningProblem, depth-1, useADC); if(nr == 0) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiDisjunction(child1,child2); - else - return new Disjunction(child1,child2); +// else +// return new Disjunction(child1,child2); } else { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiConjunction(child1, child2); - else - return new Conjunction(child1, child2); +// else +// return new Conjunction(child1, child2); } } else if(nr==2) { return new Negation(child1); @@ -682,8 +679,8 @@ * @param depth The maximum depth of the program tree. * @return The created program. */ - public static Program createGrowRandomProgram(LearningProblem learningProblem, int depth) { - if(Config.GP.adc) { + public static Program createGrowRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC return createProgram(learningProblem, createGrowRandomTree(learningProblem,depth,true), createGrowRandomTree(learningProblem,depth,false)); @@ -773,15 +770,15 @@ else if(nr>=2 && nr < numberOfConcepts+2) return (AtomicConcept)learningProblem.getReasoningService().getAtomicConceptsList().get(nr-2).clone(); else if(nr==numberOfConcepts+2) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiConjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); - else - return new Conjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); +// else +// return new Conjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+3) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiDisjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); - else - return new Disjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); +// else +// return new Disjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+4) return new Negation(createGrowRandomTree(learningProblem, depth-1, useADC)); else if(nr>=numberOfConcepts+5 && nr<numberOfConcepts+5+numberOfRoles) Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-12 15:13:50 UTC (rev 282) @@ -165,6 +165,10 @@ Class<? extends LearningAlgorithm> laClass = null; if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) laClass = ROLearner.class; + else if(algorithmOption.getStringValue().equals("gp")) + laClass = GP.class; + else + handleError("Unknown value in " + algorithmOption); la = cm.learningAlgorithm(laClass, lp, rs); configureComponent(cm, la, componentPrefixMapping, parser); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-11-12 15:13:50 UTC (rev 282) @@ -329,6 +329,10 @@ return getRoleHierarchy().getMostSpecialRoles(); } + public void prepareSubsumptionHierarchy() { + reasoner.prepareSubsumptionHierarchy(getAtomicConcepts()); + } + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { reasoner.prepareSubsumptionHierarchy(allowedConcepts); } @@ -343,6 +347,10 @@ } } + public void prepareRoleHierarchy() { + prepareRoleHierarchy(getAtomicRoles()); + } + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { try { reasoner.prepareRoleHierarchy(allowedRoles); Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 15:13:50 UTC (rev 282) @@ -27,7 +27,6 @@ import java.util.Map; import java.util.SortedSet; -import org.dllearner.Config; import org.dllearner.ConfigurationManager; import org.dllearner.algorithms.gp.GP; import org.dllearner.core.ComponentManager; @@ -222,17 +221,17 @@ // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); } else if(algorithmNr==1) { // Config.algorithm = Algorithm.GP; - Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; - Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; - Config.GP.generations = 50; - Config.GP.useFixedNumberOfGenerations = true; - Config.GP.numberOfIndividuals = 201; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +//// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; // if(exampleNr == 3 || exampleNr == 4) // Config.GP.numberOfIndividuals = 51; - Config.GP.refinementProbability = 0; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.8; - Config.GP.hillClimbingProbability = 0; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; // Config.percentPerLengthUnit = 0.005; // give GP a chance to find the long solution of the // uncle problem @@ -242,17 +241,17 @@ learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); } else if(algorithmNr==2) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; - Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; - Config.GP.generations = 50; - Config.GP.useFixedNumberOfGenerations = true; - Config.GP.numberOfIndividuals = 201; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; //if(exampleNr == 3 || exampleNr == 4) // Config.GP.numberOfIndividuals = 51; - Config.GP.refinementProbability = 0.65; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.2; - Config.GP.hillClimbingProbability = 0; +// Config.GP.refinementProbability = 0.65; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.2; +// Config.GP.hillClimbingProbability = 0; // Config.percentPerLengthUnit = 0.005; // if(exampleNr == 3 || exampleNr==5 || exampleNr==6) // Config.percentPerLengthUnit = 0.002; @@ -438,36 +437,36 @@ if (j == 0) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.85; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.05; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.85; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.05; +// Config.GP.hillClimbingProbability = 0; } else if (j == 1) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.4; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.4; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.4; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.4; +// Config.GP.hillClimbingProbability = 0; } else if (j == 2) { // Config.algorithm = Algorithm.GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.8; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; } else if (j == 3) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.7; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.1; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.7; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.1; +// Config.GP.hillClimbingProbability = 0; } algorithmStartTime = System.nanoTime(); - gp = new GP(learningProblem); +// gp = new GP(learningProblem); long algorithmTime = System.nanoTime() - algorithmStartTime; long algorithmTimeSeconds = algorithmTime / 1000000000; @@ -475,16 +474,16 @@ // freigibt ((DIGReasoner) reasoner).releaseKB(); - int conceptLength = gp.getBestSolution().getLength(); - Score bestScore = gp.getSolutionScore(); - int misClassifications = bestScore.getCoveredNegatives().size() - + bestScore.getNotCoveredPositives().size(); - double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); +// int conceptLength = gp.getBestSolution().getLength(); +// Score bestScore = gp.getSolutionScore(); +// int misClassifications = bestScore.getCoveredNegatives().size() +// + bestScore.getNotCoveredPositives().size(); +// double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); +// +// statAr[j][0].addNumber(classificationRatePercent); +// statAr[j][1].addNumber(conceptLength); +// statAr[j][2].addNumber(algorithmTimeSeconds); - statAr[j][0].addNumber(classificationRatePercent); - statAr[j][1].addNumber(conceptLength); - statAr[j][2].addNumber(algorithmTimeSeconds); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |