From: <jen...@us...> - 2009-02-13 13:01:10
|
Revision: 1603 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1603&view=rev Author: jenslehmann Date: 2009-02-13 11:44:38 +0000 (Fri, 13 Feb 2009) Log Message: ----------- removed unused/unmaintained components and continued learning problem structure Modified Paths: -------------- trunk/lib/components.ini trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/FlexibleHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/LexicographicHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/NodeComparatorStable.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/SubsumptionComparator.java trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/gui/EBNodeTreeModel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/SearchTree.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java trunk/src/dl-learner/org/dllearner/test/SworeTest.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/utilities/JamonMonitorLogger.java trunk/src/dl-learner/org/dllearner/utilities/components/ComponentCombo.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLearner2.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java Modified: trunk/lib/components.ini =================================================================== --- trunk/lib/components.ini 2009-02-13 11:06:53 UTC (rev 1602) +++ trunk/lib/components.ini 2009-02-13 11:44:38 UTC (rev 1603) @@ -20,9 +20,7 @@ org.dllearner.algorithms.RandomGuesser org.dllearner.algorithms.BruteForceLearner org.dllearner.algorithms.refinement.ROLearner -org.dllearner.algorithms.refexamples.ExampleBasedROLComponent +org.dllearner.algorithms.refinement2.ROLComponent2 org.dllearner.algorithms.gp.GP -org.dllearner.algorithms.DBpediaNavigationSuggestor -org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm org.dllearner.algorithms.el.ELLearningAlgorithm org.dllearner.algorithms.celoe.CELOE Deleted: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2009-02-13 11:06:53 UTC (rev 1602) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -1,226 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner 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 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.algorithms; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.ComponentFactory; -import org.dllearner.core.configurators.DBpediaNavigationSuggestorConfigurator; -import org.dllearner.core.options.BooleanConfigOption; -import org.dllearner.core.options.CommonConfigOptions; -import org.dllearner.core.options.ConfigEntry; -import org.dllearner.core.options.ConfigOption; -import org.dllearner.core.options.DoubleConfigOption; -import org.dllearner.core.options.InvalidConfigOptionValueException; -import org.dllearner.core.options.StringConfigOption; -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.PosNegLPStandard; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyLP; -import org.dllearner.learningproblems.ScorePosNeg; - -/** - * The DBpedia Navigation suggestor takes a knowledge fragment extracted - * from DBpedia, performs some preprocessing steps, invokes a learning - * algorithm, and then performs postprocessing steps. It does not - * implement a completely new learning algorithm itself, but uses the - * example based refinement operator learning algorithm. - * - * TODO: This should not be implemented as a learning algorithm (as it does - * almost nothing by itself) and maybe can be completely deleted. - * - * @author Jens Lehmann - * - */ -public class DBpediaNavigationSuggestor extends LearningAlgorithm { - - private DBpediaNavigationSuggestorConfigurator configurator; - @Override - public DBpediaNavigationSuggestorConfigurator getConfigurator(){ - return configurator; - } - - -// private ReasonerComponent rs; - private ExampleBasedROLComponent learner; - private static String defaultSearchTreeFile = "log/searchTree.txt"; - - public DBpediaNavigationSuggestor(LearningProblem learningProblem, ReasonerComponent rs) { - super(learningProblem, rs); -// this.rs=rs; - this.configurator = new DBpediaNavigationSuggestorConfigurator(this); - try{ - if(learningProblem instanceof PosNegLP) { - PosNegLP lp = (PosNegLP) learningProblem; - this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs); - //this.learner=new ExampleBasedROLComponent(lp, rs); - } else if(learningProblem instanceof PosOnlyLP) { - PosOnlyLP lp = (PosOnlyLP) learningProblem; - this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs); - //this.learner=new ExampleBasedROLComponent(lp, rs); - } - }catch (Exception e) { - System.out.println("this error should never occur"+this.getClass().getCanonicalName()); - e.printStackTrace(); - } - } - - public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { - Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); - problems.add(LearningProblem.class); - return problems; - } - - public static String getName() { - return "DBpedia Navigation Suggestor"; - } - - public DBpediaNavigationSuggestor(PosOnlyLP learningProblem, ReasonerComponent rs) { - super(learningProblem, rs); - System.out.println("test1"); - } - - public DBpediaNavigationSuggestor(PosNegLPStandard learningProblem, ReasonerComponent rs) { - super(learningProblem, rs); - System.out.println("test2"); - } - - public static Collection<ConfigOption<?>> createConfigOptions() { - Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false)); - options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", defaultSearchTreeFile)); - options.add(new BooleanConfigOption("replaceSearchTree","specifies whether to replace the search tree in the log file after each run or append the new search tree", false)); - StringConfigOption heuristicOption = new StringConfigOption("heuristic", "specifiy the heuristic to use", "lexicographic"); - heuristicOption.setAllowedValues(new String[] {"lexicographic", "flexible"}); - options.add(heuristicOption); - options.add(new BooleanConfigOption("applyAllFilter", "usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D)", true)); - options.add(new BooleanConfigOption("applyExistsFilter", "usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D)", true)); - options.add(new BooleanConfigOption("useTooWeakList", "try to filter out too weak concepts without sending them to the reasoner", true)); - options.add(new BooleanConfigOption("useOverlyGeneralList", "try to find overly general concept without sending them to the reasoner", true)); - options.add(new BooleanConfigOption("useShortConceptConstruction", "shorten concept to see whether they already exist", true)); - DoubleConfigOption horizExp = new DoubleConfigOption("horizontalExpansionFactor", "horizontal expansion factor (see publication for description)", 0.6); - horizExp.setLowerLimit(0.0); - horizExp.setUpperLimit(1.0); - options.add(horizExp); - options.add(new BooleanConfigOption("improveSubsumptionHierarchy", "simplify subsumption hierarchy to reduce search space (see publication for description)", true)); - // allowed/ignored concepts/roles could also be a reasoner option (?) - options.add(CommonConfigOptions.allowedConcepts()); - options.add(CommonConfigOptions.ignoredConcepts()); - options.add(CommonConfigOptions.allowedRoles()); - options.add(CommonConfigOptions.ignoredRoles()); - options.add(CommonConfigOptions.useAllConstructor()); - options.add(CommonConfigOptions.useExistsConstructor()); - options.add(CommonConfigOptions.useCardinalityRestrictions()); - options.add(CommonConfigOptions.useHasValueConstructor()); - options.add(CommonConfigOptions.valueFreqencyThreshold()); - options.add(CommonConfigOptions.useNegation()); - options.add(CommonConfigOptions.useBooleanDatatypes()); - options.add(CommonConfigOptions.maxExecutionTimeInSeconds()); - options.add(CommonConfigOptions.minExecutionTimeInSeconds()); - options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); - options.add(CommonConfigOptions.getLogLevel()); - //TODO make a commonconfig Option out of this - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",0.0); - noisePercentage.setLowerLimit(0); - noisePercentage.setUpperLimit(100); - options.add(noisePercentage); - options.add(new StringConfigOption("startClass", "the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class)")); - options.add(new BooleanConfigOption("forceRefinementLengthIncrease", "specifies whether nodes should be expanded until only longer refinements are reached")); - return options; - } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) - */ - @Override - public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - learner.applyConfigEntry(entry); - } - - @Override - public void init() throws ComponentInitException { - learner.init(); - } - - @Override - public void start() { - learner.start(); - } - - @Override - public void stop() { - learner.stop(); - } - - @Override - public Description getCurrentlyBestDescription() { - return learner.getCurrentlyBestDescription(); - } - - @Override - public EvaluatedDescriptionPosNeg getCurrentlyBestEvaluatedDescription() { - return learner.getCurrentlyBestEvaluatedDescription(); - } - - @Override - public List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions){ - return learner.getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, accuracyThreshold, filterNonMinimalDescriptions); - } - -// @Override - public ScorePosNeg getSolutionScore() { - return learner.getSolutionScore(); - } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#pause() - */ - @Override - public void pause() { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#resume() - */ - @Override - public void resume() { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#isRunning() - */ - @Override - public boolean isRunning() { - // TODO Auto-generated method stub - return false; - } -} Deleted: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2009-02-13 11:06:53 UTC (rev 1602) +++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -1,128 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner 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 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.algorithms; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.SimpleSuggestionLearningAlgorithmConfigurator; -import org.dllearner.core.options.ConfigEntry; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Thing; -import org.dllearner.learningproblems.ScorePosNeg; - -/** - * Algorithm for getting "simple" suggestions, e.g. it tests some of the most likely candidates on whether - * they are solutions of a learning problem. - * - * @author Christian Kötteritzsch - * - */ -public class SimpleSuggestionLearningAlgorithm extends LearningAlgorithm implements Runnable { - - private SimpleSuggestionLearningAlgorithmConfigurator configurator; - @Override - public SimpleSuggestionLearningAlgorithmConfigurator getConfigurator(){ - return configurator; - } - -// private boolean stop = false; - private ScorePosNeg solutionScore; - private Description bestSollution; - private Set<Description> simpleSuggestions; - - public SimpleSuggestionLearningAlgorithm() { - super(null, null); - this.configurator = new SimpleSuggestionLearningAlgorithmConfigurator(this); - } - - @Override - public Description getCurrentlyBestDescription() { - return bestSollution; - } - - @Override - public EvaluatedDescriptionPosNeg getCurrentlyBestEvaluatedDescription() { - return new EvaluatedDescriptionPosNeg(bestSollution, solutionScore); - } - - public static String getName() { - return "simple suggestion algorithm"; - } - - @Override - public void stop() { -// stop = true; - } - - @Override - public void start() { - - } - - @Override - public <T> void applyConfigEntry(ConfigEntry<T> entry) { - - } - - @Override - public void init() { - - } - -// @Override - public ScorePosNeg getSolutionScore() { - return solutionScore; - } - - public void run() { - - } - - public Set<Description> getSimpleSuggestions(ReasonerComponent rs, Set<Individual> indi) { - // EXISTS property.TOP - // ESISTS hasChild - // EXISTS hasChild.male - simpleSuggestions = new HashSet<Description>(); - List<ObjectProperty> test = rs.getAtomicRolesList(); - while (test.iterator().hasNext()) { - test.iterator().next(); - Description d1 = new ObjectSomeRestriction(test.iterator().next(), new Thing()); - test.remove(rs.getAtomicRolesList().iterator().next()); - simpleSuggestions.add(d1); - } - return simpleSuggestions; - } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#isRunning() - */ - @Override - public boolean isRunning() { - // TODO Auto-generated method stub - return false; - } -} Property changes on: trunk/src/dl-learner/org/dllearner/algorithms/refinement2 ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedHeuristic.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedHeuristic.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package org.dllearner.algorithms.refexamples; +package org.dllearner.algorithms.refinement2; import java.util.Comparator; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -18,14 +18,14 @@ * */ -package org.dllearner.algorithms.refexamples; +package org.dllearner.algorithms.refinement2; import java.text.DecimalFormat; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; +import org.dllearner.core.configurators.ROLComponent2Configurator; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.utilities.owl.ConceptComparator; @@ -42,7 +42,7 @@ */ public class ExampleBasedNode { - private ExampleBasedROLComponentConfigurator configurator; + private ROLComponent2Configurator configurator; private static DecimalFormat df = new DecimalFormat(); @@ -75,7 +75,7 @@ // a flag whether this could be a solution for a posonly learning problem private boolean isPosOnlyCandidate = true; - public ExampleBasedNode(ExampleBasedROLComponentConfigurator configurator, Description concept) { + public ExampleBasedNode(ROLComponent2Configurator configurator, Description concept) { this.configurator = configurator; this.concept = concept; horizontalExpansion = 0; Deleted: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLComponent.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -1,494 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner 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 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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, see <http://www.gnu.org/licenses/>. - * - */ - -package org.dllearner.algorithms.refexamples; - -import java.io.File; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.dllearner.algorithms.EvaluatedDescriptionPosNeg; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; -import org.dllearner.core.options.BooleanConfigOption; -import org.dllearner.core.options.CommonConfigMappings; -import org.dllearner.core.options.CommonConfigOptions; -import org.dllearner.core.options.ConfigEntry; -import org.dllearner.core.options.ConfigOption; -import org.dllearner.core.options.DoubleConfigOption; -import org.dllearner.core.options.IntegerConfigOption; -import org.dllearner.core.options.InvalidConfigOptionValueException; -import org.dllearner.core.options.StringConfigOption; -import org.dllearner.core.owl.ClassHierarchy; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.learningproblems.PosOnlyLP; -import org.dllearner.learningproblems.ScorePosNeg; -import org.dllearner.reasoning.ReasonerType; -import org.dllearner.refinementoperators.RhoDRDown; -import org.dllearner.utilities.Files; -import org.dllearner.utilities.Helper; - -/** - * The DL-Learner learning algorithm component for the example - * based refinement operator approach. It handles all - * configuration options, creates the corresponding objects and - * passes them to the actual refinement operator, heuristic, and - * learning algorithm implementations. - * - * Note: The options supported by the ROLearner component and this - * one are not equal. Options that have been dropped for now: - * - horizontal expansion factor: The goal of the algorithm will - * be to (hopefully) be able to learn long and complex concepts - * more efficiently. - * A horizontal expansion factor has its benefits, but limits - * the length of concepts learnable in reasonable time to - * about 15 with its default value of 0.6 and a small sized - * background knowledge base. We hope to get more fine-grained - * control of whether it makes sense to extend a node with - * more sophisticated heuristics. - * Dropping the horizontal expansion factor means that the - * completeness of the algorithm depends on the heuristic. - * - * @author Jens Lehmann - * - */ -public class ExampleBasedROLComponent extends LearningAlgorithm { - - private ExampleBasedROLComponentConfigurator configurator; - @Override - public ExampleBasedROLComponentConfigurator getConfigurator(){ - return configurator; - } - - // actual algorithm - private ExampleBasedROLearner algorithm; - private static Logger logger = Logger - .getLogger(ExampleBasedROLComponent.class); - private String logLevel = CommonConfigOptions.logLevelDefault; - - // configuration options - private boolean writeSearchTree; - private File searchTreeFile; - private boolean replaceSearchTree = false; - private static String defaultSearchTreeFile = "log/searchTree.txt"; - private String heuristic = "multi"; - Set<NamedClass> allowedConcepts; - Set<ObjectProperty> allowedRoles; - Set<NamedClass> ignoredConcepts; - Set<ObjectProperty> ignoredRoles; - // these are computed as the result of the previous four settings - Set<NamedClass> usedConcepts; - Set<ObjectProperty> usedRoles; - private boolean applyAllFilter = true; - private boolean applyExistsFilter = true; - private boolean useTooWeakList = true; - private boolean useOverlyGeneralList = true; - private boolean useShortConceptConstruction = true; - private boolean improveSubsumptionHierarchy = true; - private boolean useAllConstructor = CommonConfigOptions.useAllConstructorDefault; - private boolean useExistsConstructor = CommonConfigOptions.useExistsConstructorDefault; - private boolean useHasValueConstructor = CommonConfigOptions.useHasValueConstructorDefault; - private int valueFrequencyThreshold = CommonConfigOptions.valueFrequencyThresholdDefault; - private boolean useCardinalityRestrictions = CommonConfigOptions.useCardinalityRestrictionsDefault; - private boolean useNegation = CommonConfigOptions.useNegationDefault; - private boolean useBooleanDatatypes = CommonConfigOptions.useBooleanDatatypesDefault; - private boolean useDoubleDatatypes = CommonConfigOptions.useDoubleDatatypesDefault; - private static double noisePercentageDefault = 0.0; - private double noisePercentage = noisePercentageDefault; - private NamedClass startClass = null; - //refactor this - private static boolean usePropernessChecksDefault = false; - private boolean usePropernessChecks = usePropernessChecksDefault; - // refactor this - private static int maxPosOnlyExpansionDefault = 4; - private int maxPosOnlyExpansion = maxPosOnlyExpansionDefault; - private boolean forceRefinementLengthIncrease = true; - //extended Options - //in seconds - private int maxExecutionTimeInSeconds = CommonConfigOptions.maxExecutionTimeInSecondsDefault; - private int minExecutionTimeInSeconds = CommonConfigOptions.minExecutionTimeInSecondsDefault; - private int guaranteeXgoodDescriptions = CommonConfigOptions.guaranteeXgoodDescriptionsDefault; - private int maxClassDescriptionTests = CommonConfigOptions.maxClassDescriptionTestsDefault; - - // Variablen zur Einstellung der Protokollierung - // boolean quiet = false; - boolean showBenchmarkInformation = false; - // boolean createTreeString = false; - // String searchTree = new String(); - - // Konfiguration des Algorithmus - // Faktor für horizontale Erweiterung (notwendig für completeness) - // double horizontalExpansionFactor = 0.6; - - // soll später einen Operator und eine Heuristik entgegennehmen - // public ROLearner(LearningProblem learningProblem, LearningProblem learningProblem2) { - public ExampleBasedROLComponent(PosNegLP learningProblem, ReasonerComponent reasoningService) { - super(learningProblem, reasoningService); - this.configurator = new ExampleBasedROLComponentConfigurator(this); - } - - public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasonerComponent reasoningService) { - super(learningProblem, reasoningService); - this.configurator = new ExampleBasedROLComponentConfigurator(this); - } - - public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { - Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); - problems.add(PosNegLP.class); - problems.add(PosOnlyDefinitionLP.class); - return problems; - } - - public static Collection<ConfigOption<?>> createConfigOptions() { - Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false)); - options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", defaultSearchTreeFile)); - options.add(new BooleanConfigOption("replaceSearchTree","specifies whether to replace the search tree in the log file after each run or append the new search tree", false)); - StringConfigOption heuristicOption = new StringConfigOption("heuristic", "specifiy the heuristic to use", "lexicographic"); - heuristicOption.setAllowedValues(new String[] {"lexicographic", "flexible"}); - options.add(heuristicOption); - options.add(new BooleanConfigOption("applyAllFilter", "usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D)", true)); - options.add(new BooleanConfigOption("applyExistsFilter", "usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D)", true)); - options.add(new BooleanConfigOption("useTooWeakList", "try to filter out too weak concepts without sending them to the reasoner", true)); - options.add(new BooleanConfigOption("useOverlyGeneralList", "try to find overly general concept without sending them to the reasoner", true)); - options.add(new BooleanConfigOption("useShortConceptConstruction", "shorten concept to see whether they already exist", true)); - DoubleConfigOption horizExp = new DoubleConfigOption("horizontalExpansionFactor", "horizontal expansion factor (see publication for description)", 0.6); - horizExp.setLowerLimit(0.0); - horizExp.setUpperLimit(1.0); - options.add(horizExp); - options.add(new BooleanConfigOption("improveSubsumptionHierarchy", "simplify subsumption hierarchy to reduce search space (see publication for description)", true)); - // allowed/ignored concepts/roles could also be a reasoner option (?) - options.add(CommonConfigOptions.allowedConcepts()); - options.add(CommonConfigOptions.ignoredConcepts()); - options.add(CommonConfigOptions.allowedRoles()); - options.add(CommonConfigOptions.ignoredRoles()); - options.add(CommonConfigOptions.useAllConstructor()); - options.add(CommonConfigOptions.useExistsConstructor()); - options.add(CommonConfigOptions.useHasValueConstructor()); - options.add(CommonConfigOptions.valueFreqencyThreshold()); - options.add(CommonConfigOptions.useCardinalityRestrictions()); - options.add(CommonConfigOptions.cardinalityLimit()); - options.add(CommonConfigOptions.useNegation()); - options.add(CommonConfigOptions.useBooleanDatatypes()); - options.add(CommonConfigOptions.useDoubleDatatypes()); - options.add(CommonConfigOptions.maxExecutionTimeInSeconds()); - options.add(CommonConfigOptions.minExecutionTimeInSeconds()); - options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); - options.add(CommonConfigOptions.maxClassDescriptionTests()); - options.add(CommonConfigOptions.getLogLevel()); - options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault)); - options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" + - " considered as solution candidate",maxPosOnlyExpansionDefault)); - options.add(CommonConfigOptions.getNoisePercentage()); - options.add(CommonConfigOptions.getTerminateOnNoiseReached()); - options.add(new StringConfigOption("startClass", "the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class)")); - options.add(new BooleanConfigOption("forceRefinementLengthIncrease", "specifies whether nodes should be expanded until only longer refinements are reached")); - options.add(new DoubleConfigOption("negativeWeight", "Used to penalise errors on negative examples different from those of positive examples (lower = less importance for negatives).",1.0)); - options.add(new DoubleConfigOption("startNodeBonus", "You can use this to give a heuristic bonus on the start node (= initially broader exploration of search space).",0.0)); - options.add(new IntegerConfigOption("negationPenalty", "Penalty on negations (TODO: better explanation).", 0)); - options.add(CommonConfigOptions.getExpansionPenaltyFactor(0.02)); - return options; - } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) - */ - @Override - @SuppressWarnings({"unchecked"}) - public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - String name = entry.getOptionName(); - if(name.equals("writeSearchTree")) - writeSearchTree = (Boolean) entry.getValue(); - else if(name.equals("searchTreeFile")) - searchTreeFile = new File((String)entry.getValue()); - else if(name.equals("replaceSearchTree")) - replaceSearchTree = (Boolean) entry.getValue(); - else if(name.equals("heuristic")) { - String value = (String) entry.getValue(); - if(value.equals("lexicographic")) - heuristic = "lexicographic"; - else - heuristic = "flexible"; - } else if(name.equals("allowedConcepts")) { - allowedConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); - } else if(name.equals("allowedRoles")) { - allowedRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); - } else if(name.equals("ignoredConcepts")) { - ignoredConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); - } else if(name.equals("ignoredRoles")) { - ignoredRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); - } else if(name.equals("applyAllFilter")) { - applyAllFilter = (Boolean) entry.getValue(); - } else if(name.equals("applyExistsFilter")) { - applyExistsFilter = (Boolean) entry.getValue(); - } else if(name.equals("useTooWeakList")) { - useTooWeakList = (Boolean) entry.getValue(); - } else if(name.equals("useOverlyGeneralList")) { - useOverlyGeneralList = (Boolean) entry.getValue(); - } else if(name.equals("useShortConceptConstruction")) { - useShortConceptConstruction = (Boolean) entry.getValue(); - } else if(name.equals("improveSubsumptionHierarchy")) { - improveSubsumptionHierarchy = (Boolean) entry.getValue(); - } else if(name.equals("useAllConstructor")) { - useAllConstructor = (Boolean) entry.getValue(); - } else if(name.equals("useExistsConstructor")) { - useExistsConstructor = (Boolean) entry.getValue(); - } else if(name.equals("useHasValueConstructor")) { - useHasValueConstructor = (Boolean) entry.getValue(); - } else if(name.equals("valueFrequencyThreshold")) { - valueFrequencyThreshold = (Integer) entry.getValue(); - } else if(name.equals("useCardinalityRestrictions")) { - useCardinalityRestrictions = (Boolean) entry.getValue(); - } else if(name.equals("useNegation")) { - useNegation = (Boolean) entry.getValue(); - } else if(name.equals("noisePercentage")) { - noisePercentage = (Double) entry.getValue(); - } else if(name.equals("useBooleanDatatypes")) { - useBooleanDatatypes = (Boolean) entry.getValue(); - } else if(name.equals("useDoubleDatatypes")) { - useDoubleDatatypes = (Boolean) entry.getValue(); - } else if(name.equals("usePropernessChecks")) { - usePropernessChecks = (Boolean) entry.getValue(); - } else if(name.equals("maxPosOnlyExpansion")) { - maxPosOnlyExpansion = (Integer) entry.getValue(); - } else if(name.equals("startClass")) { - startClass = new NamedClass((String)entry.getValue()); - }else if(name.equals("maxExecutionTimeInSeconds")) { - maxExecutionTimeInSeconds = (Integer) entry.getValue(); - }else if(name.equals("minExecutionTimeInSeconds")) { - minExecutionTimeInSeconds = (Integer) entry.getValue(); - }else if(name.equals("guaranteeXgoodDescriptions")) { - guaranteeXgoodDescriptions = (Integer) entry.getValue(); - } else if(name.equals("maxClassDescriptionTests")) { - maxClassDescriptionTests = (Integer) entry.getValue(); - } else if(name.equals("logLevel")) { - logLevel = ((String)entry.getValue()).toUpperCase(); - } else if(name.equals("forceRefinementLengthIncrease")) { - forceRefinementLengthIncrease = (Boolean) entry.getValue(); - } - } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#init() - */ - @Override - public void init() throws ComponentInitException { - - // exit with a ComponentInitException if the reasoner is unsupported for this learning algorithm - if(reasoner.getReasonerType() == ReasonerType.DIG) { - throw new ComponentInitException("DIG does not support the inferences needed in the selected learning algorithm component: " + getName()); - } - - // set log level if the option has been set - if(!logLevel.equals(CommonConfigOptions.logLevelDefault)) - logger.setLevel(Level.toLevel(logLevel,Level.toLevel(CommonConfigOptions.logLevelDefault))); - - if(searchTreeFile == null) - searchTreeFile = new File(defaultSearchTreeFile); - - if(writeSearchTree) - Files.clearFile(searchTreeFile); - - // adjust heuristic - ExampleBasedHeuristic algHeuristic; - - if(heuristic == "lexicographic") - algHeuristic = new LexicographicHeuristic(); - else if(heuristic == "flexible") { - if(learningProblem instanceof PosOnlyDefinitionLP) { - throw new RuntimeException("does not work with positive examples only yet"); - } - algHeuristic = new FlexibleHeuristic(((PosNegLP)learningProblem).getNegativeExamples().size(), ((PosNegLP)learningProblem).getPercentPerLengthUnit()); - } else { - if(learningProblem instanceof PosOnlyLP) { -// throw new RuntimeException("does not work with positive examples only yet"); - algHeuristic = new MultiHeuristic(((PosOnlyLP)learningProblem).getPositiveExamples().size(),0, configurator); - } else { - algHeuristic = new MultiHeuristic(((PosNegLP)learningProblem).getPositiveExamples().size(),((PosNegLP)learningProblem).getNegativeExamples().size(), configurator); - } - } - - // compute used concepts/roles from allowed/ignored - // concepts/roles - if(allowedConcepts != null) { - // sanity check to control if no non-existing concepts are in the list - Helper.checkConcepts(reasoner, allowedConcepts); - usedConcepts = allowedConcepts; - } else if(ignoredConcepts != null) { - usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoner, ignoredConcepts); - } else { - usedConcepts = Helper.computeConcepts(reasoner); - } - - if(allowedRoles != null) { - Helper.checkRoles(reasoner, allowedRoles); - usedRoles = allowedRoles; - } else if(ignoredRoles != null) { - Helper.checkRoles(reasoner, ignoredRoles); - usedRoles = Helper.difference(reasoner.getObjectProperties(), ignoredRoles); - } else { - usedRoles = reasoner.getObjectProperties(); - } - - // prepare subsumption and role hierarchies, because they are needed - // during the run of the algorithm; - // in contrast to before, the learning algorithms have to maintain their - // own view on the class hierarchy - ClassHierarchy classHierarchy = reasoner.getClassHierarchy().cloneAndRestrict(usedConcepts); - if(improveSubsumptionHierarchy) - classHierarchy.thinOutSubsumptionHierarchy(); - -// reasoner.prepareRoleHierarchy(usedRoles); - // prepare datatype hierarchy only if necessary -// if(reasoner.hasDatatypeSupport()) -// reasoner.prepareDatatypePropertyHierarchy(); - - // create a refinement operator and pass all configuration - // variables to it - RhoDRDown operator = new RhoDRDown( - reasoner, - classHierarchy, - configurator, - applyAllFilter, - applyExistsFilter, - useAllConstructor, - useExistsConstructor, - useHasValueConstructor, - valueFrequencyThreshold, - useCardinalityRestrictions, - useNegation, - useBooleanDatatypes, - useDoubleDatatypes, - startClass - ); - - // create an algorithm object and pass all configuration - // options to it - algorithm = new ExampleBasedROLearner( - configurator, - learningProblem, - reasoner, - operator, - algHeuristic, - startClass, - // usedConcepts, - // usedRoles, - noisePercentage/(double)100, - writeSearchTree, - replaceSearchTree, - searchTreeFile, - useTooWeakList, - useOverlyGeneralList, - useShortConceptConstruction, - usePropernessChecks, - maxPosOnlyExpansion, - maxExecutionTimeInSeconds, - minExecutionTimeInSeconds, - guaranteeXgoodDescriptions, - maxClassDescriptionTests, - forceRefinementLengthIncrease - ); - // note: used concepts and roles do not need to be passed - // as argument, because it is sufficient to prepare the - // concept and role hierarchy accordingly - } - - public static String getName() { - return "refinement operator based learning algorithm II"; - } - - public static String getUsage() { - return "algorithm = refexamples;"; - } - - @Override - public void start() { - algorithm.start(); - } - -// @Override - public ScorePosNeg getSolutionScore() { - return algorithm.getSolutionScore(); - } - - @Override - public Description getCurrentlyBestDescription() { - return algorithm.getBestSolution(); - } - - @Override - public synchronized List<Description> getCurrentlyBestDescriptions() { - return algorithm.getCurrentlyBestDescriptions(); - } - - @Override - public EvaluatedDescriptionPosNeg getCurrentlyBestEvaluatedDescription() { - return new EvaluatedDescriptionPosNeg(algorithm.getBestSolution(),algorithm.getSolutionScore()); - } - - @Override - public synchronized SortedSet<EvaluatedDescriptionPosNeg> getCurrentlyBestEvaluatedDescriptions() { - return algorithm.getCurrentlyBestEvaluatedDescriptions(); - } - - /** {@inheritDoc} */ - @Override - public void stop() { - algorithm.stop(); - } - - public ExampleBasedNode getStartNode() { - return algorithm.getStartNode(); - } - - /** {@inheritDoc} */ - @Override - public void pause() { - // TODO: not implemented - } - - /** {@inheritDoc} */ - @Override - public void resume() { - // TODO: not implemented - } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#isRunning() - */ - /** {@inheritDoc} */ - @Override - public boolean isRunning() { - return algorithm.isRunning(); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedROLearner.java 2009-02-13 11:44:38 UTC (rev 1603) @@ -1,1531 +0,0 @@ -/** - * Copyright (C) 2007-2009, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner 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 3 of the License, or - * (at your option) any later version. - * - * DL-Learner 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, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.algorithms.refexamples; - -import java.io.File; -import java.text.DecimalFormat; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.concurrent.ConcurrentSkipListSet; - -import org.apache.log4j.Logger; -import org.dllearner.algorithms.EvaluatedDescriptionPosNeg; -import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Thing; -import org.dllearner.core.owl.Union; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.learningproblems.ScorePosNeg; -import org.dllearner.refinementoperators.RefinementOperator; -import org.dllearner.refinementoperators.RhoDRDown; -import org.dllearner.utilities.Files; -import org.dllearner.utilities.Helper; -import org.dllearner.utilities.JamonMonitorLogger; -import org.dllearner.utilities.owl.ConceptComparator; -import org.dllearner.utilities.owl.ConceptTransformation; -import org.dllearner.utilities.owl.EvaluatedDescriptionPosNegComparator; - -import com.jamonapi.Monitor; - -/** - * Implements the 2nd version of the refinement operator based learning approach. - * - * @author Jens Lehmann - * - */ -public class ExampleBasedROLearner { - - private static Logger logger = Logger.getLogger(ExampleBasedROLearner.class); - private ExampleBasedROLComponentConfigurator configurator; - - // basic setup: learning problem and reasoning service - private ReasonerComponent rs; - // often the learning problems needn't be accessed directly; instead - // use the example sets below and the posonly variable - private PosNegLP learningProblem; - private PosOnlyDefinitionLP posOnlyLearningProblem; - private Description startDescription; - private boolean posOnly = false; - private int nrOfExamples; - private int nrOfPositiveExamples; - private Set<Individual> positiveExamples; - private int nrOfNegativeExamples; - private Set<Individual> negativeExamples; - - // noise regulates how many positives can be misclassified and when the - // algorithm terminates - private double noise = 0.0; - private int allowedMisclassifications = 0; - - // positive only learning options: - // if no negatives are given, then one possible strategy is to find a very - // special concept still entailing all positive examples; - // this is realised by changing the termination criterion: a concept is a - // solution if it has been expanded x times (x is - // configurable) but no more special concept is found (all are either - // equivalent or too weak) - private int maxPosOnlyExpansion; - - // search tree options - private boolean writeSearchTree; - private File searchTreeFile; - private boolean replaceSearchTree = false; - - // constructs to improve performance - private boolean useTooWeakList = true; - private boolean useOverlyGeneralList = true; - private boolean useShortConceptConstruction = true; - - // extended Options - private long maxExecutionTimeInSeconds; - private boolean maxExecutionTimeAlreadyReached = false; - private long minExecutionTimeInSeconds = 0; - private boolean minExecutionTimeAlreadyReached = false; - private int guaranteeXgoodDescriptions = 1; - private boolean guaranteeXgoodAlreadyReached = false; - private int maxClassDescriptionTests; - - // if set to false we do not test properness; this may seem wrong - // but the disadvantage of properness testing are additional reasoner - // queries and a search bias towards ALL r.something because - // ALL r.TOP is improper and automatically expanded further - private boolean usePropernessChecks = false; - - // tree traversal means to run through the most promising concepts - // and connect them in an intersection to find a solution - // (this is called irregularly e.g. every 100 seconds) - private boolean useTreeTraversal = false; - - // if this variable is set to true, then the refinement operator - // is applied until all concept of equal length have been found - // e.g. TOP -> A1 -> A2 -> A3 is found in one loop; the disadvantage - // are potentially more method calls, but the advantage is that - // the algorithm is better in locating relevant concept in the - // subsumption hierarchy (otherwise, if the most general concept - // is not promising, it may never get expanded) - private boolean forceRefinementLengthIncrease; - - // candidate reduction: using this mechanism we can simulate - // the divide&conquer approach in many ILP programs using a - // clause by clause search; after a period of time the candidate - // set is reduced to focus CPU time on the most promising concepts - private boolean useCandidateReduction = true; - private int candidatePostReductionSize = 30; - - // setting to true gracefully stops the algorithm - private boolean stop = false; - private boolean isRunning = false; - - // node from which algorithm has started - private ExampleBasedNode startNode; - - // solution protocol - // TODO isn't solution found already true if solutions.size()>=0 ??? - @Deprecated - private boolean solutionFound = false; - private List<Description> solutions = new LinkedList<Description>(); - - // used refinement operator and heuristic (exchangeable) - private RhoDRDown operator; - // private RefinementOperator operator; - // private ExampleBasedHeuristic heuristic; - - // specifies whether to compute and log benchmark information - private boolean computeBenchmarkInformation = false; - - // comparator used to maintain a stable ordering of nodes, i.e. - // an ordering which does not change during the run of the algorithm - private NodeComparatorStable nodeComparatorStable = new NodeComparatorStable(); - // stable candidate set; it has no functional part in the algorithm, - // but is a list of the currently best concepts found; - // it is very important to use a concurrent set here as other threads will - // access it (usual iterating is likely to throw a ConcurrentModificationException) - private NavigableSet<ExampleBasedNode> candidatesStable = new ConcurrentSkipListSet<ExampleBasedNode>( - nodeComparatorStable); - // evaluated descriptions -// private EvaluatedDescriptionSet evaluatedDescriptions = new EvaluatedDescriptionSet(LearningAlgorithm.MAX_NR_OF_RESULTS); - - // comparator used to create ordered sets of concepts - private ConceptComparator conceptComparator = new ConceptComparator(); - // comparator for evaluated descriptions - private EvaluatedDescriptionPosNegComparator edComparator = new EvaluatedDescriptionPosNegComparator(); - - // utility variables - private DecimalFormat df = new DecimalFormat(); - - // candidates for refinement (used for directly accessing - // nodes in the search tree) - private TreeSet<ExampleBasedNode> candidates; - - // new nodes found during a run of the algorithm - private List<ExampleBasedNode> newCandidates = new LinkedList<ExampleBasedNode>(); - - // all concepts which have been evaluated as being proper refinements - private SortedSet<Description> properRefinements = new TreeSet<Description>(conceptComparator); - - // blacklists - private SortedSet<Description> tooWeakList = new TreeSet<Description>(conceptComparator); - private SortedSet<Description> overlyGeneralList = new TreeSet<Description>(conceptComparator); - - // set of expanded nodes (TODO: better explanation) - TreeSet<ExampleBasedNode> expandedNodes = new TreeSet<ExampleBasedNode>(nodeComparatorStable); - - // statistic variables - private int maxRecDepth = 0; - private int maxNrOfRefinements = 0; - private int maxNrOfChildren = 0; - private int redundantConcepts = 0; - private int propernessTestsReasoner = 0; - private int propernessTestsAvoidedByShortConceptConstruction = 0; - private int propernessTestsAvoidedByTooWeakList = 0; - private int conceptTestsTooWeakList = 0; - private int conceptTestsOverlyGeneralList = 0; - private int conceptTestsReasoner = 0; - - // time variables - private long runtime; - private long algorithmStartTime; - private long propernessCalcTimeNs = 0; - private long propernessCalcReasoningTimeNs = 0; - private long childConceptsDeletionTimeNs = 0; - private long refinementCalcTimeNs = 0; - private long redundancyCheckTimeNs = 0; - private long evaluateSetCreationTimeNs = 0; - private long improperConceptsRemovalTimeNs = 0; - - // prefixes - private String baseURI; - private Map<String, String> prefixes; - - public ExampleBasedROLearner( - ExampleBasedROLComponentConfigurator configurator, - LearningProblem learningProblem, - ReasonerComponent rs, - RefinementOperator operator, - ExampleBasedHeuristic heuristic, - Description startDescription, - // Set<AtomicConcept> allowedConcepts, - // Set<AtomicRole> allowedRoles, - double noise, boolean writeSearchTree, boolean replaceSearchTree, File searchTreeFile, - boolean useTooWeakList, boolean useOverlyGeneralList, - boolean useShortConceptConstruction, boolean usePropernessChecks, - int maxPosOnlyExpansion, int maxExecutionTimeInSeconds, int minExecutionTimeInSeconds, - int guaranteeXgoodDescriptions, int maxClassDescriptionTests, boolean forceRefinementLengthIncrease) { - - if (learningProblem instanceof PosNegLP) { - PosNegLP lp = (PosNegLP) learningProblem; - this.learningProblem = lp; - posOnly = false; - positiveExamples = lp.getPositiveExamples(); - negativeExamples = lp.getNegativeExamples(); - nrOfPositiveExamples = positiveExamples.size(); - nrOfNegativeExamples = negativeExamples.size(); - - // System.out.println(nrOfPositiveExamples); - // System.out.println(nrOfNegativeExamples); - // System.exit(0); - - } else if (learningProblem instanceof PosOnlyDefinitionLP) { - PosOnlyDefinitionLP lp = (PosOnlyDefinitionLP) learningProblem; - this.posOnlyLearningProblem = lp; - posOnly = true; - positiveExamples = lp.getPositiveExamples(); - negativeExamples = new TreeSet<Individual>(); - nrOfPositiveExamples = lp.getPositiveExamples().size(); - // nrOfNegativeExamples = lp.getPseudoNegatives().size(); - nrOfNegativeExamples = 0; - } - this.configurator = configurator; - nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; - this.rs = rs; - this.operator = (RhoDRDown) operator; - this.startDescription = startDescription; - // initialise candidate set with heuristic as ordering - candidates = new TreeSet<ExampleBasedNode>(heuristic); - this.noise = noise; - this.writeSearchTree = writeSearchTree; - this.replaceSearchTree = replaceSearchTree; - this.searchTreeFile = searchTreeFile; - this.useTooWeakList = useTooWeakList; - this.useOverlyGeneralList = useOverlyGeneralList; - this.useShortConceptConstruction = useShortConceptConstruction; - this.usePropernessChecks = usePropernessChecks; - baseURI = rs.getBaseURI(); - prefixes = rs.getPrefixes(); - this.maxPosOnlyExpansion = maxPosOnlyExpansion; - this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; - this.minExecutionTimeInSeconds = minExecutionTimeInSeconds; - this.guaranteeXgoodDescriptions = guaranteeXgoodDescriptions; - this.maxClassDescriptionTests = maxClassDescriptionTests; - this.forceRefinementLengthIncrease = forceRefinementLengthIncrease; - - // logger.setLevel(Level.DEBUG); - } - - public void start() { - stop = false; - isRunning = true; - runtime = System.currentTimeMillis(); - - // reset values (algorithms may be started several times) - candidates.clear(); - candidatesStable.clear(); - newCandidates.clear(); - solutionFound = false; - solutions.clear(); - maxExecutionTimeAlreadyReached = false; - minExecutionTimeAlreadyReached = false; - guaranteeXgoodAlreadyReached = false; - propernessTestsReasoner = 0; - propernessTestsAvoidedByShortConceptConstruction = 0; - propernessTestsAvoidedByTooWeakList = 0; - conceptTestsTooWeakList = 0; - conceptTestsOverlyGeneralList = 0; - propernessCalcTimeNs = 0; - propernessCalcReasoningTimeNs = 0; - childConceptsDeletionTimeNs = 0; - refinementCalcTimeNs = 0; - redundancyCheckTimeNs = 0; - evaluateSetCreationTimeNs = 0; - improperConceptsRemovalTimeNs = 0; - - Monitor totalLearningTime = JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime") - .start(); - // TODO: write a JUnit test for this problem (long-lasting or infinite - // loops because - // redundant children of a node are called recursively when a node is - // extended - // twice) - /* - * // String conceptStr = - * "(\"http://dl-learner.org/carcinogenesis#Compound\" AND (>= 2 - * \"http://dl-learner.org/carcinogenesis#hasStructure\".\"http://dl-learner.org/carcinogenesis#Ar_halide\" - * OR ((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS - * TRUE) AND >= 5 \"http://dl-learner.org/carcinogenesis#hasBond\". - * TOP)))"; // String conceptStr = - * "(\"http://dl-learner.org/carcinogenesis#Compound\" AND - * ((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS TRUE) - * AND (\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS - * TRUE)))"; String conceptStr = - * "(\"http://dl-learner.org/carcinogenesis#Compound\" AND (>= 3 - * \"http://dl-learner.org/carcinogenesis#hasStructure\".\"http://dl-learner.org/carcinogenesis#Halide\" - * OR ((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS - * TRUE) AND ALL - * \"http://dl-learner.org/carcinogenesis#hasAtom\".TOP)))"; String - * conceptStr2 = "(\"http://dl-learner.org/carcinogenesis#Compound\" AND - * (>= 4 - * \"http://dl-learner.org/carcinogenesis#hasStructure\".\"http://dl-learner.org/carcinogenesis#Halide\" - * OR ((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS - * TRUE) AND ALL - * \"http://dl-learner.org/carcinogenesis#hasAtom\".TOP)))"; try { - * NamedClass struc = new - * NamedClass("http://dl-learner.org/carcinogenesis#Compound"); - * Description d = KBParser.parseConcept(conceptStr); Description d2 = - * KBParser.parseConcept(conceptStr2); // SortedSet<Description> ds = - * (SortedSet<Description>) operator.refine(d,15,null,struc); // - * System.out.println(ds); - * // System.out.println(RhoDRDown.checkIntersection((Intersection)d)); - * - * - * Set<Individual> coveredNegatives = rs.instanceCheck(d, - * learningProblem.getNegativeExamples()); Set<Individual> - * coveredPositives = rs.instanceCheck(d, - * learningProblem.getPositiveExamples()); ExampleBasedNode ebn = new - * ExampleBasedNode(d); ebn.setCoveredExamples(coveredPositives, - * coveredNegatives); - * - * properRefinements.add(d2); extendNodeProper(ebn,13); - * extendNodeProper(ebn,14); for(Description refinement: - * ebn.getChildConcepts()) System.out.println("refinement: " + - * refinement); - * // Individual i = new - * Individual("http://dl-learner.org/carcinogenesis#d101"); // - * for(Individual i : learningProblem.getPositiveExamples()) // - * rs.instanceCheck(ds.last(), i); - * - * System.out.println("finished"); } catch (ParseException e) { // TODO - * Auto-generated catch block e.printStackTrace(); } System.exit(0); - */ - - // calculate quality threshold required for a solution - allowedMisclassifications = (int) Math.round(noise ... [truncated message content] |