From: <ji...@us...> - 2011-04-13 08:54:41
|
Revision: 2765 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2765&view=rev Author: jialva Date: 2011-04-13 08:54:28 +0000 (Wed, 13 Apr 2011) Log Message: ----------- New classes and some little changes regarding DL-Learner fuzzy extensions (I) Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java trunk/components-core/src/main/java/org/dllearner/core/Reasoner.java trunk/components-core/src/main/java/org/dllearner/core/ReasonerComponent.java trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java trunk/components-core/src/main/java/org/dllearner/core/configurators/package.html trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigMappings.java trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java trunk/components-core/src/main/resources/components.ini trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java trunk/interfaces/src/main/java/org/dllearner/cli/Start.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyPosNegLPStandardConfigurator.java trunk/components-core/src/main/java/org/dllearner/core/fuzzydll/ trunk/components-core/src/main/java/org/dllearner/core/fuzzydll/FuzzyIndividualReasoner.java trunk/components-core/src/main/java/org/dllearner/core/fuzzydll/FuzzyUnsupportedCodeException.java trunk/components-core/src/main/java/org/dllearner/core/options/fuzzydll/ trunk/components-core/src/main/java/org/dllearner/core/options/fuzzydll/FuzzyExample.java trunk/components-core/src/main/java/org/dllearner/core/options/fuzzydll/ObjectSetConfigOption.java trunk/components-core/src/main/java/org/dllearner/core/owl/fuzzydll/ trunk/components-core/src/main/java/org/dllearner/core/owl/fuzzydll/FuzzyIndividual.java trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/ trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLP.java trunk/components-core/src/main/java/org/dllearner/learningproblems/fuzzydll/FuzzyPosNegLPStandard.java trunk/components-core/src/test/java/org/dllearner/test/FuzzyDLLTest.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2011-04-12 11:24:02 UTC (rev 2764) +++ trunk/components-core/pom.xml 2011-04-13 08:54:28 UTC (rev 2765) @@ -71,8 +71,8 @@ </execution> </executions> </plugin> - </plugins> - </build> + </plugins> + </build> <dependencies> @@ -195,6 +195,17 @@ <artifactId>h2</artifactId> </dependency> + <dependency> + <groupId>fuzzydll</groupId> + <artifactId>fuzzydl</artifactId> + <version>1.0</version> + </dependency> + + <dependency> + <groupId>fuzzydll</groupId> + <artifactId>fuzzyowl2fuzzydlparser</artifactId> + <version>1.0</version> + </dependency> </dependencies> </project> Added: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -0,0 +1,814 @@ +/** + * 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.fuzzydll; + +import java.io.File; +import java.text.DecimalFormat; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.Logger; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.FuzzyClassExpressionLearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.configurators.FuzzyCELOEConfigurator; +import org.dllearner.core.options.BooleanConfigOption; +import org.dllearner.core.options.CommonConfigOptions; +import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.options.DoubleConfigOption; +import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.owl.ClassHierarchy; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Restriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; +import org.dllearner.refinementoperators.OperatorInverter; +import org.dllearner.refinementoperators.RefinementOperator; +import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.owl.DescriptionMinimizer; +import org.dllearner.utilities.owl.EvaluatedDescriptionSet; +import org.dllearner.utilities.owl.PropertyContext; + +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + +/** + * The CELOE (Class Expression Learner for Ontology Engineering) algorithm. + * It adapts and extends the standard supervised learning algorithm for the + * ontology engineering use case. + * + * @author Jens Lehmann + * + */ +public class FuzzyCELOE extends AbstractCELA implements FuzzyClassExpressionLearningAlgorithm { + + private static Logger logger = Logger.getLogger(FuzzyCELOE.class); + private FuzzyCELOEConfigurator configurator; + + private boolean isRunning = false; + private boolean stop = false; + +// private OEHeuristicStable heuristicStable = new OEHeuristicStable(); +// private OEHeuristicRuntime heuristicRuntime = new OEHeuristicRuntime(); + + private RefinementOperator operator; + private DescriptionMinimizer minimizer; + + // all nodes in the search tree (used for selecting most promising node) + private TreeSet<FuzzyOENode> nodes; + private FuzzyOEHeuristicRuntime heuristic; // = new OEHeuristicRuntime(); + // root of search tree + private FuzzyOENode startNode; + // the class with which we start the refinement process + private Description startClass; + + // all descriptions in the search tree plus those which were too weak (for fast redundancy check) + private TreeSet<Description> descriptions; + + private EvaluatedDescriptionSet bestEvaluatedDescriptions; + + // if true, then each solution is evaluated exactly instead of approximately + // private boolean exactBestDescriptionEvaluation = false; + private boolean singleSuggestionMode; + private Description bestDescription; + private double bestAccuracy = Double.MIN_VALUE; + + private NamedClass classToDescribe; + // examples are either 1.) instances of the class to describe 2.) positive examples + // 3.) union of pos.+neg. examples depending on the learning problem at hand + private Set<Individual> examples; + + // CELOE was originally created for learning classes in ontologies, but also + // works for other learning problem types + private boolean isClassLearningProblem; + private boolean isEquivalenceProblem; + + private long nanoStartTime; + + // important parameters + private double noise; + private double maxDepth; + private boolean filterFollowsFromKB; + + // less important parameters + // forces that one solution cannot be subexpression of another expression; this option is useful to get diversity + // but it can also suppress quite useful expressions + private boolean forceMutualDifference = false; + + // utility variables + private String baseURI; + private Map<String, String> prefixes; + private DecimalFormat dfPercent = new DecimalFormat("0.00%"); + private ConceptComparator descriptionComparator = new ConceptComparator(); + + // statistical variables + private int expressionTests = 0; + private int minHorizExp = 0; + private int maxHorizExp = 0; + + @Override + public FuzzyCELOEConfigurator getConfigurator() { + return configurator; + } + + public FuzzyCELOE(LearningProblem problem, ReasonerComponent reasoner) { + super(problem, reasoner); + configurator = new FuzzyCELOEConfigurator(this); + } + + 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 Collection<ConfigOption<?>> createConfigOptions() { + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + options.add(CommonConfigOptions.useAllConstructor()); + options.add(CommonConfigOptions.useExistsConstructor()); + options.add(CommonConfigOptions.useHasValueConstructor()); + options.add(CommonConfigOptions.useDataHasValueConstructor()); + options.add(CommonConfigOptions.valueFreqencyThreshold()); + options.add(CommonConfigOptions.useCardinalityRestrictions()); + options.add(CommonConfigOptions.cardinalityLimit()); + // by default, we do not use negation (should be configurable in GUI) + options.add(CommonConfigOptions.useNegation(false)); + options.add(CommonConfigOptions.useBooleanDatatypes()); + options.add(CommonConfigOptions.useDoubleDatatypes()); + options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); + options.add(CommonConfigOptions.getNoisePercentage()); + options.add(CommonConfigOptions.getTerminateOnNoiseReached(false)); + options.add(CommonConfigOptions.getMaxDepth(7)); + options.add(CommonConfigOptions.maxNrOfResults(10)); + options.add(CommonConfigOptions.maxClassDescriptionTests()); + options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); + options.add(CommonConfigOptions.getInstanceBasedDisjoints()); + options.add(new BooleanConfigOption("filterDescriptionsFollowingFromKB", "If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions.", false)); + options.add(new BooleanConfigOption("reuseExistingDescription", "If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.", false)); + 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", "log/searchTree.txt")); + 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)); + options.add(new DoubleConfigOption("expansionPenaltyFactor","heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones)", 0.1)); + return options; + } + + public static String getName() { + return "fuzzy CELOE"; + } + + @Override + 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(); + + heuristic = new FuzzyOEHeuristicRuntime(configurator); + + minimizer = new DescriptionMinimizer(reasoner); + + startClass = Thing.instance; + + singleSuggestionMode = configurator.getSingleSuggestionMode(); + + // create refinement operator + operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator); + baseURI = reasoner.getBaseURI(); + prefixes = reasoner.getPrefixes(); + if(configurator.getWriteSearchTree()) { + Files.clearFile(new File(configurator.getSearchTreeFile())); + } + + bestEvaluatedDescriptions = new EvaluatedDescriptionSet(configurator.getMaxNrOfResults()); + + isClassLearningProblem = (learningProblem instanceof ClassLearningProblem); + + // we put important parameters in class variables + noise = configurator.getNoisePercentage()/100d; +// System.out.println("noise " + noise); + maxDepth = configurator.getMaxDepth(); + // (filterFollowsFromKB is automatically set to false if the problem + // is not a class learning problem + filterFollowsFromKB = configurator.getFilterDescriptionsFollowingFromKB() + && isClassLearningProblem; + + // actions specific to ontology engineering + if(isClassLearningProblem) { + ClassLearningProblem problem = (ClassLearningProblem) learningProblem; + classToDescribe = problem.getClassToDescribe(); + isEquivalenceProblem = problem.isEquivalenceProblem(); + + examples = reasoner.getIndividuals(classToDescribe); + + // 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) + if(isEquivalenceProblem) { + Set<Description> existingDefinitions = reasoner.getAssertedDefinitions(classToDescribe); + if(configurator.getReuseExistingDescription() && (existingDefinitions.size() > 0)) { + // the existing definition is reused, which in the simplest case means to + // use it as a start class or, if it is already too specific, generalise it + + // pick the longest existing definition as candidate + Description existingDefinition = null; + int highestLength = 0; + for(Description exDef : existingDefinitions) { + if(exDef.getLength() > highestLength) { + existingDefinition = exDef; + highestLength = exDef.getLength(); + } + } + + LinkedList<Description> startClassCandidates = new LinkedList<Description>(); + startClassCandidates.add(existingDefinition); + ((RhoDRDown)operator).setDropDisjuncts(true); + RefinementOperator upwardOperator = new OperatorInverter(operator); + + // use upward refinement until we find an appropriate start class + boolean startClassFound = false; + Description candidate; + do { + candidate = startClassCandidates.pollFirst(); + if(((ClassLearningProblem)learningProblem).getRecall(candidate)<1.0) { + // add upward refinements to list + Set<Description> refinements = upwardOperator.refine(candidate, candidate.getLength()); +// System.out.println("ref: " + refinements); + LinkedList<Description> refinementList = new LinkedList<Description>(refinements); +// Collections.reverse(refinementList); +// System.out.println("list: " + refinementList); + startClassCandidates.addAll(refinementList); +// System.out.println("candidates: " + startClassCandidates); + } else { + startClassFound = true; + } + } while(!startClassFound); + startClass = candidate; + + if(startClass.equals(existingDefinition)) { + logger.info("Reusing existing description " + startClass.toManchesterSyntaxString(baseURI, prefixes) + " as start class for learning algorithm."); + } else { + logger.info("Generalised existing description " + existingDefinition.toManchesterSyntaxString(baseURI, prefixes) + " to " + startClass.toManchesterSyntaxString(baseURI, prefixes) + ", which is used as start class for the learning algorithm."); + } + +// System.out.println("start class: " + startClass); +// System.out.println("existing def: " + existingDefinition); +// System.out.println(reasoner.getIndividuals(existingDefinition)); + + ((RhoDRDown)operator).setDropDisjuncts(false); + + } else { + Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe); + if(superClasses.size() > 1) { + startClass = new Intersection(new LinkedList<Description>(superClasses)); + } else if(superClasses.size() == 1){ + startClass = (Description) superClasses.toArray()[0]; + } else { + startClass = Thing.instance; + logger.warn(classToDescribe + " is equivalent to owl:Thing. Usually, it is not " + + "sensible to learn a description in this case."); + } + } + } + } else if(learningProblem instanceof PosOnlyLP) { + examples = ((PosOnlyLP)learningProblem).getPositiveExamples(); + } else if(learningProblem instanceof PosNegLP) { + examples = Helper.union(((PosNegLP)learningProblem).getPositiveExamples(),((PosNegLP)learningProblem).getNegativeExamples()); + } + } + + @Override + public Description getCurrentlyBestDescription() { + EvaluatedDescription ed = getCurrentlyBestEvaluatedDescription(); + return ed == null ? null : ed.getDescription(); + } + + @Override + public List<Description> getCurrentlyBestDescriptions() { + return bestEvaluatedDescriptions.toDescriptionList(); + } + + @Override + public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { + return bestEvaluatedDescriptions.getBest(); + } + + @Override + public TreeSet<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { + return bestEvaluatedDescriptions.getSet(); + } + + public double getCurrentlyBestAccuracy() { + return bestEvaluatedDescriptions.getBest().getAccuracy(); + } + + @Override + public void start() { +// System.out.println(configurator.getMaxExecutionTimeInSeconds()); + + stop = false; + isRunning = true; + reset(); + nanoStartTime = System.nanoTime(); + + // highest accuracy so far + double highestAccuracy = 0.0; + FuzzyOENode nextNode; + + addNode(startClass, null); + + int loop = 0; + while (!terminationCriteriaSatisfied()) { +// System.out.println("loop " + loop); + + if(!singleSuggestionMode && bestEvaluatedDescriptions.getBestAccuracy() > highestAccuracy) { + highestAccuracy = bestEvaluatedDescriptions.getBestAccuracy(); + logger.info("more accurate (" + dfPercent.format(highestAccuracy) + ") class expression found: " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); + } + + // chose best node according to heuristics + nextNode = getNextNodeToExpand(); + int horizExp = nextNode.getHorizontalExpansion(); + + // apply operator + Monitor mon = MonitorFactory.start("refineNode"); + TreeSet<Description> refinements = refineNode(nextNode); + mon.stop(); + +// System.out.println("next node: " + nextNode); +// for(Description refinement : refinements) { +// System.out.println("refinement: " + refinement); +// } + + while(refinements.size() != 0) { + // pick element from set + Description refinement = refinements.pollFirst(); + int length = refinement.getLength(); + + // we ignore all refinements with lower length and too high depth + // (this also avoids duplicate node children) + if(length > horizExp && refinement.getDepth() <= maxDepth) { + +// System.out.println("potentially adding " + refinement + " to search tree as child of " + nextNode + " " + new Date()); + Monitor mon2 = MonitorFactory.start("addNode"); + addNode(refinement, nextNode); + mon2.stop(); + // adding nodes is potentially computationally expensive, so we have + // to check whether max time is exceeded + if(terminationCriteriaSatisfied()) { + break; + } +// System.out.println("addNode finished" + " " + new Date()); + } + +// System.out.println(" refinement queue length: " + refinements.size()); + } + + updateMinMaxHorizExp(nextNode); + + // writing the search tree (if configured) + if (configurator.getWriteSearchTree()) { + String treeString = "best node: " + bestEvaluatedDescriptions.getBest() + "\n"; + if (refinements.size() > 1) { + treeString += "all expanded nodes:\n"; + for (Description n : refinements) { + treeString += " " + n + "\n"; + } + } + treeString += startNode.toTreeString(baseURI); + treeString += "\n"; + + if (configurator.getReplaceSearchTree()) + Files.createFile(new File(configurator.getSearchTreeFile()), treeString); + else + Files.appendFile(new File(configurator.getSearchTreeFile()), treeString); + } + +// System.out.println(loop); + loop++; + } + + if (stop) { + logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); + } else { + logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); + } + + if(singleSuggestionMode) { + bestEvaluatedDescriptions.add(bestDescription, bestAccuracy, learningProblem); + } + + // print solution(s) + logger.info("solutions:\n" + getSolutionString()); + +// System.out.println(startNode.toTreeString(baseURI)); + + isRunning = false; +// System.out.println("isRunning: " + isRunning); + } + + private FuzzyOENode getNextNodeToExpand() { + // we expand the best node of those, which have not achieved 100% accuracy + // already and have a horizontal expansion equal to their length + // (rationale: further extension is likely to add irrelevant syntactical constructs) + Iterator<FuzzyOENode> it = nodes.descendingIterator(); + while(it.hasNext()) { + FuzzyOENode node = it.next(); + if(node.getAccuracy() < 1.0 || node.getHorizontalExpansion() < node.getDescription().getLength()) { + return node; + } + } + + // this should practically never be called, since for any reasonable learning + // task, we will always have at least one node with less than 100% accuracy + return nodes.last(); + } + + // expand node horizontically + private TreeSet<Description> refineNode(FuzzyOENode node) { + // we have to remove and add the node since its heuristic evaluation changes through the expansion + // (you *must not* include any criteria in the heuristic which are modified outside of this method, + // otherwise you may see rarely occurring but critical false ordering in the nodes set) + nodes.remove(node); +// System.out.println("refining: " + node); + int horizExp = node.getHorizontalExpansion(); + TreeSet<Description> refinements = (TreeSet<Description>) operator.refine(node.getDescription(), horizExp+1); + node.incHorizontalExpansion(); + node.setRefinementCount(refinements.size()); + nodes.add(node); + return refinements; + } + + // 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, FuzzyOENode parentNode) { + +// System.out.println(description); + + // redundancy check (return if redundant) + boolean nonRedundant = descriptions.add(description); + if(!nonRedundant) { + return false; + } + + // check whether the description is allowed + if(!isDescriptionAllowed(description, parentNode)) { + return false; + } + +// System.out.println("Test " + new Date()); + // quality of description (return if too weak) + double accuracy = learningProblem.getAccuracyOrTooWeak(description, noise); + // issue a warning if accuracy is not between 0 and 1 or -1 (too weak) + if(accuracy > 1.0 || (accuracy < 0.0 && accuracy != -1)) { + logger.warn("Invalid accuracy value " + accuracy + " for description " + description + ". This could be caused by a bug in the heuristic measure and should be reported to the DL-Learner bug tracker."); + System.exit(0); + } + +// System.out.println("Test2 " + new Date()); + expressionTests++; +// System.out.println("acc: " + accuracy); +// System.out.println(description + " " + accuracy); + if(accuracy == -1) { + return false; + } + + FuzzyOENode node = new FuzzyOENode(parentNode, description, accuracy); + + // link to parent (unless start node) + if(parentNode == null) { + startNode = node; + } else { + parentNode.addChild(node); + } + + nodes.add(node); +// System.out.println("Test3 " + new Date()); + + // in some cases (e.g. mutation) fully evaluating even a single description is too expensive + // due to the high number of examples -- so we just stick to the approximate accuracy + if(singleSuggestionMode) { + if(accuracy > bestAccuracy) { + bestAccuracy = accuracy; + bestDescription = description; + logger.info("more accurate (" + dfPercent.format(bestAccuracy) + ") class expression found: " + descriptionToString(bestDescription)); // + getTemporaryString(bestDescription)); + } + return true; + } + +// System.out.println("description " + description + " accuracy " + accuracy); + + // maybe add to best descriptions (method keeps set size fixed); + // we need to make sure that this does not get called more often than + // necessary since rewriting is expensive + boolean isCandidate = !bestEvaluatedDescriptions.isFull(); + if(!isCandidate) { + EvaluatedDescription worst = bestEvaluatedDescriptions.getWorst(); + double accThreshold = worst.getAccuracy(); + isCandidate = + (accuracy > accThreshold || + (accuracy >= accThreshold && description.getLength() < worst.getDescriptionLength())); + } + +// System.out.println(isCandidate); + +// System.out.println("Test4 " + new Date()); + if(isCandidate) { + + Description niceDescription = rewriteNode(node); + ConceptTransformation.transformToOrderedForm(niceDescription, descriptionComparator); +// Description niceDescription = node.getDescription(); + + // another test: none of the other suggested descriptions should be + // a subdescription of this one unless accuracy is different + // => comment: on the one hand, this appears to be too strict, because once A is a solution then everything containing + // A is not a candidate; on the other hand this suppresses many meaningless extensions of A + boolean shorterDescriptionExists = false; + if(forceMutualDifference) { + for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet()) { + if(Math.abs(ed.getAccuracy()-accuracy) <= 0.00001 && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { +// System.out.println("shorter: " + ed.getDescription()); + shorterDescriptionExists = true; + break; + } + } + } + +// System.out.println("shorter description? " + shorterDescriptionExists + " nice: " + niceDescription); + + if(!shorterDescriptionExists) { + if(!filterFollowsFromKB || !((ClassLearningProblem)learningProblem).followsFromKB(niceDescription)) { +// System.out.println("Test2"); + bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); +// System.out.println("acc: " + accuracy); +// System.out.println(bestEvaluatedDescriptions); + } + } + +// System.out.println(bestEvaluatedDescriptions.getSet().size()); + } + +// System.out.println("Test5 " + new Date()); +// System.out.println("best evaluated descriptions size: " + bestEvaluatedDescriptions.size() + " worst: " + bestEvaluatedDescriptions.getWorst()); + return true; + } + + // checks whether the description is allowed + private boolean isDescriptionAllowed(Description description, FuzzyOENode parentNode) { + if(isClassLearningProblem) { + if(isEquivalenceProblem) { + // the class to learn must not appear on the outermost property level + if(occursOnFirstLevel(description, classToDescribe)) { + return false; + } + } else { + // none of the superclasses of the class to learn must appear on the + // outermost property level + TreeSet<Description> toTest = new TreeSet<Description>(descriptionComparator); + toTest.add(classToDescribe); + while(!toTest.isEmpty()) { + Description d = toTest.pollFirst(); + if(occursOnFirstLevel(description, d)) { + return false; + } + toTest.addAll(reasoner.getClassHierarchy().getSuperClasses(d)); + } + } + } + + // perform forall sanity tests + if(parentNode != null && ConceptTransformation.getForallOccurences(description) > ConceptTransformation.getForallOccurences(parentNode.getDescription())) { + // we have an additional \forall construct, so we now fetch the contexts + // in which it occurs + SortedSet<PropertyContext> contexts = ConceptTransformation.getForallContexts(description); + SortedSet<PropertyContext> parentContexts = ConceptTransformation.getForallContexts(parentNode.getDescription()); + contexts.removeAll(parentContexts); +// System.out.println("parent description: " + parentNode.getDescription()); +// System.out.println("description: " + description); +// System.out.println("contexts: " + contexts); + // we now have to perform sanity checks: if \forall is used, then there + // should be at least on class instance which has a filler at the given context + for(PropertyContext context : contexts) { + // transform [r,s] to \exists r.\exists s.\top + Description existentialContext = context.toExistentialContext(); + boolean fillerFound = false; + for(Individual instance : examples) { + if(reasoner.hasType(existentialContext, instance)) { +// System.out.println(instance + " " + existentialContext); + fillerFound = true; + break; + } + } + // if we do not find a filler, this means that putting \forall at + // that position is not meaningful + if(!fillerFound) { + return false; + } + } + } + + // we do not want to have negations of sibling classes on the outermost level + // (they are expressed more naturally by saying that the siblings are disjoint, + // so it is reasonable not to include them in solutions) +// Set<Description> siblingClasses = reasoner.getClassHierarchy().getSiblingClasses(classToDescribe); +// for now, we just disable negation + + return true; + } + + // determine whether a named class occurs on the outermost level, i.e. property depth 0 + // (it can still be at higher depth, e.g. if intersections are nested in unions) + private boolean occursOnFirstLevel(Description description, Description clazz) { + if(description instanceof NamedClass) { + if(description.equals(clazz)) { + return true; + } + } + + if(description instanceof Restriction) { + return false; + } + + for(Description child : description.getChildren()) { + if(occursOnFirstLevel(child, clazz)) { + return true; + } + } + + return false; + } + + // check whether the node is a potential solution candidate + private Description rewriteNode(FuzzyOENode node) { + Description description = node.getDescription(); + // minimize description (expensive!) - also performes some human friendly rewrites + Description niceDescription = minimizer.minimizeClone(description); + // replace \exists r.\top with \exists r.range(r) which is easier to read for humans + ConceptTransformation.replaceRange(niceDescription, reasoner); + return niceDescription; + } + + private boolean terminationCriteriaSatisfied() { + return + stop || + (configurator.getMaxClassDescriptionTests() != 0 && (expressionTests >= configurator.getMaxClassDescriptionTests())) || + (configurator.getMaxExecutionTimeInSeconds() != 0 && ((System.nanoTime() - nanoStartTime) >= (configurator.getMaxExecutionTimeInSeconds()*1000000000l))) || + (configurator.getTerminateOnNoiseReached() && (100*getCurrentlyBestAccuracy()>100-configurator.getNoisePercentage())); + } + + private void reset() { + // set all values back to their default values (used for running + // the algorithm more than once) + nodes = new TreeSet<FuzzyOENode>(heuristic); + descriptions = new TreeSet<Description>(new ConceptComparator()); + bestEvaluatedDescriptions.getSet().clear(); + expressionTests = 0; + } + + @Override + public boolean isRunning() { + return isRunning; + } + + @Override + public void stop() { + stop = true; + } + + public FuzzyOENode getSearchTreeRoot() { + return startNode; + } + + // central function for printing description + private String descriptionToString(Description description) { + return description.toManchesterSyntaxString(baseURI, prefixes); + } + + @SuppressWarnings("unused") + private String bestDescriptionToString() { + EvaluatedDescription best = bestEvaluatedDescriptions.getBest(); + return best.getDescription().toManchesterSyntaxString(baseURI, prefixes) + " (accuracy: " + dfPercent.format(best.getAccuracy()) + ")"; + } + + private String getSolutionString() { + int current = 1; + String str = ""; + for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet().descendingSet()) { + // temporary code + // changed by Josue + if(learningProblem instanceof PosNegLPStandard) { + str += current + ": " + descriptionToString(ed.getDescription()) + " (pred. acc.: " + dfPercent.format(((PosNegLPStandard)learningProblem).getPredAccuracyOrTooWeakExact(ed.getDescription(),1)) + ", F-measure: "+ dfPercent.format(((PosNegLPStandard)learningProblem).getFMeasureOrTooWeakExact(ed.getDescription(),1)) + ")\n"; + } else if (learningProblem instanceof FuzzyPosNegLPStandard) { + str += current + ": " + descriptionToString(ed.getDescription()) + " (pred. acc.: " + dfPercent.format(((FuzzyPosNegLPStandard)learningProblem).getPredAccuracyOrTooWeakExact(ed.getDescription(),1)) + ", F-measure: "+ dfPercent.format(((FuzzyPosNegLPStandard)learningProblem).getFMeasureOrTooWeakExact(ed.getDescription(),1)) + ")\n"; + } else { + str += current + ": " + descriptionToString(ed.getDescription()) + " " + dfPercent.format(ed.getAccuracy()) + "\n"; +// System.out.println(ed); + } + current++; + } + return str; + } + +// private String getTemporaryString(Description description) { +// return descriptionToString(description) + " (pred. acc.: " + dfPercent.format(((PosNegLPStandard)learningProblem).getPredAccuracyOrTooWeakExact(description,1)) + ", F-measure: "+ dfPercent.format(((PosNegLPStandard)learningProblem).getFMeasureOrTooWeakExact(description,1)) + ")"; +// } + + private void updateMinMaxHorizExp(FuzzyOENode node) { + int newHorizExp = node.getHorizontalExpansion(); + + // update maximum value + maxHorizExp = Math.max(maxHorizExp, newHorizExp); + + // we just expanded a node with minimum horizontal expansion; + // we need to check whether it was the last one + if(minHorizExp == newHorizExp - 1) { + + // the best accuracy that a node can achieve + double scoreThreshold = heuristic.getNodeScore(node) + 1 - node.getAccuracy(); + + for(FuzzyOENode n : nodes.descendingSet()) { + if(n != node) { + if(n.getHorizontalExpansion() == minHorizExp) { + // we can stop instantly when another node with min. + return; + } + if(heuristic.getNodeScore(n) < scoreThreshold) { + // we can stop traversing nodes when their score is too low + break; + } + } + } + + // inc. minimum since we found no other node which also has min. horiz. exp. + minHorizExp++; + +// System.out.println("minimum horizontal expansion is now " + minHorizExp); + } + } + + public int getMaximumHorizontalExpansion() { + return maxHorizExp; + } + + public int getMinimumHorizontalExpansion() { + return minHorizExp; + } + + /** + * @return the expressionTests + */ + public int getClassExpressionTests() { + return expressionTests; + } + + // added by Josue (when implementing FuzzyClassExpressionLearningAlgorithm) + + @Override + public List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions( + int nrOfDescriptions) { + // TODO Auto-generated method stub + return null; + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -0,0 +1,87 @@ +/** + * 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.fuzzydll; + +import java.util.Comparator; + +import org.dllearner.core.configurators.FuzzyCELOEConfigurator; +import org.dllearner.utilities.owl.ConceptComparator; + +/** + * Search algorithm heuristic for the ontology engineering algorithm. The heuristic + * has a strong bias towards short descriptions (i.e. the algorithm is likely to be + * less suitable for learning complex descriptions). + * + * @author Jens Lehmann + * + */ +public class FuzzyOEHeuristicRuntime implements Comparator<FuzzyOENode>{ + + // strong penalty for long descriptions + private double expansionPenaltyFactor = 0.1; + // bonus for being better than parent node + private double gainBonusFactor = 0.3; + // penalty if a node description has very many refinements since exploring + // such a node is computationally very expensive + private double nodeRefinementPenalty = 0.0001; + // syntactic comparison as final comparison criterion + private ConceptComparator conceptComparator = new ConceptComparator(); + + public FuzzyOEHeuristicRuntime(FuzzyCELOEConfigurator configurator) { + expansionPenaltyFactor = configurator.getExpansionPenaltyFactor(); + } + + @Override + public int compare(FuzzyOENode node1, FuzzyOENode node2) { +// System.out.println("node1 " + node1); +// System.out.println("score: " + getNodeScore(node1)); +// System.out.println("node2 " + node2); +// System.out.println("score: " + getNodeScore(node2)); + + double diff = getNodeScore(node1) - getNodeScore(node2); + + if(diff>0) { + return 1; + } else if(diff<0) { + return -1; + } else { + return conceptComparator.compare(node1.getDescription(), node2.getDescription()); + } + } + + public double getNodeScore(FuzzyOENode node) { + // accuracy as baseline + double score = node.getAccuracy(); + // being better than the parent gives a bonus; + if(!node.isRoot()) { + double parentAccuracy = node.getParent().getAccuracy(); + score += (parentAccuracy - score) * gainBonusFactor; + } + // penalty for horizontal expansion + score -= node.getHorizontalExpansion() * expansionPenaltyFactor; + // penalty for having many child nodes (stuck prevention) + score -= node.getRefinementCount() * nodeRefinementPenalty; + return score; + } + + public double getExpansionPenaltyFactor() { + return expansionPenaltyFactor; + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -0,0 +1,168 @@ +/** + * 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.fuzzydll; + +import java.text.DecimalFormat; +import java.util.LinkedList; +import java.util.List; + +import org.dllearner.algorithms.SearchTreeNode; +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 FuzzyOENode implements SearchTreeNode { + + private Description description; + + private double accuracy; + + private int horizontalExpansion; + + private FuzzyOENode parent; + private List<FuzzyOENode> children = new LinkedList<FuzzyOENode>(); + + // the refinement count corresponds to the number of refinements of the + // description in this node - it is a better heuristic indicator than child count + // (and avoids the problem that adding children changes the heuristic value) + private int refinementCount = 0; + + private static DecimalFormat dfPercent = new DecimalFormat("0.00%"); + + public FuzzyOENode(FuzzyOENode parentNode, Description description, double accuracy) { + this.parent = parentNode; + this.description = description; + this.accuracy = accuracy; + horizontalExpansion = description.getLength()-1; + } + + public void addChild(FuzzyOENode node) { + children.add(node); + } + + public void incHorizontalExpansion() { + horizontalExpansion++; + } + + public boolean isRoot() { + return (parent == null); + } + + /** + * @return the description + */ + public Description getDescription() { + return description; + } + + public Description getExpression() { + return getDescription(); + } + + /** + * @return the accuracy + */ + public double getAccuracy() { + return accuracy; + } + + /** + * @return the parent + */ + public FuzzyOENode getParent() { + return parent; + } + + /** + * @return the children + */ + public List<FuzzyOENode> getChildren() { + return children; + } + + /** + * @return the horizontalExpansion + */ + public int getHorizontalExpansion() { + return horizontalExpansion; + } + + public String getShortDescription(String baseURI) { + String ret = description.toString(baseURI,null) + " ["; + ret += "acc:" + dfPercent.format(accuracy) + ", "; + ret += "he:" + horizontalExpansion + ", "; + ret += "c:" + children.size() + ", "; + ret += "ref:" + refinementCount + "]"; + return ret; + } + + @Override + public String toString() { + return getShortDescription(null); + } + + public String toTreeString() { + return toTreeString(0, null).toString(); + } + + public String toTreeString(String baseURI) { + return toTreeString(0, baseURI).toString(); + } + + private StringBuilder toTreeString(int depth, String baseURI) { + StringBuilder treeString = new StringBuilder(); + for(int i=0; i<depth-1; i++) + treeString.append(" "); + if(depth!=0) + treeString.append("|--> "); + treeString.append(getShortDescription(baseURI)+"\n"); + for(FuzzyOENode child : children) { + treeString.append(child.toTreeString(depth+1,baseURI)); + } + return treeString; + } + + /** + * @return the refinementCount + */ + public int getRefinementCount() { + return refinementCount; + } + + /** + * @param refinementCount the refinementCount to set + */ + public void setRefinementCount(int refinementCount) { + this.refinementCount = refinementCount; + } +} Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-04-12 11:24:02 UTC (rev 2764) +++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -83,6 +83,7 @@ "org.dllearner.kb.OWLAPIOntology", //reasoners "org.dllearner.reasoning.OWLAPIReasoner", + "org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner", // added by Josue "org.dllearner.reasoning.DIGReasoner", "org.dllearner.reasoning.FastRetrievalReasoner", "org.dllearner.reasoning.FastInstanceChecker", @@ -90,6 +91,7 @@ "org.dllearner.reasoning.PelletReasoner", //learning problems "org.dllearner.learningproblems.PosNegLPStandard", + "org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard", // added by Josue "org.dllearner.learningproblems.PosNegLPStrict", "org.dllearner.learningproblems.PosOnlyLP", "org.dllearner.learningproblems.ClassLearningProblem", @@ -102,6 +104,7 @@ "org.dllearner.algorithms.el.ELLearningAlgorithm", "org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive", "org.dllearner.algorithms.celoe.CELOE", + "org.dllearner.algorithms.fuzzydll.FuzzyCELOE", //added by Josue "org.dllearner.algorithms.isle.ISLE" } )); Modified: trunk/components-core/src/main/java/org/dllearner/core/Reasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/Reasoner.java 2011-04-12 11:24:02 UTC (rev 2764) +++ trunk/components-core/src/main/java/org/dllearner/core/Reasoner.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -19,12 +19,14 @@ */ package org.dllearner.core; +import org.dllearner.core.fuzzydll.FuzzyIndividualReasoner; + /** * List of available reasoning/query methods. * * @author Jens Lehmann * */ -public interface Reasoner extends BaseReasoner, SchemaReasoner, IndividualReasoner { +public interface Reasoner extends BaseReasoner, SchemaReasoner, IndividualReasoner, FuzzyIndividualReasoner { } Modified: trunk/components-core/src/main/java/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ReasonerComponent.java 2011-04-12 11:24:02 UTC (rev 2764) +++ trunk/components-core/src/main/java/org/dllearner/core/ReasonerComponent.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -39,6 +39,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.fuzzydll.FuzzyIndividual; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectProperty; @@ -1213,4 +1214,28 @@ return str; } + /************************************************************** + * FUZZY EXTENSIONS + **************************************************************/ + + @Override + public double hasTypeFuzzyMembership(Description description, FuzzyIndividual individual) { + reasoningStartTimeTmp = System.nanoTime(); + double result = -1; + try { + result = hasTypeFuzzyMembershipImpl(description, individual); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + nrOfInstanceChecks++; + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + instanceCheckReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + protected double hasTypeFuzzyMembershipImpl(Description concept, FuzzyIndividual individual) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } } Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java 2011-04-12 11:24:02 UTC (rev 2764) +++ trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -27,6 +27,7 @@ import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.algorithms.el.ELLearningAlgorithm; import org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive; +import org.dllearner.algorithms.fuzzydll.FuzzyCELOE; import org.dllearner.algorithms.gp.GP; import org.dllearner.algorithms.isle.ISLE; import org.dllearner.algorithms.ocel.OCEL; @@ -43,12 +44,14 @@ import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.PosNegLPStrict; import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.learningproblems.fuzzydll.FuzzyPosNegLPStandard; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.reasoning.PelletReasoner; import org.dllearner.reasoning.ProtegeReasoner; +import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner; /** * automatically generated, do not edit manually. @@ -138,6 +141,14 @@ } /** +* @param knowledgeSource see KnowledgeSource +* @return a component ready for initialization FuzzyOWLAPIReasoner +**/ +public static FuzzyOWLAPIReasoner getFuzzyOWLAPIReasoner(Set<KnowledgeSource> knowledgeSource) { +return FuzzyOWLAPIReasonerConfigurator.getFuzzyOWLAPIReasoner(knowledgeSource); +} + +/** * @param classToDescribe class of which a description should be learned * @param reasoningService see ReasoningService * @return a component ready for initialization ClassLearningProblem @@ -176,6 +187,17 @@ } /** +* @param fuzzyExamples fuzzy examples +* @param positiveExamples positive examples +* @param negativeExamples negative examples +* @param reasoningService see ReasoningService +* @return a component ready for initialization FuzzyPosNegLPStandard +**/ +public static FuzzyPosNegLPStandard getFuzzyPosNegLPStandard(ReasonerComponent reasoningService, Set<Object> fuzzyExamples, Set<String> positiveExamples, Set<String> negativeExamples) { +return FuzzyPosNegLPStandardConfigurator.getFuzzyPosNegLPStandard(reasoningService, fuzzyExamples, positiveExamples, negativeExamples); +} + +/** * @param learningProblem see LearningProblem * @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see @@ -229,6 +251,16 @@ * @param learningProblem see LearningProblem * @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see +* @return a component ready for initialization FuzzyCELOE +**/ +public static FuzzyCELOE getFuzzyCELOE(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException { +return FuzzyCELOEConfigurator.getFuzzyCELOE(learningProblem, reasoningService); +} + +/** +* @param learningProblem see LearningProblem +* @param reasoningService see ReasoningService +* @throws LearningProblemUnsupportedException see * @return a component ready for initialization GP **/ public static GP getGP(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException { Added: trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java 2011-04-13 08:54:28 UTC (rev 2765) @@ -0,0 +1,499 @@ +/** + * 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.core.configurators; + +import org.dllearner.algorithms.fuzzydll.FuzzyCELOE; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; + +/** +* automatically generated, do not edit manually. +* run org.dllearner.scripts.ConfigJavaGenerator to update +**/ +public class FuzzyCELOEConfigurator extends RefinementOperatorConfigurator implements Configurator { + +private boolean reinitNecessary = false; +private FuzzyCELOE fuzzyCELOE; + +/** +* @param fuzzyCELOE see FuzzyCELOE +**/ +public FuzzyCELOEConfigurator(FuzzyCELOE fuzzyCELOE){ +this.fuzzyCELOE = fuzzyCELOE; +} + +/** +* @param reasoningService see reasoningService +* @param learningProblem see learningProblem +* @throws LearningProblemUnsupportedException see +* @return FuzzyCELOE +**/ +public static FuzzyCELOE getFuzzyCELOE(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException{ +FuzzyCELOE component = ComponentManager.getInstance().learningAlgorithm(FuzzyCELOE.class, learningProblem, reasoningService); +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(fuzzyCELOE, "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(fuzzyCELOE, "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(fuzzyCELOE, "useHasValueConstructor") ; +} +/** +* useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getUseDataHasValueConstructor() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useDataHasValueConstructor") ; +} +/** +* 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(fuzzyCELOE, "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(fuzzyCELOE, "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(fuzzyCELOE, "cardinalityLimit") ; +} +/** +* useNegation specifies whether negation is used in the learning algorothm. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getUseNegation() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "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(fuzzyCELOE, "useBooleanDatatypes") ; +} +/** +* useDoubleDatatypes specifies whether double 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(fuzzyCELOE, "useDoubleDatatypes") ; +} +/** +* maxExecutionTimeInSeconds algorithm will stop after specified seconds. +* mandatory: false| reinit necessary: true +* default value: 10 +* @return int +**/ +public int getMaxExecutionTimeInSeconds() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "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(fuzzyCELOE, "noisePercentage") ; +} +/** +* terminateOnNoiseReached specifies whether to terminate when noise criterion is met. +* mandatory: false| reinit necessary: true +* defau... [truncated message content] |