From: <jen...@us...> - 2009-02-16 13:03:55
|
Revision: 1605 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1605&view=rev Author: jenslehmann Date: 2009-02-16 13:03:46 +0000 (Mon, 16 Feb 2009) Log Message: ----------- continued ontology engineering algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLearner2.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/core/Score.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.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/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/EvaluatedDescriptionClass.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicStable.java Added: trunk/src/dl-learner/org/dllearner/algorithms/EvaluatedDescriptionClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/EvaluatedDescriptionClass.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/EvaluatedDescriptionClass.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -0,0 +1,43 @@ +/** + * 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; + +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.owl.Description; +import org.dllearner.learningproblems.ClassScore; + +/** + * An evaluated description for learning classes in ontologies. + * + * @author Jens Lehmann + * + */ +public class EvaluatedDescriptionClass extends EvaluatedDescription { + + /** + * Constructs an evaluated description for learning classes in ontologies. + * @param description Description. + * @param score Score of description. + */ + public EvaluatedDescriptionClass(Description description, ClassScore score) { + super(description, score); + } + +} Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -19,13 +19,33 @@ */ package org.dllearner.algorithms.celoe; -import org.dllearner.algorithms.EvaluatedDescriptionPosNeg; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.Logger; 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.CELOEConfigurator; import org.dllearner.core.configurators.Configurator; +import org.dllearner.core.options.CommonConfigOptions; +import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.refinementoperators.RefinementOperator; +import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.EvaluatedDescriptionSet; /** * The CELOE (Class Expression Learner for Ontology Engineering) algorithm. @@ -37,71 +57,195 @@ */ public class CELOE extends LearningAlgorithm { + private static Logger logger = Logger.getLogger(CELOE.class); + private CELOEConfigurator configurator; + + private boolean isRunning = false; + private boolean stop = false; + +// private OEHeuristicStable heuristicStable = new OEHeuristicStable(); +// private OEHeuristicRuntime heuristicRuntime = new OEHeuristicRuntime(); + + private RefinementOperator operator; + + // all nodes in the search tree (used for selecting most promising node) + private TreeSet<OENode> nodes; + // root of search tree + private OENode startNode; + + // all descriptions in the search tree plus those which were too weak (for fast redundancy check) + private TreeSet<Description> descriptions; + + private EvaluatedDescriptionSet bestEvaluatedDescriptions = new EvaluatedDescriptionSet(LearningAlgorithm.MAX_NR_OF_RESULTS); + + private NamedClass classToDescribe; + private boolean isEquivalenceProblem; + + private long nanoStartTime; + + // important parameters + private double minAcc; + + @Override + public Configurator getConfigurator() { + return configurator; + } + public CELOE(ClassLearningProblem problem, ReasonerComponent reasoner) { super(problem, reasoner); + classToDescribe = problem.getClassToDescribe(); + isEquivalenceProblem = problem.isEquivalenceProblem(); } - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#getCurrentlyBestDescription() - */ + public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { + Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); + problems.add(ClassLearningProblem.class); + return problems; + } + + public static Collection<ConfigOption<?>> createConfigOptions() { + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + 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.getNoisePercentage()); + return options; + } + + public static String getName() { + return "CELOE"; + } + @Override - public Description getCurrentlyBestDescription() { - // TODO Auto-generated method stub - return null; + public void init() throws ComponentInitException { + // copy class hierarchy and modify it such that each class is only + // reachable via a single path + ClassHierarchy classHierarchy = reasoner.getClassHierarchy().clone(); + classHierarchy.thinOutSubsumptionHierarchy(); + + // create refinement operator + operator = new RhoDRDown(reasoner, classHierarchy, configurator); + + // we put important parameters in class variables + minAcc = configurator.getNoisePercentage()/100d; } - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#getCurrentlyBestEvaluatedDescription() - */ @Override - public EvaluatedDescriptionPosNeg getCurrentlyBestEvaluatedDescription() { - // TODO Auto-generated method stub - return null; + public Description getCurrentlyBestDescription() { + return getCurrentlyBestEvaluatedDescription().getDescription(); } - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#isRunning() - */ @Override - public boolean isRunning() { - // TODO Auto-generated method stub - return false; + public List<Description> getCurrentlyBestDescriptions() { + return bestEvaluatedDescriptions.toDescriptionList(); } - - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#start() - */ + @Override + public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { + return bestEvaluatedDescriptions.getSet().last(); + } + + @Override + public SortedSet<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { + return bestEvaluatedDescriptions.getSet(); + } + + @Override public void start() { - // TODO Auto-generated method stub - + stop = false; + isRunning = true; + reset(); + nanoStartTime = System.nanoTime(); + + // start class: intersection of super classes for definitions (since it needs to + // capture all instances), but owl:Thing for learning subclasses (since it is + // superfluous to add super classes in this case) + Description startClass; + if(isEquivalenceProblem) { + Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe); + startClass = new Intersection(new LinkedList<Description>(superClasses)); + } else { + startClass = Thing.instance; + } + addNode(startClass, null); + + + // print solution(s) + logger.info("solution : " + bestEvaluatedDescriptions.getBest()); + + isRunning = false; } - /* (non-Javadoc) - * @see org.dllearner.core.LearningAlgorithm#stop() - */ - @Override - public void stop() { - // TODO Auto-generated method stub - + // expand node horizontically + private void expandNode(OENode node) { + } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#getConfigurator() - */ - @Override - public Configurator getConfigurator() { - // TODO Auto-generated method stub - return null; + + // add node to search tree if it is not too weak + // returns true if node was added and false otherwise + private boolean addNode(Description description, OENode parentNode) { + + // redundancy check (return if redundant) + boolean nonRedundant = descriptions.add(description); + if(!nonRedundant) { + return false; + } + + // quality of description (return if too weak) + double accuracy = learningProblem.getAccuracyOrTooWeak(description, minAcc); + if(accuracy == -1) { + return false; + } + + OENode node = new OENode(parentNode, description, accuracy); + + // link to parent (unless start node) + if(parentNode == null) { + startNode = node; + } else { + parentNode.addChild(node); + } + + // maybe add to best descriptions (method keeps set size fixed) + bestEvaluatedDescriptions.add(description, accuracy, learningProblem); + + return true; + } + + // check whether the node is a potential solution candidate + // (sufficient accuracy; minimal; rewriting steps?) + private boolean checkNode(OENode node) { + return true; } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#init() - */ + + private boolean terminationCriteriaSatisfied() { + return !stop && (System.nanoTime() - nanoStartTime >= (configurator.getMaxExecutionTimeInSeconds()/1000000)); + } + + private void reset() { + // set all values back to their default values (used for running + // the algorithm more than once) +// candidates.clear(); + nodes = new TreeSet<OENode>(new OEHeuristicRuntime()); + descriptions = new TreeSet<Description>(new ConceptComparator()); + bestEvaluatedDescriptions.getSet().clear(); + } + @Override - public void init() throws ComponentInitException { - // TODO Auto-generated method stub - + public boolean isRunning() { + return isRunning; + } + + @Override + public void stop() { + stop = true; } } Added: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristic.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristic.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -0,0 +1,32 @@ +/** + * 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.celoe; + +import java.util.Comparator; + +/** + * Marker interface for heurist comparators over nodes in the search tree. + * + * @author Jens Lehmann + * + */ +public interface OEHeuristic extends Comparator<OENode> { + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -0,0 +1,39 @@ +/** + * 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.celoe; + +import java.util.Comparator; + +/** + * @author Jens Lehmann + * + */ +public class OEHeuristicRuntime implements OEHeuristic { + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(OENode o1, OENode o2) { + // TODO Auto-generated method stub + return 0; + } + +} Added: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicStable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicStable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicStable.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -0,0 +1,37 @@ +/** + * 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.celoe; + +/** + * @author Jens Lehmann + * + */ +public class OEHeuristicStable implements OEHeuristic { + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(OENode o1, OENode o2) { + // TODO Auto-generated method stub + return 0; + } + +} Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -19,12 +19,70 @@ */ package org.dllearner.algorithms.celoe; +import java.util.List; + +import org.dllearner.core.owl.Description; + /** * A node in the search tree of the ontology engineering algorithm. * + * Differences to the node structures in other algorithms (this may change): + * - covered examples are not stored in node (i.e. coverage needs to be recomputed + * for child nodes, which costs time but saves memory) + * - only evaluated nodes are stored + * - too weak nodes are not stored + * - redundant nodes are not stored (?) + * - only accuracy is stored to make the node structure reusable for different + * learning problems and -algorithms + * * @author Jens Lehmann * */ public class OENode { + private Description description; + + private double accuracy; + + private OENode parent; + private List<OENode> children; + + public OENode(OENode parentNode, Description description, double accuracy) { + this.parent = parentNode; + this.description = description; + this.accuracy = accuracy; + } + + public void addChild(OENode node) { + children.add(node); + } + + /** + * @return the description + */ + public Description getDescription() { + return description; + } + + /** + * @return the accuracy + */ + public double getAccuracy() { + return accuracy; + } + + /** + * @return the parent + */ + public OENode getParent() { + return parent; + } + + /** + * @return the children + */ + public List<OENode> getChildren() { + return children; + } + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -168,7 +168,7 @@ // the description has a chance to make it in the set if it has // at least as high accuracy - if not we can save the reasoner calls // for fully computing the evaluated description - if(bestEvaluatedDescriptions.size() == 0 || bestEvaluatedDescriptions.getWorst().getCoveredNegatives().size() >= node.getCoveredNegatives()) { + if(bestEvaluatedDescriptions.size() == 0 || ((EvaluatedDescriptionPosNeg)bestEvaluatedDescriptions.getWorst()).getCoveredNegatives().size() >= node.getCoveredNegatives()) { ScorePosNeg score = (ScorePosNeg) learningProblem.computeScore(description); EvaluatedDescriptionPosNeg ed = new EvaluatedDescriptionPosNeg(description, score); bestEvaluatedDescriptions.add(ed); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ExampleBasedNode.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -42,6 +42,8 @@ */ public class ExampleBasedNode { +// public static long exampleMemoryCounter = 0; + private ROLComponent2Configurator configurator; private static DecimalFormat df = new DecimalFormat(); @@ -114,6 +116,8 @@ this.coveredPositives = coveredPositives; this.coveredNegatives = coveredNegatives; isQualityEvaluated = true; +// exampleMemoryCounter += coveredPositives.size() * 4; +// exampleMemoryCounter += coveredNegatives.size() * 4; } @Override Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLearner2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLearner2.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLearner2.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -418,6 +418,8 @@ printStatistics(false); lastPrintTime = currentTime; logger.debug("--- loop " + loop + " started ---"); +// logger.info("used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024); +// logger.info("test: " + ExampleBasedNode.exampleMemoryCounter/1024); } // traverse the current search tree to find a solution Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -77,6 +77,15 @@ public abstract Score computeScore(Description description); /** + * Evaluates the description by computing the score and returning an + * evaluated description of the correct type (ClassLearningProblem + * returns EvaluatedDescriptionClass instead of generic EvaluatedDescription). + * @param description Description to evaluate. + * @return + */ + public abstract EvaluatedDescription evaluate(Description description); + + /** * This method returns a value, which indicates how accurate a * class description solves a learning problem. There can be different * ways to compute accuracy depending on the type of learning problem Modified: trunk/src/dl-learner/org/dllearner/core/Score.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Score.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/core/Score.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -25,6 +25,8 @@ * different criteria can be used. (Similar learning problems probably * score class descriptions/hypothesis in a similar way.) * + * TODO: Maybe we don't really need a score, but only EvaluatedDescription. + * * @author Jens Lehmann * */ Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -25,12 +25,13 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.configurators.RefinementOperatorConfigurator; /** * automatically generated, do not edit manually. * run org.dllearner.scripts.ConfigJavaGenerator to update **/ -public class CELOEConfigurator implements Configurator { +public class CELOEConfigurator extends RefinementOperatorConfigurator implements Configurator { private boolean reinitNecessary = false; @SuppressWarnings("unused") @@ -55,7 +56,205 @@ return component; } +/** +* useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseAllConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useAllConstructor") ; +} +/** +* useExistsConstructor specifies whether the existential concept constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseExistsConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useExistsConstructor") ; +} +/** +* useHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getUseHasValueConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useHasValueConstructor") ; +} +/** +* valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. +* mandatory: false| reinit necessary: true +* default value: 3 +* @return int +**/ +public int getValueFrequencyThreshold() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "valueFrequencyThreshold") ; +} +/** +* useCardinalityRestrictions specifies whether CardinalityRestrictions is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseCardinalityRestrictions() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useCardinalityRestrictions") ; +} +/** +* cardinalityLimit Gives the maximum number used in cardinality restrictions.. +* mandatory: false| reinit necessary: true +* default value: 5 +* @return int +**/ +public int getCardinalityLimit() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "cardinalityLimit") ; +} +/** +* useNegation specifies whether negation is used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseNegation() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useNegation") ; +} +/** +* useBooleanDatatypes specifies whether boolean datatypes are used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseBooleanDatatypes() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useBooleanDatatypes") ; +} +/** +* useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseDoubleDatatypes() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "useDoubleDatatypes") ; +} +/** +* maxExecutionTimeInSeconds algorithm will stop after specified seconds. +* mandatory: false| reinit necessary: true +* default value: 0 +* @return int +**/ +public int getMaxExecutionTimeInSeconds() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "maxExecutionTimeInSeconds") ; +} +/** +* noisePercentage the (approximated) percentage of noise within the examples. +* mandatory: false| reinit necessary: true +* default value: 0.0 +* @return double +**/ +public double getNoisePercentage() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(cELOE, "noisePercentage") ; +} +/** +* @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseAllConstructor(boolean useAllConstructor) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useAllConstructor", useAllConstructor); +reinitNecessary = true; +} +/** +* @param useExistsConstructor specifies whether the existential concept constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseExistsConstructor(boolean useExistsConstructor) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useExistsConstructor", useExistsConstructor); +reinitNecessary = true; +} +/** +* @param useHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setUseHasValueConstructor(boolean useHasValueConstructor) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useHasValueConstructor", useHasValueConstructor); +reinitNecessary = true; +} +/** +* @param valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions. +* mandatory: false| reinit necessary: true +* default value: 3 +**/ +public void setValueFrequencyThreshold(int valueFrequencyThreshold) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "valueFrequencyThreshold", valueFrequencyThreshold); +reinitNecessary = true; +} +/** +* @param useCardinalityRestrictions specifies whether CardinalityRestrictions is used in the learning algorithm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseCardinalityRestrictions(boolean useCardinalityRestrictions) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useCardinalityRestrictions", useCardinalityRestrictions); +reinitNecessary = true; +} +/** +* @param cardinalityLimit Gives the maximum number used in cardinality restrictions.. +* mandatory: false| reinit necessary: true +* default value: 5 +**/ +public void setCardinalityLimit(int cardinalityLimit) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "cardinalityLimit", cardinalityLimit); +reinitNecessary = true; +} +/** +* @param useNegation specifies whether negation is used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseNegation(boolean useNegation) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useNegation", useNegation); +reinitNecessary = true; +} +/** +* @param useBooleanDatatypes specifies whether boolean datatypes are used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseBooleanDatatypes(boolean useBooleanDatatypes) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useBooleanDatatypes", useBooleanDatatypes); +reinitNecessary = true; +} +/** +* @param useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseDoubleDatatypes(boolean useDoubleDatatypes) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "useDoubleDatatypes", useDoubleDatatypes); +reinitNecessary = true; +} +/** +* @param maxExecutionTimeInSeconds algorithm will stop after specified seconds. +* mandatory: false| reinit necessary: true +* default value: 0 +**/ +public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); +reinitNecessary = true; +} +/** +* @param noisePercentage the (approximated) percentage of noise within the examples. +* mandatory: false| reinit necessary: true +* default value: 0.0 +**/ +public void setNoisePercentage(double noisePercentage) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "noisePercentage", noisePercentage); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -197,6 +197,11 @@ return str; } + @Override + public ClassHierarchy clone() { + return new ClassHierarchy(subsumptionHierarchyUp, subsumptionHierarchyDown); + } + /** * The method computes a new class hierarchy, which is a copy of this * one, but only the specified classes are allowed to occur. For instance, Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -23,6 +23,8 @@ import java.util.LinkedList; import java.util.Set; +import org.dllearner.algorithms.EvaluatedDescriptionClass; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ClassLearningProblemConfigurator; @@ -129,4 +131,20 @@ // TODO Auto-generated method stub return 0; } + + /** + * @return the classToDescribe + */ + public NamedClass getClassToDescribe() { + return classToDescribe; + } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#evaluate(org.dllearner.core.owl.Description) + */ + @Override + public EvaluatedDescription evaluate(Description description) { + ClassScore score = computeScore(description); + return new EvaluatedDescriptionClass(description, score); + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -22,6 +22,7 @@ import java.util.Set; import java.util.SortedSet; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.configurators.PosNegInclusionLPConfigurator; @@ -217,4 +218,13 @@ return 0; } + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#evaluate(org.dllearner.core.owl.Description) + */ + @Override + public EvaluatedDescription evaluate(Description description) { + // TODO Auto-generated method stub + return null; + } + } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -24,6 +24,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.PosNegLPStandardConfigurator; import org.dllearner.core.options.ConfigOption; @@ -247,4 +248,13 @@ return 0; } + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#evaluate(org.dllearner.core.owl.Description) + */ + @Override + public EvaluatedDescription evaluate(Description description) { + // TODO Auto-generated method stub + return null; + } + } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -23,6 +23,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.PosNegLPStrictConfigurator; import org.dllearner.core.options.BooleanConfigOption; @@ -221,4 +222,13 @@ // TODO Auto-generated method stub return 0; } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#evaluate(org.dllearner.core.owl.Description) + */ + @Override + public EvaluatedDescription evaluate(Description description) { + // TODO Auto-generated method stub + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -39,6 +39,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.configurators.CELOEConfigurator; import org.dllearner.core.configurators.ROLearnerConfigurator; import org.dllearner.core.configurators.RefinementOperatorConfigurator; import org.dllearner.core.options.ConfigOption; @@ -65,7 +66,7 @@ private static final SortedSet<String> EXTENDSREFINEMENTOPERATOR = new TreeSet<String>(Arrays.asList(new String[]{ ROLearnerConfigurator.class.getSimpleName(), - CELOE.class.getSimpleName(), + CELOEConfigurator.class.getSimpleName(), })); @SuppressWarnings("unchecked") Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2009-02-13 17:10:49 UTC (rev 1604) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2009-02-16 13:03:46 UTC (rev 1605) @@ -27,6 +27,8 @@ import java.util.TreeSet; import org.dllearner.algorithms.EvaluatedDescriptionPosNeg; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningProblem; import org.dllearner.core.owl.Description; /** @@ -39,9 +41,9 @@ */ public class EvaluatedDescriptionSet { - private EvaluatedDescriptionPosNegComparator comp = new EvaluatedDescriptionPosNegComparator(); + private EvaluatedDescriptionComparator comp = new EvaluatedDescriptionComparator(); - private SortedSet<EvaluatedDescriptionPosNeg> set = new TreeSet<EvaluatedDescriptionPosNeg>(comp); + private SortedSet<EvaluatedDescription> set = new TreeSet<EvaluatedDescription>(comp); private int maxSize; @@ -49,10 +51,21 @@ this.maxSize = maxSize; } - public void add(EvaluatedDescriptionPosNeg ed) { + public void add(Description description, double accuracy, LearningProblem problem) { + if(set.size()==0 || getWorst().getAccuracy() <= accuracy) { + set.add(problem.evaluate(description)); + } + if(set.size()>maxSize) { + Iterator<EvaluatedDescription> it = set.iterator(); + it.next(); + it.remove(); + } + } + + public void add(EvaluatedDescription ed) { set.add(ed); if(set.size()>maxSize) { - Iterator<EvaluatedDescriptionPosNeg> it = set.iterator(); + Iterator<EvaluatedDescription> it = set.iterator(); it.next(); it.remove(); } @@ -68,24 +81,24 @@ return set.size(); } - public EvaluatedDescriptionPosNeg getBest() { + public EvaluatedDescription getBest() { return set.first(); } - public EvaluatedDescriptionPosNeg getWorst() { + public EvaluatedDescription getWorst() { return set.last(); } /** * @return the set */ - public SortedSet<EvaluatedDescriptionPosNeg> getSet() { + public SortedSet<EvaluatedDescription> getSet() { return set; } public List<Description> toDescriptionList() { List<Description> list = new LinkedList<Description>(); - for(EvaluatedDescriptionPosNeg ed : set) { + for(EvaluatedDescription ed : set) { list.add(ed.getDescription()); } return list; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |