You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ton...@us...> - 2008-03-12 01:48:15
|
Revision: 702 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=702&view=rev Author: tonytacker Date: 2008-03-11 18:48:07 -0700 (Tue, 11 Mar 2008) Log Message: ----------- We can now start to show a search tree. It was not possible, without some changes. - add abstract class getStartNode() to LearningAlgorithm.java - implement this method in all classes which are using it ATTENTION: I had to change getStartNode() in ROLearner.java, hope it will not produce errors. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-03-12 01:48:07 UTC (rev 702) @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; +import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -286,4 +287,8 @@ stop = true; } + @Override + public ExampleBasedNode getStartNode() { + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-03-12 01:48:07 UTC (rev 702) @@ -25,6 +25,7 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.gp.Program; import org.dllearner.algorithms.gp.GPUtilities; +import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -127,5 +128,9 @@ } + @Override + public ExampleBasedNode getStartNode() { + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-03-12 01:48:07 UTC (rev 702) @@ -30,6 +30,7 @@ import java.util.Map.Entry; import org.dllearner.algorithms.hybridgp.Psi; +import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -1003,4 +1004,9 @@ //public void setAlgorithmType(AlgorithmType algorithmType) { // this.algorithmType = algorithmType; //} + + @Override + public ExampleBasedNode getStartNode() { + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-12 01:48:07 UTC (rev 702) @@ -349,6 +349,7 @@ algorithm.stop(); } + @Override public ExampleBasedNode getStartNode() { return algorithm.getStartNode(); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-03-12 01:48:07 UTC (rev 702) @@ -12,6 +12,7 @@ import java.util.TreeSet; import org.apache.log4j.Logger; +import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -1003,8 +1004,12 @@ /** * @return the startNode */ - public Node getStartNode() { + public Node getStartNode_original() { return startNode; } + @Override + public ExampleBasedNode getStartNode() { + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-03-12 01:48:07 UTC (rev 702) @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.List; +import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.core.owl.Description; /** @@ -70,4 +71,9 @@ return new LinkedList<Class<? extends LearningProblem>>(); } + /** + * Root for search tree. + * @return + */ + public abstract ExampleBasedNode getStartNode(); } Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-11 17:55:22 UTC (rev 701) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-12 01:48:07 UTC (rev 702) @@ -22,6 +22,7 @@ import javax.swing.*; import javax.swing.tree.*; +import org.dllearner.algorithms.refexamples.*; /** * TreeWindow @@ -45,21 +46,29 @@ // set icon setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( this.getClass().getResource("icon.gif"))); - + // tree - DefaultMutableTreeNode root = new DefaultMutableTreeNode( "root" ); - for ( int knot = 0; knot < 4; knot++ ) - { - DefaultMutableTreeNode node = new DefaultMutableTreeNode( "knot " + knot ); - root.add( node ); - for ( int leaf = 1; leaf < 4; leaf++ ) - node.add( new DefaultMutableTreeNode("leaf " + (knot*3+leaf )) ); - } - JTree tree = new JTree( root ); - this.add( new JScrollPane( tree ) ); + DefaultMutableTreeNode exampleRoot = new DefaultMutableTreeNode("root"); + for (int knot = 0; knot < 4; knot++) { + DefaultMutableTreeNode node = new DefaultMutableTreeNode("knot " + knot); + exampleRoot.add(node); + for (int leaf = 1; leaf < 4; leaf++) + node.add(new DefaultMutableTreeNode("leaf " + (knot * 3 + leaf))); + } + ExampleBasedNode rootNode = config.getLearningAlgorithm().getStartNode(); + EBNodeTreeModel root = new EBNodeTreeModel(rootNode); + + // show tree + if (root != null) { + JTree tree = new JTree(root); + this.add(new JScrollPane(tree)); + } + else { + JTree tree = new JTree(exampleRoot); + this.add(new JScrollPane(tree)); + } this.setVisible(true); } - - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-11 17:55:29
|
Revision: 701 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=701&view=rev Author: jenslehmann Date: 2008-03-11 10:55:22 -0700 (Tue, 11 Mar 2008) Log Message: ----------- - search tree traversal and candidate set reduction ML techniques implemented - small test example for double datatype learning - PTE2 carcinogenesis examples added Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Added Paths: ----------- trunk/examples/datatypes/ trunk/examples/datatypes/double.conf trunk/examples/datatypes/double.owl Added: trunk/examples/datatypes/double.conf =================================================================== --- trunk/examples/datatypes/double.conf (rev 0) +++ trunk/examples/datatypes/double.conf 2008-03-11 17:55:22 UTC (rev 701) @@ -0,0 +1,20 @@ +/** + * Simple test example for double datatypes using the height + * of persons. + * + * possible solution: + * height <= 1.84 + * + * Copyright (C) 2008, Jens Lehmann + */ + +algorithm = refexamples; +// refexamples.writeSearchTree = true; +refexamples.searchTreeFile = "log/doubleTree.txt"; +reasoner = fastInstanceChecker; + +import("double.owl"); + ++"http://dl-learner.org/examples/double#frank" +-"http://dl-learner.org/examples/double#peter" +-"http://dl-learner.org/examples/double#susan" Added: trunk/examples/datatypes/double.owl =================================================================== --- trunk/examples/datatypes/double.owl (rev 0) +++ trunk/examples/datatypes/double.owl 2008-03-11 17:55:22 UTC (rev 701) @@ -0,0 +1,121 @@ +<?xml version="1.0"?> + + +<!DOCTYPE rdf:RDF [ + <!ENTITY owl "http://www.w3.org/2002/07/owl#" > + <!ENTITY owl11 "http://www.w3.org/2006/12/owl11#" > + <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > + <!ENTITY owl11xml "http://www.w3.org/2006/12/owl11-xml#" > + <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > + <!ENTITY double "http://dl-learner.org/examples/double#" > + <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > +]> + + +<rdf:RDF xmlns="http://dl-learner.org/examples/double#" + xml:base="http://dl-learner.org/examples/double" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl11="http://www.w3.org/2006/12/owl11#" + xmlns:owl11xml="http://www.w3.org/2006/12/owl11-xml#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:double="http://dl-learner.org/examples/double#"> + <owl:Ontology rdf:about=""/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Data properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/examples/double#height --> + + <owl:DatatypeProperty rdf:about="#height"> + <rdfs:domain rdf:resource="#Person"/> + <rdfs:range rdf:resource="&xsd;double"/> + </owl:DatatypeProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/examples/double#Man --> + + <owl:Class rdf:about="#Man"> + <rdfs:subClassOf rdf:resource="#Person"/> + </owl:Class> + + + + <!-- http://dl-learner.org/examples/double#Person --> + + <owl:Class rdf:about="#Person"> + <rdfs:subClassOf rdf:resource="&owl;Thing"/> + </owl:Class> + + + + <!-- http://dl-learner.org/examples/double#Woman --> + + <owl:Class rdf:about="#Woman"> + <rdfs:subClassOf rdf:resource="#Person"/> + </owl:Class> + + + + <!-- http://www.w3.org/2002/07/owl#Thing --> + + <owl:Class rdf:about="&owl;Thing"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/examples/double#frank --> + + <Man rdf:about="#frank"> + <height rdf:datatype="&xsd;double">1.82</height> + </Man> + + + + <!-- http://dl-learner.org/examples/double#peter --> + + <Man rdf:about="#peter"> + <height rdf:datatype="&xsd;double">1.91</height> + </Man> + + + + <!-- http://dl-learner.org/examples/double#susan --> + + <Woman rdf:about="#susan"> + <height rdf:datatype="&xsd;double">1.86</height> + </Woman> +</rdf:RDF> Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-10 17:53:52 UTC (rev 700) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-11 17:55:22 UTC (rev 701) @@ -174,6 +174,10 @@ return ret; } + public double getAccuracy(int nrOfPositiveExamples, int nrOfNegativeExamples) { + return (coveredPositives.size() + nrOfNegativeExamples - coveredNegatives.size())/(double)(nrOfPositiveExamples+nrOfNegativeExamples); + } + public Set<Individual> getCoveredPositives() { return coveredPositives; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-10 17:53:52 UTC (rev 700) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-11 17:55:22 UTC (rev 701) @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.NavigableSet; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -106,6 +107,18 @@ // ALL r.TOP is improper and automatically expanded further private boolean testProperness = false; + // tree traversal means to run through the most promising concepts + // and connect them in an intersection to find a solution + // (this is called irregularly e.g. every 100 seconds) + private boolean useTreeTraversal = false; + + // candidate reduction: using this mechanism we can simulate + // the divide&conquer approach in many ILP programs using a + // clause by clause search; after a period of time the candidate + // set is reduced to focus CPU time on the most promising concepts + private boolean useCandidateReduction = true; + private int candidatePostReductionSize = 30; + // setting to true gracefully stops the algorithm private boolean stop = false; @@ -228,7 +241,7 @@ public void start() { // calculate quality threshold required for a solution - allowedMisclassifications = (int) Math.round(noise * nrOfExamples); + allowedMisclassifications = (int) Math.round(noise * nrOfExamples); // start search with start class if(startDescription == null) { @@ -250,6 +263,11 @@ algorithmStartTime = System.nanoTime(); long lastPrintTime = 0; + long lastTreeTraversalTime = System.nanoTime(); + long lastReductionTime = System.nanoTime(); + // try a traversal after 100 seconds + long traversalInterval = 1000l * 1000000000l; + long reductionInterval = 100l * 1000000000l; long currentTime; while(!solutionFound && !stop) { @@ -262,6 +280,18 @@ logger.debug("--- loop " + loop + " started ---"); } + // traverse the current search tree to find a solution + if(useTreeTraversal && (currentTime - lastTreeTraversalTime > traversalInterval)) { + traverseTree(); + lastTreeTraversalTime = System.nanoTime(); + } + + // reduce candidates to focus on promising concepts + if(useCandidateReduction && (currentTime - lastReductionTime > reductionInterval)) { + reduceCandidates(); + lastReductionTime = System.nanoTime(); + } + // chose best node according to heuristics bestNode = candidates.last(); // extend best node @@ -695,6 +725,130 @@ } return false; } + + // TODO: investigate whether it makes sense not to store all individuals + // in the nodes, but instead perform instance checks in tree traversal + // (it is only run in large intervals so it shouldn't be too expensive) + private void traverseTree() { +// ExampleBasedNode startNode = candidatesStable.last(); + ExampleBasedNode startNode = findBestTraversalStartNode(); + Description currentDescription = startNode.getConcept(); + Set<Individual> currentCoveredPos = startNode.getCoveredPositives(); + Set<Individual> currentCoveredNeg = startNode.getCoveredNegatives(); + double currentAccuracy = startNode.getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples); + int currentMisclassifications = nrOfPositiveExamples - currentCoveredPos.size() + currentCoveredNeg.size(); + System.out.println("tree traversal start node " + startNode.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); + System.out.println("tree traversal start accuracy: " + currentAccuracy); + int i=0; + // start from the most promising nodes + NavigableSet<ExampleBasedNode> reverseView = candidatesStable.descendingSet(); + for(ExampleBasedNode currNode : reverseView) { + // compute covered positives and negatives + SortedSet<Individual> newCoveredPositives = new TreeSet<Individual>(currentCoveredPos); + newCoveredPositives.retainAll(currNode.getCoveredPositives()); + SortedSet<Individual> newCoveredNegatives = new TreeSet<Individual>(currentCoveredNeg); + newCoveredNegatives.retainAll(currNode.getCoveredNegatives()); + + // compute the accuracy we would get by adding this node + double accuracy = (newCoveredPositives.size() + nrOfNegativeExamples - newCoveredNegatives.size())/(double)(nrOfPositiveExamples+nrOfNegativeExamples); + int misclassifications = nrOfPositiveExamples - newCoveredPositives.size() + newCoveredNegatives.size(); + int misclassifiedPositives = nrOfPositiveExamples - newCoveredPositives.size(); + + int lostPositives = currentCoveredPos.size() - newCoveredPositives.size(); + + // TODO: maybe we should also consider a minimum improvement when adding something + // otherwise we could overfit + // we give double weith to lost positives, i.e. when one positive is lost at least + // two negatives need to be uncovered + boolean consider = (misclassifications + lostPositives < currentMisclassifications) && + (misclassifiedPositives <= allowedMisclassifications); +// boolean consider = (misclassifications < currentMisclassifications) && +// (misclassifiedPositives <= allowedMisclassifications); + + // concept has been chosen, so construct it + if(consider) { + + // construct a new concept as intersection of both + Intersection mc = new Intersection(currentDescription, currNode.getConcept()); + + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + +// System.out.println("extended concept to: " + mc); + System.out.println("misclassifications: " + misclassifications); + System.out.println("misclassified positives: " + misclassifiedPositives); + System.out.println("accuracy: " + accuracy); + + // update variables + currentDescription = mc; + currentCoveredPos = newCoveredPositives; + currentCoveredNeg = newCoveredNegatives; + currentMisclassifications = misclassifications; + currentAccuracy = accuracy; + + if(accuracy > 1 - noise) { + System.out.println("traversal found " + mc); + System.out.println("accuracy: " + accuracy); + System.exit(0); + } + } + + i++; + if(i==1000) + break; + } + + } + + // we look for a node covering many positives and hopefully + // few negatives; we give a strong penalty on uncovered positives + private ExampleBasedNode findBestTraversalStartNode() { + // 2 points for each covered pos + 1 point for each uncovered neg + int currScore = 0; + int i = 0; + ExampleBasedNode currNode = null; + NavigableSet<ExampleBasedNode> reverseView = candidatesStable.descendingSet(); + for(ExampleBasedNode node : reverseView) { + int score = 2 * node.getCoveredPositives().size() + (nrOfNegativeExamples - node.getCoveredNegatives().size()); + if(score > currScore) { + currScore = score; + currNode = node; + } + i++; + // limit search because stable candidate set can grow very large + if(i == 10000) + break; + } + return currNode; + } + + private void reduceCandidates() { + Iterator<ExampleBasedNode> it = candidatesStable.descendingIterator(); + Set<ExampleBasedNode> promisingNodes = new HashSet<ExampleBasedNode>(); + int i = 0; + while(it.hasNext() && promisingNodes.size()<candidatePostReductionSize) { + ExampleBasedNode node = it.next(); +// System.out.println(node.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); + // first criterion: the considered node should have an accuracy gain over its parent + // (avoids to use only the most promising node + all its refinements with equal accuracy) + boolean hasAccuracyGain = (node.getParent() == null) || (node.getCoveredPositives().size() != node.getParent().getCoveredPositives().size()) + || (node.getCoveredNegatives().size() != node.getParent().getCoveredNegatives().size()); + // second criterion: uncovered positives; it does not make much sense to pick nodes with + // low potential for reaching a solution (already at the limit of misclassified positives) + int misclassifiedPositives = nrOfPositiveExamples - node.getCoveredPositives().size(); + boolean hasRefinementPotential = (misclassifiedPositives <= Math.floor(0.65d*allowedMisclassifications)); + boolean keep = hasAccuracyGain && hasRefinementPotential; + if(keep) { + promisingNodes.add(node); + } + i++; + } + candidates.retainAll(promisingNodes); + System.out.println("searched " + i + " nodes and picked the following promising descriptions:"); + for(ExampleBasedNode node : promisingNodes) + System.out.println(node.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); + } + /* private Set<Individual> computeQuality(Description refinement, Set<Individual> coveredPositives) { Set<Individual> ret = new TreeSet<Individual>(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-10 17:53:52 UTC (rev 700) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-11 17:55:22 UTC (rev 701) @@ -21,8 +21,9 @@ import java.util.List; -import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Thing; import org.dllearner.utilities.ConceptComparator; /** @@ -77,7 +78,7 @@ private double expansionPenaltyFactor; private double gainBonusFactor; private double nodeChildPenalty = 0.0001; - private double startNodeBonus = 0.1; + private double startNodeBonus = 0.8; // examples private int nrOfNegativeExamples; @@ -140,9 +141,15 @@ private static int getHeuristicLengthBonus(Description description) { int bonus = 0; - if(description instanceof BooleanValueRestriction) + // do not count TOP symbols (in particular in ALL r.TOP and EXISTS r.TOP) + // as they provide no extra information + if(description instanceof Thing) bonus = 1; + // some bonus for doubles because they are already penalised by length 3 + if(description instanceof DatatypeValueRestriction) + bonus = 1; + List<Description> children = description.getChildren(); for(Description child : children) { bonus += getHeuristicLengthBonus(child); Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-03-10 17:53:52 UTC (rev 700) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-03-11 17:55:22 UTC (rev 701) @@ -122,8 +122,10 @@ public static void main(String[] args) throws FileNotFoundException, IOException, ParseException { + // TODO: newgroups are not mapped currently String[] files = new String[] { "newgroups.pl", "ames.pl", "atoms.pl", "bonds.pl", "gentoxprops.pl", - "ind_nos.pl", "ind_pos.pl", + "ind_nos.pl", "ind_pos.pl", "pte2/canc_nos.pl", "pte2/pte2ames.pl", "pte2/pte2atoms.pl", + "pte2/pte2bonds.pl", "pte2/pte2gentox.pl", "pte2/pte2ind_nos.pl", "pte2/pte2newgroups.pl" // "train.b" => not a pure Prolog file but Progol/Aleph specific }; File owlFile = new File("examples/carcinogenesis/pte.owl"); @@ -252,20 +254,23 @@ appendNegExamples(confTrainFile, negTrainExamples); // generating test examples for PTE-1 - File confPTE1File = new File("examples/carcinogenesis/testpte1.conf"); - Files.clearFile(confPTE1File); + // => put all in one file, because they were used as training for PTE-2 + // File confPTE1File = new File("examples/carcinogenesis/testpte1.conf"); + // Files.clearFile(confPTE1File); File testPTE1Positives = new File(prologDirectory + "pte1.f"); File testPTE1Negatives = new File(prologDirectory + "pte1.n"); List<Individual> posPTE1Examples = getExamples(testPTE1Positives); List<Individual> negPTE1Examples = getExamples(testPTE1Negatives); - appendPosExamples(confPTE1File, posPTE1Examples); - appendNegExamples(confPTE1File, negPTE1Examples); + appendPosExamples(confTrainFile, posPTE1Examples); + appendNegExamples(confTrainFile, negPTE1Examples); - // TODO: how to get PTE-2 predictions? the pte-2 directory suggests - // that all are positive which is not true (according to the papers) - // solution: go to "http://ntp-server.niehs.nih.gov/" and click - // on "Testing Status of Agents at NTP" + // create a PTE-2 test file + File confPTE2File = new File("examples/carcinogenesis/testpte2.conf"); + Files.clearFile(confPTE2File); + Files.appendFile(confPTE2File, "import(\"pte.owl\");\nreasoner=fastInstanceChecker;\n\n"); + Files.appendFile(confPTE2File, getPTE2Examples()); + } private static List<Axiom> mapClause(Clause clause) throws IOException, ParseException { @@ -361,7 +366,7 @@ axioms.add(dpa); // either parse this or ashby_alert - not both - ashby_alert contains // all information in ind already - } else if (headName.equals("ind")) { + } else if (headName.equals("ind") || headName.equals("ring_no")) { String compoundName = head.getArgument(0).toPLString(); String structureName = head.getArgument(1).toPLString(); int count = Integer.parseInt(head.getArgument(2).toPLString()); @@ -555,4 +560,86 @@ newGroups.addAll(list); } + /** + * <p>To find out whether a substance is carinogenetic go to + * "http://ntp-server.niehs.nih.gov/" and click + * on "Testing Status of Agents at NTP".</p> + * + * Levels: + * <ul> + * <li>CE = clear evidence</li> + * <li>SE = some evidence</li> + * <li>E = equivocal evidence</li> + * <li>NE = no evidence</li> + * </ul> + * Levels CE and SE are positive examples. E and NE negative examples. + * Experiments are performed on rats and mice of both genders, so we + * have four evidence values. An example is positive if at least one + * value is SE or CE. + * + * <p>Some values are taken from the IJCAI-97 paper of Muggleton.</p> + * + * <p>Positives (19): <br /> + * <ul> + * <li>t3 (SE+3NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCACAFD4-123F-7908-7B521E4F665EFBD9</li> + * <li>t5: paper</li> + * <li>t7: paper</li> + * <li>t8: paper</li> + * <li>t9 (3CE+SE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD7C6869-123F-7908-7BDEA4CFAA55CEA8</li> + * <li>t10: paper</li> + * <li>t12 (2SE+E+NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCB0ADE0-123F-7908-7BEC101C7309C4DE</li> + * <li>t14 (2CE+2NE) probably 111-42-2 instead of 11-42-2: http://ntp.niehs.nih.gov/index.cfm?objectid=BCC60FF1-123F-7908-7B2D579AA48DE90C</li> + * <li>t15: paper</li> + * <li>t16 (2CE+SE+E): http://ntp.niehs.nih.gov/index.cfm?objectid=BCC5D9CE-123F-7908-7B959CCE5262468A</li> + * <li>t18 (2SE+E+NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCA087AA-123F-7908-7B79FDFDE3CDCF87</li> + * <li>t19 (2CE+E+NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCAE5690-123F-7908-7B02E35E2BB57694</li> + * <li>t20 (2SE+E+NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCF95607-123F-7908-7B0761D3C515CC12</li> + * <li>t21 (CE+3NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCFCB63C-123F-7908-7BF910C2783AE9FE</li> + * <li>t22 (SE+3NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD8345C2-123F-7908-7BC52FEF80F110E1</li> + * <li>t23 (4CE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCADD2D9-123F-7908-7B5C8180FE80B22F</li> + * <li>t24 (CE+E): http://ntp.niehs.nih.gov/index.cfm?objectid=BCFB19FF-123F-7908-7B845E176F13E6E1</li> + * <li>t25 (3CE+SE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD2D2A62-123F-7908-7B0DA824E782754C</li> + * <li>t30 (2CE+SE+E) : http://ntp.niehs.nih.gov/index.cfm?objectid=BCB13734-123F-7908-7BEBA533E35A48B7</li> + * </ul> + * </p> + * + * <p>Negatives (10): + * <ul> + * <li>t1 (4NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD9FF53C-123F-7908-7B123DAE0A25B122 </li> + * <li>t2 (4NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCF8651E-123F-7908-7B21DD5ED83CD0FF </li> + * <li>t4: paper</li> + * <li>t6: paper</li> + * <li>t11: paper</li> + * <li>t13 (4NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD136ED6-123F-7908-7B619EE79F2FD062</li> + * <li>t17: paper</li> + * <li>t26 (2E+2NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD1E6209-123F-7908-7B95EB8BAE662CE7</li> + * <li>t27 (E+3NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BCAC5D00-123F-7908-7BC46ECB72A6C91B</li> + * <li>t28 (E+3NE): http://ntp.niehs.nih.gov/index.cfm?objectid=BD34E02A-123F-7908-7BC6791917B591DF</li> + * </ul> + * </p> + * + * <p>Unclear (1): + * <ul> + * <li>t29: probably a negative (see http://ntp.niehs.nih.gov/index.cfm?objectid=BD855EA1-123F-7908-7B573FC3C08188DC) but + * no tests directly for this substance</li> + * </ul> + * </p> + * @return A string for all examples as used in the conf file. + */ + public static String getPTE2Examples() { + String[] pos = new String[] {"t3","t5","t7","t8","t9","t10","t12", + "t14","t15","t16","t18","t19","t20","t21","t22","t23","t24", + "t25","t30"}; + String[] neg = new String[] {"t1", "t2", "t4", "t6", "t11", "t13", + "t17","t26","t27","t28"}; + + String ret = ""; + for(String posEx : pos) + ret += "+" + getURI2(posEx) + "\n"; + for(String negEx : neg) + ret += "-" + getURI2(negEx) + "\n"; + + return ret; + } + } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-10 17:53:52 UTC (rev 700) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-11 17:55:22 UTC (rev 701) @@ -127,7 +127,7 @@ // splits for double datatype properties in ascening order private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); - private int maxNrOfSplits = 20; + private int maxNrOfSplits = 10; // staistics public long mComputationTimeNs = 0; @@ -359,6 +359,7 @@ } } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); DataRange dr = dsr.getDataRange(); @@ -956,7 +957,7 @@ int nrOfValues = values.size(); // create split set List<Double> splitsDP = new LinkedList<Double>(); - for(int splitNr=0; splitNr < maxNrOfSplits; splitNr++) { + for(int splitNr=0; splitNr < Math.min(maxNrOfSplits,nrOfValues-1); splitNr++) { int index; if(nrOfValues<=maxNrOfSplits) index = splitNr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-10 17:54:15
|
Revision: 700 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=700&view=rev Author: jenslehmann Date: 2008-03-10 10:53:52 -0700 (Mon, 10 Mar 2008) Log Message: ----------- double datatype learning support Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/SimpleDoubleDataRange.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-10 17:53:52 UTC (rev 700) @@ -100,6 +100,12 @@ private boolean useOverlyGeneralList = true; private boolean useShortConceptConstruction = true; + // if set to false we do not test properness; this may seem wrong + // but the disadvantage of properness testing are additional reasoner + // queries and a search bias towards ALL r.something because + // ALL r.TOP is improper and automatically expanded further + private boolean testProperness = false; + // setting to true gracefully stops the algorithm private boolean stop = false; @@ -431,11 +437,13 @@ Set<Description> improperConcepts = null; if(toEvaluateConcepts.size()>0) { // Test aller Konzepte auf properness (mit DIG in nur einer Anfrage) - long propCalcReasoningStart = System.nanoTime(); - improperConcepts = rs.subsumes(toEvaluateConcepts, concept); - propernessTestsReasoner+=toEvaluateConcepts.size(); - // boolean isProper = !learningProblem.getReasoningService().subsumes(refinement, concept); - propernessCalcReasoningTimeNs += System.nanoTime() - propCalcReasoningStart; + if(testProperness) { + long propCalcReasoningStart = System.nanoTime(); + improperConcepts = rs.subsumes(toEvaluateConcepts, concept); + propernessTestsReasoner+=toEvaluateConcepts.size(); + // boolean isProper = !learningProblem.getReasoningService().subsumes(refinement, concept); + propernessCalcReasoningTimeNs += System.nanoTime() - propCalcReasoningStart; + } } long improperConceptsRemovalTimeNsStart = System.nanoTime(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-10 17:53:52 UTC (rev 700) @@ -77,7 +77,7 @@ private double expansionPenaltyFactor; private double gainBonusFactor; private double nodeChildPenalty = 0.0001; - private double startNodeBonus = 0.8; + private double startNodeBonus = 0.1; // examples private int nrOfNegativeExamples; Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-03-10 17:53:52 UTC (rev 700) @@ -79,6 +79,12 @@ public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + // some convenience methods + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException; // mehrere instance checks für ein Konzept - spart bei DIG Anfragen Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-10 17:53:52 UTC (rev 700) @@ -459,6 +459,42 @@ return result; } + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return reasoner.getDoubleDatatypeMembers(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Map<Individual, SortedSet<Double>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return reasoner.getDoubleDatatypeMembers(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Map<Individual, SortedSet<Double>> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return reasoner.getDoubleDatatypeMembers(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Map<Individual, SortedSet<Double>> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return reasoner.getDoubleDatatypeMembers(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public Set<NamedClass> getAtomicConcepts() { return reasoner.getAtomicConcepts(); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-03-10 17:53:52 UTC (rev 700) @@ -32,11 +32,14 @@ */ public class DatatypeSomeRestriction extends DatatypeQuantorRestriction { + DataRange dataRange; + /** * @param datatypeProperty */ - public DatatypeSomeRestriction(DatatypeProperty datatypeProperty) { + public DatatypeSomeRestriction(DatatypeProperty datatypeProperty, DataRange dataRange) { super(datatypeProperty); + this.dataRange = dataRange; } /* (non-Javadoc) @@ -44,7 +47,6 @@ */ @Override public int getArity() { - // TODO Auto-generated method stub return 0; } @@ -52,16 +54,14 @@ * @see org.dllearner.core.owl.KBElement#getLength() */ public int getLength() { - // TODO Auto-generated method stub - return 0; + return 1 + dataRange.getLength(); } /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toString(baseURI, prefixes) + dataRange.toString(baseURI, prefixes); } /* (non-Javadoc) @@ -83,5 +83,12 @@ public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { // TODO Auto-generated method stub return null; + } + + /** + * @return the dataRange + */ + public DataRange getDataRange() { + return dataRange; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-03-10 17:53:52 UTC (rev 700) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class DoubleMaxValue implements DoubleDataRange { +public class DoubleMaxValue implements SimpleDoubleDataRange { private double value; @@ -54,8 +54,7 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return " <= " + value; } public void accept(KBElementVisitor visitor) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-03-10 17:53:52 UTC (rev 700) @@ -22,13 +22,13 @@ import java.util.Map; /** - * Double data range restricted by a maximum value, e.g. + * Double data range restricted by a minimum value, e.g. * hasAge >= 18. * * @author Jens Lehmann * */ -public class DoubleMinValue implements DoubleDataRange { +public class DoubleMinValue implements SimpleDoubleDataRange { private double value; @@ -54,8 +54,7 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return " >= " + value; } public void accept(KBElementVisitor visitor) { Added: trunk/src/dl-learner/org/dllearner/core/owl/SimpleDoubleDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SimpleDoubleDataRange.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/SimpleDoubleDataRange.java 2008-03-10 17:53:52 UTC (rev 700) @@ -0,0 +1,33 @@ +/** + * 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.owl; + +/** + * A double data range with a single value used for restrictions, + * e.g. hasAge >= 18 (but not 65 >= hasAge >= 18). + * + * @author Jens Lehmann + * + */ +public interface SimpleDoubleDataRange extends DoubleDataRange { + + public double getValue(); + +} Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-10 17:53:52 UTC (rev 700) @@ -37,9 +37,13 @@ import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; +import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -206,6 +210,9 @@ @Override public boolean instanceCheck(Description description, Individual individual) throws ReasoningMethodUnsupportedException { + +// System.out.println(description + " " + individual); + if (description instanceof NamedClass) { return classInstancesPos.get((NamedClass) description).contains(individual); } else if (description instanceof Negation) { @@ -294,6 +301,28 @@ } else { return bdNeg.get(dp).contains(individual); } + } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + SortedSet<Double> values = dd.get(dp).get(individual); + + // if there is no filler for this individual and property we + // need to return false + if(values == null) + return false; + + if(dr instanceof DoubleMaxValue) { + if(values.first() <= ((DoubleMaxValue)dr).getValue()) + return true; + else + return false; + } else if(dr instanceof DoubleMinValue) { + if(values.last() >= ((DoubleMinValue)dr).getValue()) + return true; + else + return false; + } } throw new ReasoningMethodUnsupportedException("Instance check for description " @@ -325,6 +354,11 @@ return atomicConcepts; } + @Override + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + return rc.getDoubleDatatypeMembers(datatypeProperty); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-03-10 17:53:52 UTC (rev 700) @@ -35,6 +35,7 @@ import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.DescriptionVisitor; +import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; @@ -45,6 +46,7 @@ import org.dllearner.core.owl.ObjectMinCardinalityRestriction; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.SimpleDoubleDataRange; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.TypedConstant; import org.dllearner.core.owl.Union; @@ -55,9 +57,13 @@ import org.semanticweb.owl.model.OWLConstant; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDataProperty; +import org.semanticweb.owl.model.OWLDataRange; import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLObjectProperty; +import org.semanticweb.owl.model.OWLTypedConstant; +import org.semanticweb.owl.vocab.OWLRestrictedDataRangeFacetVocabulary; +import org.semanticweb.owl.vocab.XSDVocabulary; /** * Converter from DL-Learner descriptions to OWL API descriptions based @@ -212,7 +218,8 @@ public void visit(DatatypeValueRestriction description) { // convert OWL constant to OWL API constant Constant c = description.getValue(); - OWLConstant constant; + OWLConstant constant = convertConstant(c); + /* if(c instanceof TypedConstant) { Datatype dt = ((TypedConstant)c).getDatatype(); OWLDataType odt = convertDatatype(dt); @@ -225,6 +232,7 @@ constant = factory.getOWLUntypedConstant(uc.getLiteral()); } } + */ // get datatype property DatatypeProperty dtp = description.getRestrictedPropertyExpresssion(); @@ -276,8 +284,28 @@ * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeSomeRestriction) */ public void visit(DatatypeSomeRestriction description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); + + // TODO: currently works only for double min/max + + DatatypeProperty dp = (DatatypeProperty) description.getRestrictedPropertyExpression(); + // currently only double restrictions implemented + SimpleDoubleDataRange dr = (SimpleDoubleDataRange) description.getDataRange(); + Double value = dr.getValue(); + + OWLDataType doubleDataType = factory.getOWLDataType(XSDVocabulary.DOUBLE.getURI()); + OWLTypedConstant constant = factory.getOWLTypedConstant(value.toString(), doubleDataType); + + OWLRestrictedDataRangeFacetVocabulary facet; + if(dr instanceof DoubleMinValue) + facet = OWLRestrictedDataRangeFacetVocabulary.MIN_INCLUSIVE; + else + facet = OWLRestrictedDataRangeFacetVocabulary.MAX_INCLUSIVE; + + OWLDataRange owlDataRange = factory.getOWLDataRangeRestriction(doubleDataType, facet, constant); + OWLDataProperty odp = factory.getOWLDataProperty(URI.create(dp.getName())); + OWLDescription d = factory.getOWLDataSomeRestriction(odp, owlDataRange); + + stack.push(d); } public OWLDataType convertDatatype(Datatype datatype) { @@ -291,4 +319,20 @@ throw new Error("OWLAPIDescriptionConverter: datatype not implemented"); } + private OWLConstant convertConstant(Constant constant) { + OWLConstant owlConstant; + if(constant instanceof TypedConstant) { + Datatype dt = ((TypedConstant)constant).getDatatype(); + OWLDataType odt = convertDatatype(dt); + owlConstant = factory.getOWLTypedConstant(constant.getLiteral(), odt); + } else { + UntypedConstant uc = (UntypedConstant) constant; + if(uc.hasLang()) { + owlConstant = factory.getOWLUntypedConstant(uc.getLiteral(), uc.getLang()); + } else { + owlConstant = factory.getOWLUntypedConstant(uc.getLiteral()); + } + } + return owlConstant; + } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-10 17:53:52 UTC (rev 700) @@ -19,6 +19,7 @@ */ package org.dllearner.refinementoperators; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -29,12 +30,17 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; +import java.util.Map.Entry; import org.dllearner.algorithms.refinement.RefinementOperator; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -119,7 +125,11 @@ // concept comparator private ConceptComparator conceptComparator = new ConceptComparator(); - // Statistik + // splits for double datatype properties in ascening order + private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); + private int maxNrOfSplits = 20; + + // staistics public long mComputationTimeNs = 0; public long topComputationTimeNs = 0; @@ -129,6 +139,7 @@ private boolean useExistsConstructor = true; private boolean useNegation = true; private boolean useBooleanDatatypes = true; + private boolean useDoubleDatatypes = true; private boolean disjointChecks = true; private boolean instanceBasedDisjoints = true; @@ -165,38 +176,29 @@ dpDomains.put(dp, rs.getDomain(dp)); } + // compute splits for double datatype properties + for(DatatypeProperty dp : rs.getDoubleDatatypeProperties()) { + computeSplits(dp); + } + /* - NamedClass struc = new NamedClass("http://dl-learner.org/carcinogenesis#Compound"); + NamedClass struc = new NamedClass("http://dl-learner.org/carcinogenesis#Atom"); ObjectProperty op = new ObjectProperty("http://dl-learner.org/carcinogenesis#hasAtom"); - ObjectAllRestriction oar = new ObjectAllRestriction(op,struc); - String str = "((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS FALSE) OR ALL \"http://dl-learner.org/carcinogenesis#hasAtom\".TOP)"; - Description desc = null; - try { - desc = KBParser.parseConcept(str); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -// System.out.println(oar.getLength()); -// computeTopRefinements(3,struc); -// for(Description d : topARefinements.get(struc).get(1)) { - // bei 3 ist noch alles OK, bei 4 seltsamer Fehler mit Union - Set<Description> ds = refine(struc,10,null,struc); - Set<Description> improper = new HashSet<Description>(); + ObjectSomeRestriction oar = new ObjectSomeRestriction(op,Thing.instance); + + Set<Description> ds = refine(Thing.instance,3,null,struc); +// Set<Description> improper = new HashSet<Description>(); for(Description d : ds) { -// if(d instanceof Union) - if(rs.subsumes(d, struc)) { - improper.add(d); +// if(rs.subsumes(d, struc)) { +// improper.add(d); System.out.println(d); - } +// } } -// System.out.println(refine(Thing.instance,7,null,struc).size()); System.out.println(ds.size()); - System.out.println(improper.size()); +// System.out.println(improper.size()); System.exit(0); */ - - + if(startClass != null) this.startClass = startClass; } @@ -356,6 +358,36 @@ refinements.add(new ObjectAllRestriction(moreSpecialRole, description.getChild(0))); } + } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + if(dr instanceof DoubleMaxValue) { + double value = ((DoubleMaxValue)dr).getValue(); + // find out which split value was used + int splitIndex = splits.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex - 1; + if(newSplitIndex >= 0) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,max); + refinements.add(newDSR); +// System.out.println(description + " => " + newDSR); + } + } else if(dr instanceof DoubleMinValue) { + double value = ((DoubleMinValue)dr).getValue(); + // find out which split value was used + int splitIndex = splits.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex + 1; + if(newSplitIndex < splits.get(dp).size()) { + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,min); + refinements.add(newDSR); + } + } } // if a refinement is not Bottom, Top, ALL r.Bottom a refinement of top can be appended @@ -606,6 +638,16 @@ } } + if(useDoubleDatatypes) { + Set<DatatypeProperty> doubleDPs = rs.getDoubleDatatypeProperties(); + for(DatatypeProperty dp : doubleDPs) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(splits.get(dp).size()-1)); + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + m.put(3,m3); mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; @@ -677,6 +719,24 @@ } } + if(useDoubleDatatypes) { + Set<DatatypeProperty> doubleDPs = mgdd.get(nc); +// System.out.println("cached disjoints " + cachedDisjoints); +// System.out.println("appOP " + appOP); +// System.out.println("appBD " + appBD); +// System.out.println("appDD " + appDD); +// System.out.println("mgr " + mgr); +// System.out.println("mgbd " + mgbd); +// System.out.println("mgdd " + mgdd); + + for(DatatypeProperty dp : doubleDPs) { + DoubleMaxValue max = new DoubleMaxValue(splits.get(dp).get(splits.get(dp).size()-1)); + DoubleMinValue min = new DoubleMinValue(splits.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + mA.get(nc).put(3,m3); mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; @@ -755,10 +815,11 @@ appBD.put(domain, applicableBDPs); // double datatype properties - Set<DatatypeProperty> mostGeneralDDPs = rs.getBooleanDatatypeProperties(); + Set<DatatypeProperty> mostGeneralDDPs = rs.getDoubleDatatypeProperties(); Set<DatatypeProperty> applicableDDPs = new TreeSet<DatatypeProperty>(); for(DatatypeProperty role : mostGeneralDDPs) { Description d = (NamedClass) rs.getDomain(role); +// System.out.println("domain: " + d); if(!isDisjoint(domain,d)) applicableDDPs.add(role); } @@ -788,16 +849,18 @@ } private boolean isDisjoint(Description d1, Description d2) { - // equal concepts are not disjoint (unless equivalent to bottom) -// if(conceptComparator.compare(d1, d2)==0) -// return false; +// System.out.println("| " + d1 + " " + d2); +// System.out.println("| " + cachedDisjoints); + // check whether we have cached this query Map<Description,Boolean> tmp = cachedDisjoints.get(d1); Boolean tmp2 = null; if(tmp != null) tmp2 = tmp.get(d2); +// System.out.println("| " + tmp + " " + tmp2); + if(tmp2==null) { Boolean result; if(instanceBasedDisjoints) { @@ -809,24 +872,33 @@ // add the result to the cache (we add it twice such that // the order of access does not matter) +// System.out.println("| result: " + result); + // create new entries if necessary - Map<Description,Boolean> map = new TreeMap<Description,Boolean>(conceptComparator); + Map<Description,Boolean> map1 = new TreeMap<Description,Boolean>(conceptComparator); + Map<Description,Boolean> map2 = new TreeMap<Description,Boolean>(conceptComparator); if(tmp == null) - cachedDisjoints.put(d1, map); + cachedDisjoints.put(d1, map1); if(!cachedDisjoints.containsKey(d2)) - cachedDisjoints.put(d2, map); + cachedDisjoints.put(d2, map2); // add result symmetrically in the description matrix cachedDisjoints.get(d1).put(d2, result); cachedDisjoints.get(d2).put(d1, result); +// System.out.println("---"); return result; - } else + } else { +// System.out.println("==="); return tmp2; + } } private boolean isDisjointInstanceBased(Description d1, Description d2) { - Set<Individual> d1Instances = rs.retrieval(d1); - Set<Individual> d2Instances = rs.retrieval(d2); + SortedSet<Individual> d1Instances = rs.retrieval(d1); + SortedSet<Individual> d2Instances = rs.retrieval(d2); +// System.out.println(d1 + " " + d2); +// System.out.println(d1 + " " + d1Instances); +// System.out.println(d2 + " " + d2Instances); for(Individual d1Instance : d1Instances) { if(d2Instances.contains(d1Instance)) return false; @@ -870,4 +942,34 @@ return !rs.subsumes(d, b); } + private void computeSplits(DatatypeProperty dp) { + Set<Double> valuesSet = new TreeSet<Double>(); +// Set<Individual> individuals = rs.getIndividuals(); + Map<Individual,SortedSet<Double>> valueMap = rs.getDoubleDatatypeMembers(dp); + // add all values to the set (duplicates will be remove automatically) + for(Entry<Individual,SortedSet<Double>> e : valueMap.entrySet()) + valuesSet.addAll(e.getValue()); + // convert set to a list where values are sorted + List<Double> values = new LinkedList<Double>(valuesSet); + Collections.sort(values); + + int nrOfValues = values.size(); + // create split set + List<Double> splitsDP = new LinkedList<Double>(); + for(int splitNr=0; splitNr < maxNrOfSplits; splitNr++) { + int index; + if(nrOfValues<=maxNrOfSplits) + index = splitNr; + else + index = (int) Math.floor(splitNr * (double)nrOfValues/(maxNrOfSplits+1)); + + double value = 0.5*(values.get(index)+values.get(index+1)); + splitsDP.add(value); + } + splits.put(dp, splitsDP); + +// System.out.println(values); +// System.out.println(splits); +// System.exit(0); + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-03-09 19:25:46 UTC (rev 699) +++ trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-03-10 17:53:52 UTC (rev 700) @@ -4,12 +4,17 @@ import java.util.Set; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.SimpleDoubleDataRange; import org.dllearner.core.owl.Union; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.ObjectQuantorRestriction; @@ -94,8 +99,44 @@ return cmp; } else return -1; + } else if(concept1 instanceof DatatypeSomeRestriction) { + if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) { + return 1; + } else if(concept2 instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) concept1; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DatatypeSomeRestriction dsr2 = (DatatypeSomeRestriction) concept2; + DatatypeProperty dp2 = (DatatypeProperty) dsr2.getRestrictedPropertyExpression(); + + // first criterion: name of the properties + int cmp = rc.compare(dp, dp2); + + if(cmp == 0) { + SimpleDoubleDataRange dr = (SimpleDoubleDataRange) dsr.getDataRange(); + SimpleDoubleDataRange dr2 = (SimpleDoubleDataRange) dsr2.getDataRange(); + + // equal classes + if((dr instanceof DoubleMaxValue && dr2 instanceof DoubleMaxValue) + || (dr instanceof DoubleMinValue && dr2 instanceof DoubleMinValue)) { + double val1 = dr.getValue(); + double val2 = dr2.getValue(); + if(val1 > val2) + return 1; + else if(val1 == val2) + return 0; + else + return -1; + + } else if(dr instanceof DoubleMaxValue) + return 1; + else + return -1; + } else + return cmp; + } else + return -1; } else if(concept1 instanceof Thing) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) + if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction || concept2 instanceof DatatypeSomeRestriction) return 1; else if(concept2 instanceof Thing) return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-09 19:26:51
|
Revision: 699 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=699&view=rev Author: jenslehmann Date: 2008-03-09 12:25:46 -0700 (Sun, 09 Mar 2008) Log Message: ----------- small algorithm bug fixes and reasoning improvements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-09 19:25:46 UTC (rev 699) @@ -47,8 +47,8 @@ private Set<Individual> coveredNegatives; // the method by which quality was evaluated in this node - public enum QualityEvaluationMethod { TOP, REASONER, TOO_WEAK_LIST, OVERLY_GENERAL_LIST }; - private QualityEvaluationMethod qualityEvaluationMethod = QualityEvaluationMethod.TOP; + public enum QualityEvaluationMethod { START, REASONER, TOO_WEAK_LIST, OVERLY_GENERAL_LIST }; + private QualityEvaluationMethod qualityEvaluationMethod = QualityEvaluationMethod.START; // all properties of a node in the search tree private Description concept; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-09 19:25:46 UTC (rev 699) @@ -599,6 +599,7 @@ // + nrOfNegativeExamples - bestNode.getCoveredNegatives().size())/(double)nrOfExamples); // Refinementoperator auf Konzept anwenden // String bestNodeString = "currently best node: " + bestNode + " accuracy: " + df.format(accuracy) + "%"; + System.out.println("start node: " + startNode.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); String bestNodeString = "currently best node: " + bestNode.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI); // searchTree += bestNodeString + "\n"; System.out.println(bestNodeString); @@ -612,6 +613,7 @@ // System.out.println("max. number of children of a node: " + maxNrOfChildren); System.out.println("subsumption time: " + Helper.prettyPrintNanoSeconds(rs.getSubsumptionReasoningTimeNs())); System.out.println("instance check time: " + Helper.prettyPrintNanoSeconds(rs.getInstanceCheckReasoningTimeNs())); + System.out.println("retrieval time: " + Helper.prettyPrintNanoSeconds(rs.getRetrievalReasoningTimeNs())); } if(computeBenchmarkInformation) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-09 19:25:46 UTC (rev 699) @@ -19,6 +19,10 @@ */ package org.dllearner.algorithms.refexamples; +import java.util.List; + +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.Description; import org.dllearner.utilities.ConceptComparator; /** @@ -73,13 +77,14 @@ private double expansionPenaltyFactor; private double gainBonusFactor; private double nodeChildPenalty = 0.0001; + private double startNodeBonus = 0.8; // examples private int nrOfNegativeExamples; private int nrOfExamples; public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples) { - this(nrOfPositiveExamples, nrOfNegativeExamples, 0.03, 0.5); + this(nrOfPositiveExamples, nrOfNegativeExamples, 0.02, 0.5); } public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, double expansionPenaltyFactor, double gainBonusFactor) { @@ -113,8 +118,11 @@ if(parent != null) { double parentAccuracy = getAccuracy(parent.getCoveredPositives().size(),parent.getCoveredNegatives().size()); gain = accuracy - parentAccuracy; + } else { + accuracy += startNodeBonus; } - return accuracy + gainBonusFactor * gain - expansionPenaltyFactor * node.getHorizontalExpansion() - nodeChildPenalty * node.getChildren().size(); + int he = node.getHorizontalExpansion() - getHeuristicLengthBonus(node.getConcept()); + return accuracy + gainBonusFactor * gain - expansionPenaltyFactor * he - nodeChildPenalty * node.getChildren().size(); } private double getAccuracy(int coveredPositives, int coveredNegatives) { @@ -127,4 +135,18 @@ return multi.getNodeScore(node); } + // this function can be used to give some constructs a length bonus + // compared to their syntactic length + private static int getHeuristicLengthBonus(Description description) { + int bonus = 0; + + if(description instanceof BooleanValueRestriction) + bonus = 1; + + List<Description> children = description.getChildren(); + for(Description child : children) { + bonus += getHeuristicLengthBonus(child); + } + return bonus; + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-03-09 19:25:46 UTC (rev 699) @@ -50,5 +50,12 @@ public boolean getBooleanValue() { return booleanValue; } - + + /** + * Boolean value restrictions have length 2, because they encode two + * pieces of information: the property and the boolean value. + */ + public int getLength() { + return 2; + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-03-09 19:25:46 UTC (rev 699) @@ -29,7 +29,7 @@ * @author Jens Lehmann * */ -public class DatatypeValueRestriction extends ValueRestriction { +public abstract class DatatypeValueRestriction extends ValueRestriction { public DatatypeValueRestriction(DatatypeProperty restrictedPropertyExpression, Constant value) { super(restrictedPropertyExpression, value); @@ -55,9 +55,12 @@ /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#getLength() */ - public int getLength() { - return 1 + restrictedPropertyExpression.getLength() + value.getLength(); - } + // we do not add the + 1 here because e.g. for boolean values we + // probably do not want to add it while for double value we may + // add it (because "<=" ">=" are possible while boolean has only "=") +// public int getLength() { +// return 1 + restrictedPropertyExpression.getLength() + value.getLength(); +// } /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-09 19:25:46 UTC (rev 699) @@ -659,6 +659,31 @@ return map; } + public Map<Individual, SortedSet<Double>> getDoubleValues(DatatypeProperty datatypeProperty) { + OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); + Map<Individual, SortedSet<Double>> map = new TreeMap<Individual, SortedSet<Double>>(); + for(Individual i : individuals) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(i.getName())); + + // get all related individuals via OWL API + Set<OWLConstant> inds = null; + try { + inds = reasoner.getRelatedValues(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + // convert data back to DL-Learner structures + SortedSet<Double> is = new TreeSet<Double>(); + for(OWLConstant oi : inds) { + Double d = Double.parseDouble(oi.getLiteral()); + is.add(d); + } + map.put(i, is); + } + return map; + } + @Override public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) { OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-09 17:49:11 UTC (rev 698) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-09 19:25:46 UTC (rev 699) @@ -129,6 +129,7 @@ private boolean useExistsConstructor = true; private boolean useNegation = true; private boolean useBooleanDatatypes = true; + private boolean disjointChecks = true; private boolean instanceBasedDisjoints = true; // caches for reasoner queries @@ -164,18 +165,38 @@ dpDomains.put(dp, rs.getDomain(dp)); } - -// NamedClass struc = new NamedClass("http://dl-learner.org/carcinogenesis#Structure"); + /* + NamedClass struc = new NamedClass("http://dl-learner.org/carcinogenesis#Compound"); + ObjectProperty op = new ObjectProperty("http://dl-learner.org/carcinogenesis#hasAtom"); + ObjectAllRestriction oar = new ObjectAllRestriction(op,struc); + String str = "((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS FALSE) OR ALL \"http://dl-learner.org/carcinogenesis#hasAtom\".TOP)"; + Description desc = null; + try { + desc = KBParser.parseConcept(str); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// System.out.println(oar.getLength()); // computeTopRefinements(3,struc); // for(Description d : topARefinements.get(struc).get(1)) { // bei 3 ist noch alles OK, bei 4 seltsamer Fehler mit Union -// for(Description d : refine(Thing.instance,3,null,struc)) { + Set<Description> ds = refine(struc,10,null,struc); + Set<Description> improper = new HashSet<Description>(); + for(Description d : ds) { // if(d instanceof Union) -// System.out.println(d); -// } + if(rs.subsumes(d, struc)) { + improper.add(d); + System.out.println(d); + } + } // System.out.println(refine(Thing.instance,7,null,struc).size()); -// System.exit(0); + System.out.println(ds.size()); + System.out.println(improper.size()); + System.exit(0); + */ + if(startClass != null) this.startClass = startClass; } @@ -199,15 +220,16 @@ public Set<Description> refine(Description description, int maxLength, List<Description> knownRefinements, Description currDomain) { -// System.out.println(description + " " + currDomain); +// System.out.println(description + " " + currDomain + " " + maxLength); // actions needing to be performed if this is the first time the // current domain is used if(!(currDomain instanceof Thing) && !topARefinementsLength.containsKey(currDomain)) topARefinementsLength.put((NamedClass)currDomain, 0); - // TODO: check whether using list or set makes more sense + // check whether using list or set makes more sense // here; and whether HashSet or TreeSet should be used + // => TreeSet because duplicates are possible Set<Description> refinements = new TreeSet<Description>(conceptComparator); // used as temporary variable @@ -261,7 +283,8 @@ // (non-recursive variant because only depth 1 was modified) ConceptTransformation.cleanConceptNonRecursive(mc); ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); - + + refinements.add(mc); } } @@ -270,6 +293,8 @@ // refine one of the elements for(Description child : description.getChildren()) { +// System.out.println("union child: " + child + " " + maxLength + " " + description.getLength() + " " + child.getLength()); + // refine child tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); @@ -377,9 +402,10 @@ // this can avoid a lot of superfluous computation in the algorithm e.g. // when A1 looks good, so many refinements of the form (A1 OR (A2 AND A3)) // are generated which are all equal to A1 due to disjointness of A2 and A3 - if(c instanceof NamedClass && isDisjoint(description, c)) - // refinements.add(mc); + if(disjointChecks && c instanceof NamedClass && description instanceof NamedClass && isDisjoint(description, c)) { skip = true; +// System.out.println(c + " ignored when refining " + description); + } if(!skip) { Intersection mc = new Intersection(); @@ -545,14 +571,23 @@ SortedSet<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); m.put(1,m1); + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); if(useNegation) { Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); - SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); for(Description c : m2tmp) { m2.add(new Negation(c)); } - m.put(2,m2); } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m2.add(new BooleanValueRestriction(dp,true)); + m2.add(new BooleanValueRestriction(dp,false)); + } + } + m.put(2,m2); SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); if(useExistsConstructor) { @@ -571,15 +606,6 @@ } } - // boolean datatypes, e.g. testPositive = true - if(useBooleanDatatypes) { - Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); - for(DatatypeProperty dp : booleanDPs) { - m3.add(new BooleanValueRestriction(dp,true)); - m3.add(new BooleanValueRestriction(dp,false)); - } - } - m.put(3,m3); mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; @@ -600,6 +626,7 @@ SortedSet<Description> m1 = rs.getMoreSpecialConcepts(nc); mA.get(nc).put(1,m1); + SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); if(useNegation) { // the definition in the paper is more complex, but acutally // we only have to insert the most specific concepts satisfying @@ -608,7 +635,7 @@ // subClassOf A and thus: if A and B are disjoint then also A' // and B; if not A AND B = B then also not A' AND B = B SortedSet<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); - SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); + for(Description c : m2tmp) { if(c instanceof Thing) m2.add(c); @@ -617,13 +644,23 @@ if(!isNotADisjoint(a, nc) && isNotAMeaningful(a, nc)) m2.add(new Negation(a)); } + } + } + + // compute applicable properties + computeMg(nc); + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = mgbd.get(nc); + for(DatatypeProperty dp : booleanDPs) { + m2.add(new BooleanValueRestriction(dp,true)); + m2.add(new BooleanValueRestriction(dp,false)); } - mA.get(nc).put(2,m2); } + + mA.get(nc).put(2,m2); - // compute applicable properties - computeMg(nc); - SortedSet<Description> m3 = new TreeSet<Description>(conceptComparator); if(useExistsConstructor) { for(ObjectProperty r : mgr.get(nc)) { @@ -640,15 +677,6 @@ } } - // boolean datatypes, e.g. testPositive = true - if(useBooleanDatatypes) { - Set<DatatypeProperty> booleanDPs = mgbd.get(nc); - for(DatatypeProperty dp : booleanDPs) { - m3.add(new BooleanValueRestriction(dp,true)); - m3.add(new BooleanValueRestriction(dp,false)); - } - } - mA.get(nc).put(3,m3); mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-09 17:49:19
|
Revision: 698 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=698&view=rev Author: tonytacker Date: 2008-03-09 10:49:11 -0700 (Sun, 09 Mar 2008) Log Message: ----------- removed set-button from checkBoxList (special layout for WidgetPanelStringSet) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-03-09 17:49:11 UTC (rev 698) @@ -20,7 +20,8 @@ package org.dllearner.gui; import javax.swing.*; - +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -33,17 +34,19 @@ * * @author Tilo Hielscher */ -public class CheckBoxList extends JPanel { +public class CheckBoxList extends JPanel implements ActionListener { private static final long serialVersionUID = -7119007550662195455L; private JPanel checkBoxPanel = new JPanel(); private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); + private WidgetPanelStringSet panel; /** * Make a JPanel with GridBagLayout. */ - public CheckBoxList() { + public CheckBoxList(WidgetPanelStringSet panel) { + this.panel = panel; checkBoxPanel.setLayout(gridbag); add(checkBoxPanel, BorderLayout.CENTER); constraints.anchor = GridBagConstraints.WEST; @@ -57,7 +60,9 @@ * will add to list. */ public void add(String label) { - list.add(new JCheckBox(label)); + JCheckBox chkBox = new JCheckBox(label); + list.add(chkBox); + chkBox.addActionListener(this); update(); } @@ -113,4 +118,8 @@ gbc.weightx = wx; gbc.weighty = wy; } + + public void actionPerformed(ActionEvent e) { + panel.specialSet(); + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 17:49:11 UTC (rev 698) @@ -153,6 +153,7 @@ } // tree if (e.getSource() == treeButton) { + @SuppressWarnings("unused") TreeWindow a = new TreeWindow(config); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-09 17:49:11 UTC (rev 698) @@ -79,8 +79,7 @@ private JList stringList = new JList(); private DefaultListModel listModel = new DefaultListModel(); - private JButton setButton = new JButton("set"); - private CheckBoxList cBL = new CheckBoxList(); + private CheckBoxList cBL = new CheckBoxList(this); public WidgetPanelStringSet(Config config, Component component, Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { @@ -100,7 +99,6 @@ addButton.addActionListener(this); removeButton.addActionListener(this); clearButton.addActionListener(this); - setButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { @@ -132,15 +130,17 @@ // set entry value = exampleSet; setEntry(); - } else { - // SPECIAL LAYOUT - // setButton - if (e.getSource() == setButton) { - value = cBL.getSelections(); - setEntry(); - } } + } + /** + * Use this, to set entry for layout 2. + */ + public void specialSet() { + if (isSpecial()) { + this.value = cBL.getSelections(); + setEntry(); + } } @Override @@ -216,10 +216,6 @@ buildConstraints(constraints, 0, 1, 1, 1, 100, 100); gridbag.setConstraints(cBL, constraints); widgetPanel.add(cBL, constraints); - // setButton - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(setButton, constraints); - widgetPanel.add(setButton, constraints); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase("positiveExamples") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-09 11:49:31
|
Revision: 697 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=697&view=rev Author: jenslehmann Date: 2008-03-09 04:49:21 -0700 (Sun, 09 Mar 2008) Log Message: ----------- - added disjointness test (including result cache) to further reduce refinements in new operator - bug fix for deactivated negation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-09 02:16:01 UTC (rev 696) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-09 11:49:21 UTC (rev 697) @@ -260,7 +260,8 @@ bestNode = candidates.last(); // extend best node newCandidates.clear(); - // TODO: why is the best node tempoariliy removed from the candidates set? + // best node is removed temporarily, because extending it can + // change its evaluation candidates.remove(bestNode); extendNodeProper(bestNode, bestNode.getHorizontalExpansion()+1); candidates.add(bestNode); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-09 02:16:01 UTC (rev 696) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-09 11:49:21 UTC (rev 697) @@ -302,6 +302,11 @@ @Override public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException { + if(concept instanceof NamedClass) + return classInstancesPos.get((NamedClass)concept); + else if(concept instanceof Negation && concept.getChild(0) instanceof NamedClass) + return classInstancesNeg.get((NamedClass)concept.getChild(0)); + // return rs.retrieval(concept); SortedSet<Individual> inds = new TreeSet<Individual>(); for(Individual i : individuals) { Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-09 02:16:01 UTC (rev 696) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-09 11:49:21 UTC (rev 697) @@ -35,6 +35,7 @@ import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DatatypeProperty; 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.Negation; @@ -127,11 +128,14 @@ private boolean useAllConstructor = true; private boolean useExistsConstructor = true; private boolean useNegation = true; - private boolean useBooleanDatatypes = true; + private boolean useBooleanDatatypes = true; + private boolean instanceBasedDisjoints = true; // caches for reasoner queries + private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); + // private Map<NamedClass,Map<NamedClass,Boolean>> abDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); - private Map<NamedClass,Map<NamedClass,Boolean>> notABDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); +// private Map<NamedClass,Map<NamedClass,Boolean>> notABDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); // private Map<NamedClass,Map<NamedClass,Boolean>> notABMeaningful = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); public RhoDRDown(ReasoningService reasoningService) { @@ -160,6 +164,18 @@ dpDomains.put(dp, rs.getDomain(dp)); } + +// NamedClass struc = new NamedClass("http://dl-learner.org/carcinogenesis#Structure"); +// computeTopRefinements(3,struc); +// for(Description d : topARefinements.get(struc).get(1)) { + // bei 3 ist noch alles OK, bei 4 seltsamer Fehler mit Union +// for(Description d : refine(Thing.instance,3,null,struc)) { +// if(d instanceof Union) +// System.out.println(d); +// } +// System.out.println(refine(Thing.instance,7,null,struc).size()); +// System.exit(0); + if(startClass != null) this.startClass = startClass; } @@ -245,8 +261,7 @@ // (non-recursive variant because only depth 1 was modified) ConceptTransformation.cleanConceptNonRecursive(mc); ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); - - refinements.add(mc); + } } @@ -318,8 +333,9 @@ } - // if a refinement is neither Bottom nor Top a refinement of top can be appended - if(!(description instanceof Thing) && !(description instanceof Nothing)) { + // if a refinement is not Bottom, Top, ALL r.Bottom a refinement of top can be appended + if(!(description instanceof Thing) && !(description instanceof Nothing) + && !(description instanceof ObjectAllRestriction && description.getChild(0) instanceof Nothing)) { // -1 because of the AND symbol which is appended int topRefLength = maxLength - description.getLength() - 1; @@ -357,6 +373,14 @@ } } + // perform a disjointness check when named classes are added; + // this can avoid a lot of superfluous computation in the algorithm e.g. + // when A1 looks good, so many refinements of the form (A1 OR (A2 AND A3)) + // are generated which are all equal to A1 due to disjointness of A2 and A3 + if(c instanceof NamedClass && isDisjoint(description, c)) + // refinements.add(mc); + skip = true; + if(!skip) { Intersection mc = new Intersection(); mc.addChild(description); @@ -365,13 +389,20 @@ // clean and transform to ordered negation normal form ConceptTransformation.cleanConceptNonRecursive(mc); ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); - + refinements.add(mc); } } } } +// for(Description refinement : refinements) { +// if((refinement instanceof Intersection || refinement instanceof Union) && refinement.getChildren().size()<2) { +// System.out.println(description + " " + refinement + " " + currDomain + " " + maxLength); +// System.exit(0); +// } +// } + return refinements; } @@ -424,36 +455,52 @@ topARefinements.get(domain).get(i).addAll(mA.get(domain).get(i)); // combinations has several numbers => generate disjunct } else { - SortedSet<Union> baseSet = new TreeSet<Union>(conceptComparator); + + // check whether the combination makes sense, i.e. whether + // all lengths mentioned in it have corresponding elements + // e.g. when negation is deactivated there won't be elements of + // length 2 in M + boolean validCombo = true; for(Integer j : combo) { - if(domain == null) - baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); - else - baseSet = MathOperations.incCrossProduct(baseSet, mA.get(domain).get(j)); + if((domain == null && m.get(j).size()==0) || + (domain != null && mA.get(domain).get(j).size()==0)) + validCombo = false; } - // convert all concepts in ordered negation normal form - for(Description concept : baseSet) { - ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); - } - - // apply the exists filter (throwing out all refinements with - // double \exists r for any r) - // TODO: similar filtering can be done for boolean datatype - // properties - if(applyExistsFilter) { - Iterator<Union> it = baseSet.iterator(); - while(it.hasNext()) { - if(MathOperations.containsDoubleObjectSomeRestriction(it.next())) - it.remove(); + if(validCombo) { + + SortedSet<Union> baseSet = new TreeSet<Union>(conceptComparator); + for(Integer j : combo) { + if(domain == null) + baseSet = MathOperations.incCrossProduct(baseSet, m.get(j)); + else + baseSet = MathOperations.incCrossProduct(baseSet, mA.get(domain).get(j)); } + + // convert all concepts in ordered negation normal form + for(Description concept : baseSet) { + ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); + } + + // apply the exists filter (throwing out all refinements with + // double \exists r for any r) + // TODO: similar filtering can be done for boolean datatype + // properties + if(applyExistsFilter) { + Iterator<Union> it = baseSet.iterator(); + while(it.hasNext()) { + if(MathOperations.containsDoubleObjectSomeRestriction(it.next())) + it.remove(); + } + } + + // add computed refinements + if(domain == null) + topRefinements.get(i).addAll(baseSet); + else + topARefinements.get(domain).get(i).addAll(baseSet); + } - - // add computed refinements - if(domain == null) - topRefinements.get(i).addAll(baseSet); - else - topARefinements.get(domain).get(i).addAll(baseSet); } } @@ -690,31 +737,99 @@ appDD.put(domain, applicableDDPs); } + // returns true of the intersection contains elements disjoint + // to the given description (if true adding the description to + // the intersection results in a description equivalent to bottom) + // e.g. OldPerson AND YoungPerson; Nitrogen-34 AND Tin-113 + // Note: currently we only check named classes in the intersection, + // it would be interesting to see whether it makes sense to extend this + // (advantage: less refinements, drawback: operator will need infinitely many + // reasoner queries in the long run) + @SuppressWarnings({"unused"}) + private boolean containsDisjoints(Intersection intersection, Description d) { + List<Description> children = intersection.getChildren(); + for(Description child : children) { + if(d instanceof Nothing) + return true; + else if(child instanceof NamedClass) { + if(isDisjoint((NamedClass)child, d)) + return true; + } + } + return false; + } + + private boolean isDisjoint(Description d1, Description d2) { + // equal concepts are not disjoint (unless equivalent to bottom) +// if(conceptComparator.compare(d1, d2)==0) +// return false; + + // check whether we have cached this query + Map<Description,Boolean> tmp = cachedDisjoints.get(d1); + Boolean tmp2 = null; + if(tmp != null) + tmp2 = tmp.get(d2); + + if(tmp2==null) { + Boolean result; + if(instanceBasedDisjoints) { + result = isDisjointInstanceBased(d1,d2); + } else { + Description d = new Intersection(d1, d2); + result = rs.subsumes(new Nothing(), d); + } + // add the result to the cache (we add it twice such that + // the order of access does not matter) + + // create new entries if necessary + Map<Description,Boolean> map = new TreeMap<Description,Boolean>(conceptComparator); + if(tmp == null) + cachedDisjoints.put(d1, map); + if(!cachedDisjoints.containsKey(d2)) + cachedDisjoints.put(d2, map); + + // add result symmetrically in the description matrix + cachedDisjoints.get(d1).put(d2, result); + cachedDisjoints.get(d2).put(d1, result); + return result; + } else + return tmp2; + } + + private boolean isDisjointInstanceBased(Description d1, Description d2) { + Set<Individual> d1Instances = rs.retrieval(d1); + Set<Individual> d2Instances = rs.retrieval(d2); + for(Individual d1Instance : d1Instances) { + if(d2Instances.contains(d1Instance)) + return false; + } + return true; + } + + /* // computes whether two classes are disjoint; this should be computed // by the reasoner only ones and otherwise taken from a matrix - // => this has low importance in the long run, because M is cached anyway, - // but avoids many duplicate queries when computing M private boolean isDisjoint(NamedClass a, Description d) { // we need to test whether A AND B is equivalent to BOTTOM Description d2 = new Intersection(a, d); return rs.subsumes(new Nothing(), d2); - } + }*/ // we need to test whether NOT A AND B is equivalent to BOTTOM private boolean isNotADisjoint(NamedClass a, NamedClass b) { - Map<NamedClass,Boolean> tmp = notABDisjoint.get(a); - Boolean tmp2 = null; - if(tmp != null) - tmp2 = tmp.get(b); - - if(tmp2==null) { +// Map<NamedClass,Boolean> tmp = notABDisjoint.get(a); +// Boolean tmp2 = null; +// if(tmp != null) +// tmp2 = tmp.get(b); +// +// if(tmp2==null) { Description notA = new Negation(a); Description d = new Intersection(notA, b); Boolean result = rs.subsumes(new Nothing(), d); // ... add to cache ... return result; - } else - return tmp2; +// } else +// return tmp2; } // we need to test whether NOT A AND B = B This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-09 02:16:08
|
Revision: 696 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=696&view=rev Author: tonytacker Date: 2008-03-08 18:16:01 -0800 (Sat, 08 Mar 2008) Log Message: ----------- add an example tree in new window for tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 05:23:20 UTC (rev 695) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 02:16:01 UTC (rev 696) @@ -36,7 +36,7 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton; + private JButton runButton, stopButton, treeButton; private JTextArea infoArea; private Config config; @@ -67,11 +67,13 @@ runButton = new JButton("Run"); runButton.addActionListener(this); + showPanel.add(runButton); stopButton = new JButton("Stop"); stopButton.addActionListener(this); - - showPanel.add(runButton); showPanel.add(stopButton); + treeButton = new JButton("Tree"); + treeButton.addActionListener(this); + showPanel.add(treeButton); infoPanel.setLayout(gridbag); constraints.anchor = GridBagConstraints.WEST; @@ -149,6 +151,10 @@ if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { thread.exit(); } + // tree + if (e.getSource() == treeButton) { + TreeWindow a = new TreeWindow(config); + } } /** Added: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-09 02:16:01 UTC (rev 696) @@ -0,0 +1,65 @@ +package org.dllearner.gui; + +/** + * 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/>. + * + */ + +import javax.swing.*; +import javax.swing.tree.*; + +/** + * TreeWindow + * + * @author Tilo Hielscher + */ +public class TreeWindow extends JFrame { + + private static final long serialVersionUID = -5807192061389763835L; + + @SuppressWarnings("unused") + private Config config; + + public TreeWindow(Config config) { + this.config = config; + this.setTitle("DL-Learner Tree"); + this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + this.setLocationByPlatform(true); + this.setSize(300, 400); + + // set icon + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); + + // tree + DefaultMutableTreeNode root = new DefaultMutableTreeNode( "root" ); + for ( int knot = 0; knot < 4; knot++ ) + { + DefaultMutableTreeNode node = new DefaultMutableTreeNode( "knot " + knot ); + root.add( node ); + for ( int leaf = 1; leaf < 4; leaf++ ) + node.add( new DefaultMutableTreeNode("leaf " + (knot*3+leaf )) ); + } + JTree tree = new JTree( root ); + this.add( new JScrollPane( tree ) ); + + this.setVisible(true); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-08 05:23:22
|
Revision: 695 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=695&view=rev Author: tonytacker Date: 2008-03-07 21:23:20 -0800 (Fri, 07 Mar 2008) Log Message: ----------- cleared code for better reading Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 04:58:56 UTC (rev 694) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 05:23:20 UTC (rev 695) @@ -28,7 +28,6 @@ import java.util.List; import javax.swing.*; - /** * @author Tilo Hielscher * @@ -98,7 +97,7 @@ percent[i] = new JLabel("-"); } - // name, bar, time + // layout for name, bar, time for (int i = 0; i < 5; i++) { buildConstraints(constraints, 0, i, 1, 1, 1, 1); gridbag.setConstraints(name[i], constraints); @@ -181,10 +180,12 @@ time[0].setText(makeTime(algorithmRunTime)); percent[0].setText("100%"); } - overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); - bar[1].update((double) overallReasoningTime / (double) algorithmRunTime); - time[1].setText(makeTime(overallReasoningTime)); - percent[1].setText(Percent(overallReasoningTime, algorithmRunTime)); + if (config.getReasoningService() != null) { + overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); + bar[1].update((double) overallReasoningTime / (double) algorithmRunTime); + time[1].setText(makeTime(overallReasoningTime)); + percent[1].setText(Percent(overallReasoningTime, algorithmRunTime)); + } if (config.getReasoningService().getNrOfInstanceChecks() > 0) { instanceCheckReasoningTime = config.getReasoningService() .getInstanceCheckReasoningTimeNs(); @@ -285,7 +286,7 @@ /** * Make a string from list, every entry in new line. * - * @param listDescription + * @param list * it is the list. * @return the string. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-08 04:58:59
|
Revision: 694 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=694&view=rev Author: tonytacker Date: 2008-03-07 20:58:56 -0800 (Fri, 07 Mar 2008) Log Message: ----------- improved output for best solutions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 04:16:34 UTC (rev 693) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 04:58:56 UTC (rev 694) @@ -25,8 +25,10 @@ import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; import javax.swing.*; + /** * @author Tilo Hielscher * @@ -162,9 +164,10 @@ infoArea.setText(""); // best solutions - if (config.getLearningAlgorithm().getBestSolutions(5) != null) - infoArea.append("BestSolutions:\n" - + config.getLearningAlgorithm().getBestSolutions(5).toString() + "\n\n"); + if (config.getLearningAlgorithm().getBestSolutions(5) != null) { + infoArea.append("Best solutions: \n\n" + + listToString(config.getLearningAlgorithm().getBestSolutions(10)) + "\n"); + } // solution score // if (config.getLearningAlgorithm().getSolutionScore() != null) // infoArea.append("SolutionScore:\n" @@ -278,4 +281,19 @@ gbc.weightx = wx; gbc.weighty = wy; } + + /** + * Make a string from list, every entry in new line. + * + * @param listDescription + * it is the list. + * @return the string. + */ + public String listToString(List<?> list) { + String string = ""; + for (int i = 0; i < list.size(); i++) { + string += list.get(i) + "\n"; + } + return string; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-08 04:16:37
|
Revision: 693 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=693&view=rev Author: tonytacker Date: 2008-03-07 20:16:34 -0800 (Fri, 07 Mar 2008) Log Message: ----------- changed layout for runPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/Bar.java Added: trunk/src/dl-learner/org/dllearner/gui/Bar.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Bar.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/Bar.java 2008-03-08 04:16:34 UTC (rev 693) @@ -0,0 +1,71 @@ +package org.dllearner.gui; + +/** + * 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/>. + * + */ + +import java.awt.*; +import javax.swing.*; + +/** + * @author Tilo Hielscher + * + */ +public class Bar extends JPanel { + + private static final long serialVersionUID = 8084274242520881523L; + private int height; + private int width; + private double factor; + + @Override + public void paint(Graphics g) { + super.paintComponent(g); + super.setSize(this.width, this.height); + g.fillRect(0, 0, (int) (this.width * this.factor), this.height); + } + + /** + * Make a horizontal bar. + * + * @param width + * in pixel + * @param height + * in pixel + * @param factor + * should between 0 and 1 (1 for 100%) + */ + public Bar(int width, int height, double factor) { + this.width = width; + this.height = height; + this.factor = factor; + repaint(); + } + + /** + * Update horizontal bar. + * + * @param factor + * should between 0 and 1 (1 for 100%) + */ + public void update(double factor) { + this.factor = factor; + repaint(); + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-07 08:44:10 UTC (rev 692) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 04:16:34 UTC (rev 693) @@ -21,13 +21,13 @@ */ import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /** - * RunPanel let algorithm start and stop and show informations about. - * * @author Tilo Hielscher * */ @@ -40,12 +40,25 @@ private Config config; private ThreadRun thread; - // private Boolean runBoolean = new Boolean(false); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); + private GridBagLayout gridbag2 = new GridBagLayout(); + private GridBagConstraints constraints2 = new GridBagConstraints(); + private JPanel showPanel = new JPanel(); + private JPanel centerPanel = new JPanel(); + private JPanel solutionPanel = new JPanel(); private JPanel infoPanel = new JPanel(); - private JPanel solutionPanel = new JPanel(); + private String[] names = { "Algorithm Runtime", "OverallReasoningTime", "Instances", + "Retrieval", "Subsumption" }; + + private JLabel[] name = new JLabel[5]; + private Bar[] bar = new Bar[5]; + private JLabel[] time = new JLabel[5]; + private JLabel[] percent = new JLabel[5]; + RunPanel(Config config) { super(new BorderLayout()); @@ -56,16 +69,68 @@ stopButton = new JButton("Stop"); stopButton.addActionListener(this); + showPanel.add(runButton); + showPanel.add(stopButton); + + infoPanel.setLayout(gridbag); + constraints.anchor = GridBagConstraints.WEST; + constraints.ipadx = 20; + + // make names + for (int i = 0; i < 5; i++) { + name[i] = new JLabel(names[i]); + } + + // make bars + for (int i = 0; i < 5; i++) { + bar[i] = new Bar(100, 10, 0.0); + } + + // make time + for (int i = 0; i < 5; i++) { + time[i] = new JLabel("-"); + } + + // make percent + for (int i = 0; i < 5; i++) { + percent[i] = new JLabel("-"); + } + + // name, bar, time + for (int i = 0; i < 5; i++) { + buildConstraints(constraints, 0, i, 1, 1, 1, 1); + gridbag.setConstraints(name[i], constraints); + infoPanel.add(name[i], constraints); + buildConstraints(constraints, 1, i, 1, 1, 1, 1); + gridbag.setConstraints(bar[i], constraints); + infoPanel.add(bar[i], constraints); + buildConstraints(constraints, 2, i, 1, 1, 1, 1); + gridbag.setConstraints(time[i], constraints); + infoPanel.add(time[i], constraints); + buildConstraints(constraints, 3, i, 1, 1, 1, 1); + gridbag.setConstraints(percent[i], constraints); + infoPanel.add(percent[i], constraints); + } + + // text area infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); - showPanel.add(runButton); - showPanel.add(stopButton); + // layout for centerPanel + centerPanel.setLayout(gridbag2); + constraints2.anchor = GridBagConstraints.CENTER; + constraints2.fill = GridBagConstraints.BOTH; + constraints2.ipadx = 10; + buildConstraints(constraints2, 0, 0, 1, 1, 1, 1); + gridbag2.setConstraints(infoPanel, constraints2); + centerPanel.add(infoPanel, constraints2); + buildConstraints(constraints2, 0, 1, 1, 1, 1, 1); + gridbag2.setConstraints(infoScroll, constraints2); + centerPanel.add(infoScroll, constraints2); - infoPanel.add(infoScroll); - + // layout for this panel add(showPanel, BorderLayout.PAGE_START); - add(infoPanel, BorderLayout.CENTER); + add(centerPanel, BorderLayout.CENTER); add(solutionPanel, BorderLayout.PAGE_END); } @@ -76,7 +141,6 @@ thread = new ThreadRun(config); config.getReasoningService().resetStatistics(); thread.start(); - // this.runBoolean = true; ThreadStatistics threadStatistics = new ThreadStatistics(config, this); threadStatistics.start(); } @@ -95,10 +159,11 @@ Long instanceCheckReasoningTime = null; Long retrievalReasoningTime = null; Long subsumptionReasoningTime = null; + infoArea.setText(""); // best solutions if (config.getLearningAlgorithm().getBestSolutions(5) != null) - infoArea.append("BestSolution:\n" + infoArea.append("BestSolutions:\n" + config.getLearningAlgorithm().getBestSolutions(5).toString() + "\n\n"); // solution score // if (config.getLearningAlgorithm().getSolutionScore() != null) @@ -109,34 +174,40 @@ // reasoner statistics if (config.getAlgorithmRunTime() != null) { algorithmRunTime = config.getAlgorithmRunTime(); - infoArea.append("Algorithm Runtime: " + makeTime(algorithmRunTime) + "\n"); + bar[0].update(1.0); + time[0].setText(makeTime(algorithmRunTime)); + percent[0].setText("100%"); } overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); - infoArea.append("OverallReasoningTime: " + makeTime(overallReasoningTime) - + Percent(overallReasoningTime, algorithmRunTime) + "\n"); - infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() - + "): "); + bar[1].update((double) overallReasoningTime / (double) algorithmRunTime); + time[1].setText(makeTime(overallReasoningTime)); + percent[1].setText(Percent(overallReasoningTime, algorithmRunTime)); if (config.getReasoningService().getNrOfInstanceChecks() > 0) { instanceCheckReasoningTime = config.getReasoningService() .getInstanceCheckReasoningTimeNs(); - infoArea.append(makeTime(instanceCheckReasoningTime) - + Percent(instanceCheckReasoningTime, algorithmRunTime) + "\n"); - } else - infoArea.append(" - \n"); - infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + "): "); + name[2].setText(names[2] + " (" + config.getReasoningService().getNrOfInstanceChecks() + + ")"); + bar[2].update((double) instanceCheckReasoningTime / (double) algorithmRunTime); + time[2].setText(makeTime(instanceCheckReasoningTime)); + percent[2].setText(Percent(instanceCheckReasoningTime, algorithmRunTime)); + } if (config.getReasoningService().getNrOfRetrievals() > 0) { retrievalReasoningTime = config.getReasoningService().getRetrievalReasoningTimeNs(); - infoArea.append(makeTime(retrievalReasoningTime) - + Percent(retrievalReasoningTime, algorithmRunTime) + "\n"); - } else - infoArea.append(" - \n"); + name[3].setText(names[3] + " (" + config.getReasoningService().getNrOfRetrievals() + + ")"); + bar[3].update((double) retrievalReasoningTime / (double) algorithmRunTime); + time[3].setText(makeTime(retrievalReasoningTime)); + percent[3].setText(Percent(retrievalReasoningTime, algorithmRunTime)); + } if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) { subsumptionReasoningTime = config.getReasoningService().getSubsumptionReasoningTimeNs(); - infoArea.append("Subsumption (" - + config.getReasoningService().getNrOfSubsumptionChecks() + "): " - + makeTime(subsumptionReasoningTime) - + Percent(subsumptionReasoningTime, algorithmRunTime) + "\n"); + name[4].setText(names[4] + " (" + + config.getReasoningService().getNrOfSubsumptionChecks() + ")"); + bar[4].update((double) subsumptionReasoningTime / (double) algorithmRunTime); + time[4].setText(makeTime(subsumptionReasoningTime)); + percent[4].setText(Percent(subsumptionReasoningTime, algorithmRunTime)); } + repaint(); } /** @@ -180,9 +251,9 @@ } /** - * Get a percent string like this: "(10,5 %)" + * Get a percent string like this: "10,5%" * - * @param a + * @param a * @param b * @return */ @@ -190,8 +261,21 @@ if (a != null && b != null) { Double c = (double) a / (double) b * (double) 100; c = Math.ceil(c * 10) / 10; - return " (" + c.toString() + " %) "; + return c.toString() + "% "; } return null; } + + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, + int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-07 08:44:26
|
Revision: 692 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=692&view=rev Author: jenslehmann Date: 2008-03-07 00:44:10 -0800 (Fri, 07 Mar 2008) Log Message: ----------- added ORE tool package Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ trunk/src/dl-learner/org/dllearner/tools/ore/ trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java Added: trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-03-07 08:44:10 UTC (rev 692) @@ -0,0 +1,30 @@ +/** + * 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.tools.ore; + +/** + * Start class for the ontology repair and enrichment tool. + * + * @author Lorenz Bühmann. + * + */ +public class ORE { + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-06 07:06:02
|
Revision: 691 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=691&view=rev Author: jenslehmann Date: 2008-03-05 23:05:58 -0800 (Wed, 05 Mar 2008) Log Message: ----------- output changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-05 18:30:41 UTC (rev 690) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-06 07:05:58 UTC (rev 691) @@ -594,13 +594,14 @@ if(!finalStats) { ExampleBasedNode bestNode = candidatesStable.last(); - double accuracy = 100 * ((bestNode.getCoveredPositives().size() - + nrOfNegativeExamples - bestNode.getCoveredNegatives().size())/(double)nrOfExamples); +// double accuracy = 100 * ((bestNode.getCoveredPositives().size() +// + nrOfNegativeExamples - bestNode.getCoveredNegatives().size())/(double)nrOfExamples); // Refinementoperator auf Konzept anwenden - String bestNodeString = "currently best node: " + bestNode + " accuracy: " + df.format(accuracy) + "%"; +// String bestNodeString = "currently best node: " + bestNode + " accuracy: " + df.format(accuracy) + "%"; + String bestNodeString = "currently best node: " + bestNode.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI); // searchTree += bestNodeString + "\n"; System.out.println(bestNodeString); - String expandedNodeString = "next expanded node: " + candidates.last(); + String expandedNodeString = "next expanded node: " + candidates.last().getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI); // searchTree += expandedNodeString + "\n"; System.out.println(expandedNodeString); System.out.println("algorithm runtime " + Helper.prettyPrintNanoSeconds(algorithmRuntime)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-05 18:31:00
|
Revision: 690 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=690&view=rev Author: jenslehmann Date: 2008-03-05 10:30:41 -0800 (Wed, 05 Mar 2008) Log Message: ----------- KB parser extensions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/parser/KBParser.java trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-03-05 18:29:41 UTC (rev 689) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-03-05 18:30:41 UTC (rev 690) @@ -410,6 +410,7 @@ Description c,c1,c2; NamedClass ac; ObjectProperty ar; + DatatypeProperty dp; String s; int i; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -421,21 +422,19 @@ Bottom(); {if (true) return new Nothing();} break; - case ID: - case STRING: - ac = AtomicConcept(); - {if (true) return ac;} - break; default: jj_la1[9] = jj_gen; - if (jj_2_5(2147483647)) { + if (jj_2_5(2)) { + ac = AtomicConcept(); + {if (true) return ac;} + } else if (jj_2_6(2147483647)) { jj_consume_token(22); c1 = Concept(); And(); c2 = Concept(); jj_consume_token(23); {if (true) return new Intersection(c1,c2);} - } else if (jj_2_6(2147483647)) { + } else if (jj_2_7(2147483647)) { jj_consume_token(22); c1 = Concept(); Or(); @@ -481,8 +480,29 @@ break; default: jj_la1[10] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); + if (jj_2_8(4)) { + jj_consume_token(22); + dp = DatatypeProperty(); + jj_consume_token(47); + jj_consume_token(48); + jj_consume_token(23); + {if (true) return new BooleanValueRestriction(dp, true);} + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 22: + jj_consume_token(22); + dp = DatatypeProperty(); + jj_consume_token(47); + jj_consume_token(49); + jj_consume_token(23); + {if (true) return new BooleanValueRestriction(dp, false);} + break; + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } } } } @@ -535,7 +555,7 @@ name = String(); break; default: - jj_la1[11] = jj_gen; + jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -553,7 +573,7 @@ name = String(); break; default: - jj_la1[12] = jj_gen; + jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -571,7 +591,7 @@ name = String(); break; default: - jj_la1[13] = jj_gen; + jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -589,7 +609,7 @@ name = String(); break; default: - jj_la1[14] = jj_gen; + jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -675,41 +695,55 @@ finally { jj_save(5, xla); } } - final private boolean jj_3R_13() { + final private boolean jj_2_7(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_7(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(6, xla); } + } + + final private boolean jj_2_8(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_8(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(7, xla); } + } + + final private boolean jj_3R_14() { if (jj_scan_token(19)) return true; - if (jj_3R_20()) return true; + if (jj_3R_25()) return true; if (jj_3R_4()) return true; if (jj_scan_token(COMMAND_END)) return true; if (jj_3R_2()) return true; return false; } - final private boolean jj_3_6() { + final private boolean jj_3_7() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(15)) return true; return false; } - final private boolean jj_3R_12() { + final private boolean jj_3R_13() { if (jj_scan_token(18)) return true; if (jj_3R_2()) return true; return false; } - final private boolean jj_3R_20() { + final private boolean jj_3R_25() { if (jj_scan_token(NUMBER)) return true; return false; } - final private boolean jj_3_5() { + final private boolean jj_3_6() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(14)) return true; return false; } - final private boolean jj_3R_11() { + final private boolean jj_3R_12() { if (jj_scan_token(17)) return true; if (jj_3R_4()) return true; if (jj_scan_token(COMMAND_END)) return true; @@ -717,12 +751,7 @@ return false; } - final private boolean jj_3R_24() { - if (jj_3R_22()) return true; - return false; - } - - final private boolean jj_3R_10() { + final private boolean jj_3R_11() { if (jj_scan_token(16)) return true; if (jj_3R_4()) return true; if (jj_scan_token(COMMAND_END)) return true; @@ -730,7 +759,7 @@ return false; } - final private boolean jj_3R_9() { + final private boolean jj_3R_10() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(15)) return true; @@ -750,7 +779,7 @@ return false; } - final private boolean jj_3R_8() { + final private boolean jj_3R_9() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(14)) return true; @@ -765,47 +794,35 @@ return false; } - final private boolean jj_3R_23() { - if (jj_3R_21()) return true; + final private boolean jj_3R_18() { + if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_19() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_23()) { - jj_scanpos = xsp; - if (jj_3R_24()) return true; - } + final private boolean jj_3_5() { + if (jj_3R_5()) return true; return false; } - final private boolean jj_3R_16() { - if (jj_3R_22()) return true; + final private boolean jj_3R_8() { + if (jj_scan_token(13)) return true; return false; } final private boolean jj_3R_7() { - if (jj_3R_19()) return true; + if (jj_scan_token(12)) return true; return false; } - final private boolean jj_3R_6() { - if (jj_scan_token(13)) return true; - return false; - } - final private boolean jj_3R_2() { Token xsp; xsp = jj_scanpos; - if (jj_3R_5()) { - jj_scanpos = xsp; - if (jj_3R_6()) { - jj_scanpos = xsp; if (jj_3R_7()) { jj_scanpos = xsp; if (jj_3R_8()) { jj_scanpos = xsp; + if (jj_3_5()) { + jj_scanpos = xsp; if (jj_3R_9()) { jj_scanpos = xsp; if (jj_3R_10()) { @@ -816,7 +833,13 @@ jj_scanpos = xsp; if (jj_3R_13()) { jj_scanpos = xsp; - if (jj_3R_14()) return true; + if (jj_3R_14()) { + jj_scanpos = xsp; + if (jj_3R_15()) { + jj_scanpos = xsp; + if (jj_3_8()) { + jj_scanpos = xsp; + if (jj_3R_16()) return true; } } } @@ -826,44 +849,36 @@ } } } + } + } return false; } - final private boolean jj_3R_5() { - if (jj_scan_token(12)) return true; - return false; - } - - final private boolean jj_3R_21() { + final private boolean jj_3R_26() { if (jj_scan_token(ID)) return true; return false; } - final private boolean jj_3R_18() { - if (jj_3R_22()) return true; + final private boolean jj_3R_20() { + if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_15() { - if (jj_3R_21()) return true; + final private boolean jj_3R_17() { + if (jj_3R_26()) return true; return false; } final private boolean jj_3R_3() { Token xsp; xsp = jj_scanpos; - if (jj_3R_15()) { + if (jj_3R_17()) { jj_scanpos = xsp; - if (jj_3R_16()) return true; + if (jj_3R_18()) return true; } return false; } - final private boolean jj_3R_22() { - if (jj_scan_token(STRING)) return true; - return false; - } - final private boolean jj_3_2() { Token xsp; xsp = jj_scanpos; @@ -884,30 +899,93 @@ return false; } - final private boolean jj_3R_14() { - if (jj_scan_token(20)) return true; - if (jj_3R_20()) return true; - if (jj_3R_4()) return true; - if (jj_scan_token(COMMAND_END)) return true; - if (jj_3R_2()) return true; + final private boolean jj_3R_24() { + if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_17() { - if (jj_3R_21()) return true; + final private boolean jj_3R_19() { + if (jj_3R_26()) return true; return false; } final private boolean jj_3R_4() { Token xsp; xsp = jj_scanpos; - if (jj_3R_17()) { + if (jj_3R_19()) { jj_scanpos = xsp; - if (jj_3R_18()) return true; + if (jj_3R_20()) return true; } return false; } + final private boolean jj_3R_22() { + if (jj_3R_27()) return true; + return false; + } + + final private boolean jj_3R_23() { + if (jj_3R_26()) return true; + return false; + } + + final private boolean jj_3R_6() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_23()) { + jj_scanpos = xsp; + if (jj_3R_24()) return true; + } + return false; + } + + final private boolean jj_3R_21() { + if (jj_3R_26()) return true; + return false; + } + + final private boolean jj_3R_5() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_21()) { + jj_scanpos = xsp; + if (jj_3R_22()) return true; + } + return false; + } + + final private boolean jj_3R_27() { + if (jj_scan_token(STRING)) return true; + return false; + } + + final private boolean jj_3R_16() { + if (jj_scan_token(22)) return true; + if (jj_3R_6()) return true; + if (jj_scan_token(47)) return true; + if (jj_scan_token(49)) return true; + if (jj_scan_token(23)) return true; + return false; + } + + final private boolean jj_3_8() { + if (jj_scan_token(22)) return true; + if (jj_3R_6()) return true; + if (jj_scan_token(47)) return true; + if (jj_scan_token(48)) return true; + if (jj_scan_token(23)) return true; + return false; + } + + final private boolean jj_3R_15() { + if (jj_scan_token(20)) return true; + if (jj_3R_25()) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(COMMAND_END)) return true; + if (jj_3R_2()) return true; + return false; + } + public KBParserTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; @@ -917,7 +995,7 @@ public boolean lookingAhead = false; private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[15]; + final private int[] jj_la1 = new int[16]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { @@ -925,12 +1003,12 @@ jj_la1_1(); } private static void jj_la1_0() { - jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x203200,0x1f0000,0x200200,0x200200,0x200200,0x200200,}; + jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x3000,0x1f0000,0x400000,0x200200,0x200200,0x200200,0x200200,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0xffd,0xffd,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_1 = new int[] {0xffd,0xffd,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } - final private JJCalls[] jj_2_rtns = new JJCalls[6]; + final private JJCalls[] jj_2_rtns = new JJCalls[8]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -943,7 +1021,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -956,7 +1034,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -966,7 +1044,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -976,7 +1054,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -985,7 +1063,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -994,7 +1072,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1105,12 +1183,12 @@ public ParseException generateParseException() { jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[47]; + boolean[] la1tokens = new boolean[50]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 15; i++) { + for (int i = 0; i < 16; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { @@ -1122,7 +1200,7 @@ } } } - for (int i = 0; i < 47; i++) { + for (int i = 0; i < 50; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; @@ -1147,7 +1225,7 @@ final private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 8; i++) { try { JJCalls p = jj_2_rtns[i]; do { @@ -1160,6 +1238,8 @@ case 3: jj_3_4(); break; case 4: jj_3_5(); break; case 5: jj_3_6(); break; + case 6: jj_3_7(); break; + case 7: jj_3_8(); break; } } p = p.next; Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-03-05 18:29:41 UTC (rev 689) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-03-05 18:30:41 UTC (rev 690) @@ -72,6 +72,9 @@ "\"DOUBLE\"", "\"BOOLEAN\"", "\"INTEGER\"", + "\"IS\"", + "\"TRUE\"", + "\"FALSE\"", }; } Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-03-05 18:29:41 UTC (rev 689) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-03-05 18:30:41 UTC (rev 690) @@ -15,7 +15,7 @@ case 0: if ((active0 & 0x34c000000L) != 0L) return 10; - if ((active0 & 0x20000000L) != 0L) + if ((active0 & 0x2000020000000L) != 0L) return 18; if ((active0 & 0x4000L) != 0L) return 13; @@ -67,9 +67,9 @@ case 68: return jjMoveStringLiteralDfa1_0(0x1c6400000000L); case 70: - return jjMoveStringLiteralDfa1_0(0x20000000L); + return jjMoveStringLiteralDfa1_0(0x2000020000000L); case 73: - return jjMoveStringLiteralDfa1_0(0x400080000000L); + return jjMoveStringLiteralDfa1_0(0xc00080000000L); case 79: return jjMoveStringLiteralDfa1_0(0x31800008000L); case 82: @@ -77,7 +77,7 @@ case 83: return jjMoveStringLiteralDfa1_0(0x34c000000L); case 84: - return jjMoveStringLiteralDfa1_0(0x10001000L); + return jjMoveStringLiteralDfa1_0(0x1000010001000L); default : return jjMoveNfa_0(0, 0); } @@ -98,7 +98,7 @@ return jjStopAtPos(1, 20); break; case 65: - return jjMoveStringLiteralDfa2_0(active0, 0x8c000000000L); + return jjMoveStringLiteralDfa2_0(active0, 0x208c000000000L); case 66: return jjMoveStringLiteralDfa2_0(active0, 0x21000000000L); case 78: @@ -110,6 +110,10 @@ case 82: if ((active0 & 0x8000L) != 0L) return jjStopAtPos(1, 15); + return jjMoveStringLiteralDfa2_0(active0, 0x1000000000000L); + case 83: + if ((active0 & 0x800000000000L) != 0L) + return jjStopAtPos(1, 47); break; case 85: return jjMoveStringLiteralDfa2_0(active0, 0x20c000000L); @@ -150,6 +154,8 @@ return jjMoveStringLiteralDfa3_0(active0, 0x2800000000L); case 74: return jjMoveStringLiteralDfa3_0(active0, 0x21000000000L); + case 76: + return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L); case 77: return jjMoveStringLiteralDfa3_0(active0, 0x400000000L); case 78: @@ -165,7 +171,7 @@ case 84: return jjMoveStringLiteralDfa3_0(active0, 0x484000002000L); case 85: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x1100000000000L); case 97: return jjMoveStringLiteralDfa3_0(active0, 0x10000000L); case 98: @@ -199,6 +205,8 @@ case 67: return jjMoveStringLiteralDfa4_0(active0, 0x204000000L); case 69: + if ((active0 & 0x1000000000000L) != 0L) + return jjStopAtPos(3, 48); return jjMoveStringLiteralDfa4_0(active0, 0x421000000000L); case 71: return jjMoveStringLiteralDfa4_0(active0, 0x8000000000L); @@ -206,6 +214,8 @@ return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L); case 79: return jjMoveStringLiteralDfa4_0(active0, 0x2800000000L); + case 83: + return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L); case 84: return jjMoveStringLiteralDfa4_0(active0, 0x2000L); case 99: @@ -239,6 +249,8 @@ case 69: if ((active0 & 0x8000000000L) != 0L) return jjStopAtPos(4, 39); + else if ((active0 & 0x2000000000000L) != 0L) + return jjStopAtPos(4, 49); return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L); case 71: return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L); @@ -1144,12 +1156,12 @@ "\104\101\124\101\124\131\120\105\120\122\117\120\105\122\124\131\104\117\115\101\111\116", "\122\101\116\107\105", "\117\120\122\101\116\107\105", "\117\102\112\105\103\124\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\120\122\101\116\107\105", "\104\101\124\101\124\131\120\105\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\117\125\102\114\105", "\102\117\117\114\105\101\116", -"\111\116\124\105\107\105\122", }; +"\111\116\124\105\107\105\122", "\111\123", "\124\122\125\105", "\106\101\114\123\105", }; public static final String[] lexStateNames = { "DEFAULT", }; static final long[] jjtoToken = { - 0x7fffffffff01L, + 0x3ffffffffff01L, }; static final long[] jjtoSkip = { 0xfeL, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-05 18:30:01
|
Revision: 689 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=689&view=rev Author: jenslehmann Date: 2008-03-05 10:29:41 -0800 (Wed, 05 Mar 2008) Log Message: ----------- - a lot of bug fixes - new learning algorithm should be usable now Modified Paths: -------------- trunk/examples/arch/arch.conf trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java Modified: trunk/examples/arch/arch.conf =================================================================== --- trunk/examples/arch/arch.conf 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/examples/arch/arch.conf 2008-03-05 18:29:41 UTC (rev 689) @@ -18,6 +18,8 @@ algorithm = refexamples; reasoner = fastInstanceChecker; +// comment this out if the search should start from construction +// refexamples.startClass = "http://localhost/foo#construction"; // export("arch.owl"); import("arch.kb"); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-05 18:29:41 UTC (rev 689) @@ -20,6 +20,7 @@ package org.dllearner.algorithms.refexamples; +import java.text.DecimalFormat; import java.util.Set; import java.util.TreeSet; @@ -39,6 +40,8 @@ */ public class ExampleBasedNode { + private static DecimalFormat df = new DecimalFormat(); + // example based variables private Set<Individual> coveredPositives; private Set<Individual> coveredNegatives; @@ -50,7 +53,8 @@ // all properties of a node in the search tree private Description concept; private int horizontalExpansion; - private int coveredNegativeExamples; + // specifies whether the node is too weak (exceeds the max. nr allowed + // misclassifications of positive examples) private boolean isTooWeak; private boolean isQualityEvaluated; private boolean isRedundant; @@ -104,11 +108,12 @@ @Override public String toString() { +// System.out.println(concept); String ret = concept.toString() + " [q:"; if(isTooWeak) ret += "tw"; else - ret += coveredNegativeExamples; + ret += coveredNegatives.size(); ret += ", he:" + horizontalExpansion + ", children:" + children.size() + "]"; return ret; } @@ -124,35 +129,50 @@ } } - public String getTreeString() { - return getTreeString(0).toString(); + public String getTreeString(int nrOfPositiveExamples, int nrOfNegativeExamples) { + return getTreeString(nrOfPositiveExamples, nrOfNegativeExamples, 0,null).toString(); } - private StringBuilder getTreeString(int depth) { + public String getTreeString(int nrOfPositiveExamples, int nrOfNegativeExamples, String baseURI) { + return getTreeString(nrOfPositiveExamples, nrOfNegativeExamples, 0,baseURI).toString(); + } + + private StringBuilder getTreeString(int nrOfPositiveExamples, int nrOfNegativeExamples, 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("|--> "); - treeString.append(getShortDescription()+"\n"); + treeString.append(getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)+"\n"); for(ExampleBasedNode child : children) { - treeString.append(child.getTreeString(depth+1)); + treeString.append(child.getTreeString(nrOfPositiveExamples, nrOfNegativeExamples, depth+1,baseURI)); } return treeString; } - private String getShortDescription() { - String ret = concept.toString() + " [q:"; + public String getShortDescription(int nrOfPositiveExamples, int nrOfNegativeExamples, String baseURI) { + String ret = concept.toString(baseURI,null) + " ["; if(isTooWeak) - ret += "tw"; - else - ret += coveredNegativeExamples; + ret += "q:tw"; + else { + double accuracy = 100 * (coveredPositives.size() + nrOfNegativeExamples - coveredNegatives.size())/(double)(nrOfPositiveExamples+nrOfNegativeExamples); + ret += "acc:" + df.format(accuracy) + "% "; + + // comment this out to display the heuristic score with default parameters + double heuristicScore = MultiHeuristic.getNodeScore(this, nrOfPositiveExamples, nrOfNegativeExamples); + ret += "h:" +df.format(heuristicScore) + " "; + + int wrongPositives = nrOfPositiveExamples - coveredPositives.size(); + ret += "q:" + wrongPositives + "p-" + coveredNegatives.size() + "n"; + } - ret += " ("+qualityEvaluationMethod+"), he:" + horizontalExpansion + "]"; + ret += " ("+qualityEvaluationMethod+"), he:" + horizontalExpansion; + ret += " c:" + children.size() + "]"; + return ret; - } + } public Set<Individual> getCoveredPositives() { return coveredPositives; @@ -178,9 +198,6 @@ return qualityEvaluationMethod; } - public int getCoveredNegativeExamples() { - return coveredNegativeExamples; - } public int getHorizontalExpansion() { return horizontalExpansion; } @@ -199,6 +216,6 @@ */ public ExampleBasedNode getParent() { return parent; - } + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-05 18:29:41 UTC (rev 689) @@ -85,7 +85,7 @@ private File searchTreeFile; private boolean replaceSearchTree = false; private static String defaultSearchTreeFile = "log/searchTree.txt"; - private String heuristic = "lexicographic"; + private String heuristic = "multi"; Set<NamedClass> allowedConcepts; Set<ObjectProperty> allowedRoles; Set<NamedClass> ignoredConcepts; @@ -241,11 +241,16 @@ if(heuristic == "lexicographic") algHeuristic = new LexicographicHeuristic(); - else { + else if(heuristic == "flexible") { if(learningProblem instanceof PosOnlyDefinitionLP) { throw new RuntimeException("does not work with positive examples only yet"); } algHeuristic = new FlexibleHeuristic(((PosNegLP)learningProblem).getNegativeExamples().size(), ((PosNegLP)learningProblem).getPercentPerLengthUnit()); + } else { + if(learningProblem instanceof PosOnlyDefinitionLP) { + throw new RuntimeException("does not work with positive examples only yet"); + } + algHeuristic = new MultiHeuristic(((PosNegLP)learningProblem).getPositiveExamples().size(),((PosNegLP)learningProblem).getNegativeExamples().size()); } // compute used concepts/roles from allowed/ignored Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-05 18:29:41 UTC (rev 689) @@ -170,6 +170,9 @@ private long evaluateSetCreationTimeNs = 0; private long improperConceptsRemovalTimeNs = 0; + // prefixes + private String baseURI; + public ExampleBasedROLearner( LearningProblem learningProblem, ReasoningService rs, @@ -212,13 +215,14 @@ this.useTooWeakList = useTooWeakList; this.useOverlyGeneralList = useOverlyGeneralList; this.useShortConceptConstruction = useShortConceptConstruction; + baseURI = rs.getBaseURI(); logger.setLevel(Level.DEBUG); } public void start() { // calculate quality threshold required for a solution - allowedMisclassifications = (int) Math.round(noise * nrOfExamples); + allowedMisclassifications = (int) Math.round(noise * nrOfExamples); // start search with start class if(startDescription == null) { @@ -266,15 +270,15 @@ if(writeSearchTree) { // String treeString = ""; - String treeString = "best expanded node: " + bestNode+ "\n"; + String treeString = "best node: " + bestNode+ "\n"; if(expandedNodes.size()>1) { - treeString += "all expanded nodes:\n"; // due to minimum horizontal expansion:\n"; + treeString += "all expanded nodes:\n"; for(ExampleBasedNode n : expandedNodes) { treeString += " " + n + "\n"; } } expandedNodes.clear(); - treeString += startNode.getTreeString(); + treeString += startNode.getTreeString(nrOfPositiveExamples, nrOfNegativeExamples, baseURI); treeString += "\n"; if(replaceSearchTree) @@ -291,6 +295,7 @@ } if(solutionFound) { + logger.info("best node " + candidatesStable.last().getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); logger.info("\nsolutions:"); for(Description c : solutions) { logger.info(" " + c + " (length " + c.getLength() +", depth " + c.getDepth() + ")"); @@ -305,10 +310,9 @@ System.out.println("Algorithm terminated succesfully."); } + // we apply the operator recursively until all proper refinements up + // to the maxmimum length are reached private void extendNodeProper(ExampleBasedNode node, int maxLength) { - // Rekursionsanfang ist das Konzept am Knoten selbst; danach wird der Operator - // so lange darauf angewandt bis alle proper refinements bis zu maxLength - // gefunden wurden long propCalcNsStart = System.nanoTime(); if(writeSearchTree) @@ -317,54 +321,27 @@ if(node.getChildren().size()>maxNrOfChildren) maxNrOfChildren = node.getChildren().size(); - // Knoten in instabiler Menge muss aktualisiert werden - // => wird jetzt schon vom Algorithmus entfernt - /* - boolean remove = candidates.remove(node); - - if(!remove) { - System.out.println(candidates); - System.out.println(candidatesStable); - System.out.println(node); - - throw new RuntimeException("remove failed"); - }*/ - extendNodeProper(node, node.getConcept(), maxLength, 0); node.setHorizontalExpansion(maxLength); - // wird jetzt schon im Kernalgorithmus hinzugefügt - /* - boolean add = candidates.add(node); - if(!add) { - throw new RuntimeException("add failed"); - }*/ - - // Knoten wird entfernt und wieder hinzugefügt, da sich seine - // Position geändert haben könnte => geht noch nicht wg. ConcurrentModification - // falls Knoten wg. min. horiz. exp. expandiert werden - // candidates.remove(node); - // candidates.add(node); propernessCalcTimeNs += (System.nanoTime()-propCalcNsStart); } - - - // für alle proper refinements von concept bis maxLength werden Kinderknoten - // für node erzeugt; - // recDepth dient nur zur Protokollierung + // for all refinements of concept up to max length, we check whether they are properr + // and call the method recursively if not + // recDepth is used only for statistics private void extendNodeProper(ExampleBasedNode node, Description concept, int maxLength, int recDepth) { - // führe Methode nicht aus, wenn Algorithmus gestoppt wurde (alle rekursiven Funktionsaufrufe - // werden nacheinander abgebrochen, so dass ohne weitere Reasoninganfragen relativ schnell beendet wird) + // do not execute methods if algorithm has been stopped (this means that the algorithm + // will terminate without further reasoning queries) if(stop) return; if(recDepth > maxRecDepth) maxRecDepth = recDepth; - // Refinements berechnen => hier dürfen dürfen refinements <= horizontal expansion - // des Konzepts nicht gelöscht werden! + // compute refinements => we must not delete refinements with low horizontal expansion, + // because they are used in recursive calls of this method later on long refinementCalcTimeNsStart = System.nanoTime(); Set<Description> refinements = operator.refine(concept, maxLength, null); refinementCalcTimeNs += System.nanoTime() - refinementCalcTimeNsStart; @@ -393,18 +370,13 @@ while(it.hasNext()) { Description refinement = it.next(); if(refinement.getLength()>node.getHorizontalExpansion()) { - // TODO: an dieser Stelle könnte man Algorithmen ansetzen lassen, die - // versuchen properness-Anfragen zu vermeiden: - // 1. Konzept kürzen und schauen, ob es Mutterkonzept entspricht - // 2. Blacklist, die überprüft, ob Konzept too weak ist - // (dann ist es auch proper) - // sagt aus, ob festgestellt wurde, ob refinement proper ist // (sagt nicht aus, dass das refinement proper ist!) boolean propernessDetected = false; // 1. short concept construction if(useShortConceptConstruction) { + // kurzes Konzept konstruieren Description shortConcept = ConceptTransformation.getShortConcept(refinement, conceptComparator); int n = conceptComparator.compare(shortConcept, concept); @@ -503,9 +475,11 @@ quality = getNumberOfNegatives(); qualityKnown = true; newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.OVERLY_GENERAL_LIST); + newNode.setCoveredExamples(learningProblem.getPositiveExamples(), learningProblem.getNegativeExamples()); } + } - + // Qualität des Knotens auswerten if(!qualityKnown) { long propCalcReasoningStart2 = System.nanoTime(); @@ -519,23 +493,23 @@ // calculate how many pos. examples are not covered by the // parent node of the refinement - int misclassifications = nrOfPositiveExamples - coveredPositives.size(); + int misclassifiedPositives = nrOfPositiveExamples - coveredPositives.size(); // iterate through all covered examples (examples which are not - // covered do not need to be tested, because they remain uncovered) - // TODO: DIG will be slow if we send each reasoner request individually + // covered do not need to be tested, because they remain uncovered); + // DIG will be slow if we send each reasoner request individually // (however if we send everything in one request, too many instance checks - // are performed => rely on fast instance checker [still to implement]) + // are performed => rely on fast instance checker) for(Individual i : coveredPositives) { // TODO: move code to a separate function if(quality != -1) { boolean covered = rs.instanceCheck(refinement, i); if(!covered) - misclassifications++; + misclassifiedPositives++; else newlyCoveredPositives.add(i); - if(misclassifications > allowedMisclassifications) + if(misclassifiedPositives > allowedMisclassifications) quality = -1; } @@ -561,7 +535,7 @@ + newlyCoveredNegatives.size(); newNode.setCoveredExamples(newlyCoveredPositives, newlyCoveredNegatives); } - + } if(quality == -1) { @@ -575,18 +549,17 @@ solutions.add(refinement); } -// newNode.setCoveredNegativeExamples(quality); + newCandidates.add(newNode); - // candidates.add(newNode); - // candidatesStable.add(newNode); - - - if(quality == getNumberOfNegatives()) + + // we need to make sure that all positives are covered + // before adding something to the overly general list + if((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == getNumberOfNegatives()) overlyGeneralList.add(refinement); - - // System.out.print("."); + } +// System.out.println(newNode.getConcept() + " " + quality); node.addChild(newNode); } } @@ -673,6 +646,7 @@ System.out.println("onnf time percentage: " + df.format(onnfTimePercentage) + "%"); System.out.println("shortening time percentage: " + df.format(shorteningTimePercentage) + "%"); } + System.out.println("properness tests (reasoner/short concept/too weak list): " + propernessTestsReasoner + "/" + propernessTestsAvoidedByShortConceptConstruction + "/" + propernessTestsAvoidedByTooWeakList); System.out.println("concept tests (reasoner/too weak list/overly general list/redundant concepts): " + conceptTestsReasoner + "/" @@ -709,6 +683,22 @@ } return false; } +/* + private Set<Individual> computeQuality(Description refinement, Set<Individual> coveredPositives) { + Set<Individual> ret = new TreeSet<Individual>(); + int misclassifications; + for(Individual i : coveredPositives) { + boolean covered = rs.instanceCheck(refinement, i); + if(!covered) + misclassifications++; + else + ret.add(i); + + if(misclassifications > allowedMisclassifications) + return null; + } + } +*/ public void stop() { stop = true; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/FlexibleHeuristic.java 2008-03-05 18:29:41 UTC (rev 689) @@ -66,10 +66,10 @@ if(n1.isQualityEvaluated() && n2.isQualityEvaluated() && !n1.isTooWeak() && !n2.isTooWeak()) { // alle scores sind negativ, größere scores sind besser - double score1 = -n1.getCoveredNegativeExamples()/(double)nrOfNegativeExamples; + double score1 = -n1.getCoveredNegatives().size()/(double)nrOfNegativeExamples; score1 -= percentPerLengthUnit * n1.getConcept().getLength(); - double score2 = -n2.getCoveredNegativeExamples()/(double)nrOfNegativeExamples; + double score2 = -n2.getCoveredNegatives().size()/(double)nrOfNegativeExamples; score2 -= percentPerLengthUnit * n2.getConcept().getLength(); double diff = score1 - score2; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/LexicographicHeuristic.java 2008-03-05 18:29:41 UTC (rev 689) @@ -32,9 +32,9 @@ // sicherstellen, dass Qualität ausgewertet wurde if(n1.isQualityEvaluated() && n2.isQualityEvaluated() && !n1.isTooWeak() && !n2.isTooWeak()) { - if(n1.getCoveredNegativeExamples()<n2.getCoveredNegativeExamples()) + if(n1.getCoveredNegatives().size()<n2.getCoveredNegatives().size()) return 1; - else if(n1.getCoveredNegativeExamples()>n2.getCoveredNegativeExamples()) + else if(n1.getCoveredNegatives().size()>n2.getCoveredNegatives().size()) return -1; else { //TODO: es wäre geringfügig effizienter die Länge nicht mehrfach zu berechnen Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-05 18:29:41 UTC (rev 689) @@ -57,6 +57,11 @@ * N = number of negative examples<br /> * </code></p> * + * TODO: Maybe the number of children of a node could be used instead of + * horiz. exp, because if a node has a very high number of children, the + * algorithm gets stuck easily, while it could still be very agile in other + * parts of the search space. + * * @author Jens Lehmann * */ @@ -65,13 +70,18 @@ private ConceptComparator conceptComparator = new ConceptComparator(); // heuristic parameters - private double expansionPenaltyFactor = 0.01; - private double gainBonusFactor = 1.00; + private double expansionPenaltyFactor; + private double gainBonusFactor; + private double nodeChildPenalty = 0.0001; // examples private int nrOfNegativeExamples; private int nrOfExamples; + public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples) { + this(nrOfPositiveExamples, nrOfNegativeExamples, 0.03, 0.5); + } + public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, double expansionPenaltyFactor, double gainBonusFactor) { this.nrOfNegativeExamples = nrOfNegativeExamples; nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; @@ -104,11 +114,17 @@ double parentAccuracy = getAccuracy(parent.getCoveredPositives().size(),parent.getCoveredNegatives().size()); gain = accuracy - parentAccuracy; } - return accuracy + gainBonusFactor * gain - expansionPenaltyFactor * node.getHorizontalExpansion(); + return accuracy + gainBonusFactor * gain - expansionPenaltyFactor * node.getHorizontalExpansion() - nodeChildPenalty * node.getChildren().size(); } private double getAccuracy(int coveredPositives, int coveredNegatives) { return (coveredPositives + nrOfNegativeExamples - coveredNegatives)/(double)nrOfExamples; } + + public static double getNodeScore(ExampleBasedNode node, int nrOfPositiveExamples, int nrOfNegativeExamples) { + MultiHeuristic multi = new MultiHeuristic(nrOfPositiveExamples, nrOfNegativeExamples); + return multi.getNodeScore(node); + } + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/NodeComparatorStable.java 2008-03-05 18:29:41 UTC (rev 689) @@ -25,44 +25,54 @@ import org.dllearner.utilities.ConceptComparator; /** - * Der Comparator ist stable, weil er nur nach covered negatives, - * Konzeptlänge und Konzeptstring vergleicht, die sich während des Algorithmus nicht - * ändern können. + * This comparator is stable, because it only takes covered examples, concept + * length and the concepts itself (using again a stable comparator) into a + * account, which do not change during the run of the algorithm. * - * @author jl + * @author Jens Lehmann * */ public class NodeComparatorStable implements Comparator<ExampleBasedNode> { - ConceptComparator conceptComparator = new ConceptComparator(); + private ConceptComparator conceptComparator = new ConceptComparator(); - // implementiert public int compare(ExampleBasedNode n1, ExampleBasedNode n2) { - // sicherstellen, dass Qualität ausgewertet wurde + // make sure quality has been evaluated if(n1.isQualityEvaluated() && n2.isQualityEvaluated()) { if(!n1.isTooWeak() && !n2.isTooWeak()) { - if(n1.getCoveredNegativeExamples()<n2.getCoveredNegativeExamples()) + int classificationPointsN1 = n1.getCoveredPositives().size() - n1.getCoveredNegatives().size(); + int classificationPointsN2 = n2.getCoveredPositives().size() - n2.getCoveredNegatives().size(); + + if(classificationPointsN1>classificationPointsN2) return 1; - else if(n1.getCoveredNegativeExamples()>n2.getCoveredNegativeExamples()) + else if(classificationPointsN1<classificationPointsN2) return -1; else { - //TODO: es wäre geringfügig effizienter die Länge nicht mehrfach zu berechnen - if(n1.getConcept().getLength()<n2.getConcept().getLength()) + int lengthN1 = n1.getConcept().getLength(); + int lengthN2 = n2.getConcept().getLength(); + + if(lengthN1<lengthN2) return 1; - else if(n1.getConcept().getLength()>n2.getConcept().getLength()) + else if(lengthN1>lengthN2) return -1; else return conceptComparator.compare(n1.getConcept(), n2.getConcept()); } - } else - return conceptComparator.compare(n1.getConcept(), n2.getConcept()); + } else { + if(n1.isTooWeak() && !n2.isTooWeak()) + return -1; + else if(!n1.isTooWeak() && n2.isTooWeak()) + return 1; + else + return conceptComparator.compare(n1.getConcept(), n2.getConcept()); + } } - throw new RuntimeException("Cannot compare nodes, which have no evaluated quality or are too weak."); + throw new RuntimeException("Cannot compare nodes, which have no evaluated quality."); } - // alle NodeComparators führen zur gleichen Ordnung + // all stable node comparators lead to the same order @Override public boolean equals(Object o) { return (o instanceof NodeComparatorStable); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-03-05 18:29:41 UTC (rev 689) @@ -559,6 +559,14 @@ return atomicRolesList; } + public String getBaseURI() { + return reasoner.getBaseURI(); + } + + public Map<String, String> getPrefixes() { + return reasoner.getPrefixes(); + } + public long getInstanceCheckReasoningTimeNs() { return instanceCheckReasoningTimeNs; } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2008-03-05 18:29:41 UTC (rev 689) @@ -53,6 +53,7 @@ public String toString() { String str = ""; str += "score: " + score + "\n"; + str += "accuracy: " + (1 + classificationScore) + "\n"; str += "posAsPos: " + posAsPos + "\n"; str += "positive examples classified as negative: " + posAsNeg + "\n"; str += "negative examples classified as positive: " + negAsPos + "\n"; Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-03-05 18:29:41 UTC (rev 689) @@ -246,13 +246,14 @@ Description c,c1,c2; NamedClass ac; ObjectProperty ar; + DatatypeProperty dp; String s; int i; } { Top() {return new Thing();} | Bottom() {return new Nothing();} - | ac = AtomicConcept() {return ac;} + | LOOKAHEAD(2) ac = AtomicConcept() {return ac;} // | s=Id() {return new AtomicConcept(s);} // | s=String() {return new AtomicConcept(s);} // Parser geht bis zum n�chsten AND oder OR @@ -278,7 +279,9 @@ // | LE() i=Integer() s=Id() "." c=Concept() // {return new LessEqual(i,new AtomicRole(s),c);} | LE() i=Integer() ar=ObjectProperty() "." c=Concept() - {return new ObjectMaxCardinalityRestriction(i,ar,c);} + {return new ObjectMaxCardinalityRestriction(i,ar,c);} + | LOOKAHEAD(4) "(" dp=DatatypeProperty() "IS" "TRUE" ")" { return new BooleanValueRestriction(dp, true); } + | "(" dp=DatatypeProperty() "IS" "FALSE" ")" { return new BooleanValueRestriction(dp, false); } } void Or() : {} { <OR> } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-05 18:29:41 UTC (rev 689) @@ -301,8 +301,14 @@ } @Override - public SortedSet<Individual> retrieval(Description concept) { - return rs.retrieval(concept); + public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException { +// return rs.retrieval(concept); + SortedSet<Individual> inds = new TreeSet<Individual>(); + for(Individual i : individuals) { + if(instanceCheck(concept,i)) + inds.add(i); + } + return inds; } /* Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-05 18:29:41 UTC (rev 689) @@ -546,7 +546,8 @@ @Override public SortedSet<Individual> retrieval(Description concept) { - OWLDescription d = getOWLAPIDescription(concept); +// OWLDescription d = getOWLAPIDescription(concept); + OWLDescription d = OWLAPIDescriptionConvertVisitor.getOWLDescription(concept); Set<OWLIndividual> individuals = null; try { individuals = reasoner.getIndividuals(d, false); Modified: trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-03-05 12:07:28 UTC (rev 688) +++ trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-03-05 18:29:41 UTC (rev 689) @@ -67,8 +67,35 @@ return ((NamedClass)concept1).getName().compareTo(((NamedClass)concept2).getName()); else return -1; + } else if(concept1 instanceof BooleanValueRestriction) { + if(concept2 instanceof Nothing || concept2 instanceof NamedClass) { + return 1; + } else if(concept2 instanceof BooleanValueRestriction) { + // first criterion: name of the properties + int cmp = rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(), ((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion()); + + // second criterion: value of the properties (it should rarely happen that + // both boolean values are present since this is a contradiction or superfluous) + if(cmp == 0) { + boolean val1 = ((BooleanValueRestriction)concept1).getBooleanValue(); + boolean val2 = ((BooleanValueRestriction)concept2).getBooleanValue(); + if(val1) { + if(val2) + return 0; + else + return 1; + } else { + if(val2) + return -1; + else + return 0; + } + } else + return cmp; + } else + return -1; } else if(concept1 instanceof Thing) { - if(concept2 instanceof Nothing || concept2 instanceof NamedClass) + if(concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) return 1; else if(concept2 instanceof Thing) return 0; @@ -104,17 +131,6 @@ return roleCompare; } else return -1; - } else if(concept1 instanceof BooleanValueRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction) { - return 1; - } else if(concept2 instanceof BooleanValueRestriction) { - int cmp = rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(), ((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion()); - if(cmp == 0) - return compare(concept1.getChild(0), concept2.getChild(0)); - else - return cmp; - } else - return -1; } else if(concept1 instanceof Intersection) { if(concept2.getChildren().size()<2) return 1; @@ -162,12 +178,6 @@ } else throw new RuntimeException(concept1.toString()); } - - /* - private int compareRole(Role r1, Role r2) { - return r1.toString().compareTo(r2.toString()); - } - */ // TODO: Vergleich zwischen ConceptComparators: immer identisch // (testen, ob das bessere Performance bringt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-05 12:07:36
|
Revision: 688 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=688&view=rev Author: jenslehmann Date: 2008-03-05 04:07:28 -0800 (Wed, 05 Mar 2008) Log Message: ----------- implemented a new heuristic Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java trunk/src/dl-learner/org/dllearner/core/owl/Thing.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-04 19:10:55 UTC (rev 687) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-03-05 12:07:28 UTC (rev 688) @@ -39,16 +39,15 @@ */ public class ExampleBasedNode { - // example based variables here + // example based variables private Set<Individual> coveredPositives; private Set<Individual> coveredNegatives; - // TOP ist einfach das TOP-Konzept, also das einzige welches nicht evaluiert wird + // the method by which quality was evaluated in this node public enum QualityEvaluationMethod { TOP, REASONER, TOO_WEAK_LIST, OVERLY_GENERAL_LIST }; - private QualityEvaluationMethod qualityEvaluationMethod = QualityEvaluationMethod.TOP; - // alle Eigenschaften eines Knotens im Suchbaum + // all properties of a node in the search tree private Description concept; private int horizontalExpansion; private int coveredNegativeExamples; @@ -59,28 +58,17 @@ private static ConceptComparator conceptComparator = new ConceptComparator(); private static NodeComparatorStable nodeComparator = new NodeComparatorStable(); - // Einbettung in Suchbaum + // link to parent in search tree private ExampleBasedNode parent = null; - // private Set<Node> children = new HashSet<Node>(); private Set<ExampleBasedNode> children = new TreeSet<ExampleBasedNode>(nodeComparator); - // es wird auch eine Liste von Kindern gehalten + // apart from the child nodes, we also keep child concepts private Set<Description> childConcepts = new TreeSet<Description>(conceptComparator); - // verwendeter Operator für Expansion des Knotens - // private RefinementOperator operator; - public ExampleBasedNode(Description concept) { this.concept = concept; horizontalExpansion = 0; isQualityEvaluated = false; } - - public void setCoveredNegativeExamples(int coveredNegativeExamples) { - if(isQualityEvaluated) - throw new RuntimeException("Cannot set quality of a node more than once."); - this.coveredNegativeExamples = coveredNegativeExamples; - isQualityEvaluated = true; - } public void setHorizontalExpansion(int horizontalExpansion) { this.horizontalExpansion = horizontalExpansion; @@ -104,25 +92,16 @@ return children.add(child); } - public Description getConcept() { - return concept; + public void setQualityEvaluationMethod(QualityEvaluationMethod qualityEvaluationMethod) { + this.qualityEvaluationMethod = qualityEvaluationMethod; } - public int getCoveredNegativeExamples() { - return coveredNegativeExamples; + + public void setCoveredExamples(Set<Individual> coveredPositives, Set<Individual> coveredNegatives) { + this.coveredPositives = coveredPositives; + this.coveredNegatives = coveredNegatives; + isQualityEvaluated = true; } - public int getHorizontalExpansion() { - return horizontalExpansion; - } - public boolean isQualityEvaluated() { - return isQualityEvaluated; - } - public boolean isRedundant() { - return isRedundant; - } - public boolean isTooWeak() { - return isTooWeak; - } - + @Override public String toString() { String ret = concept.toString() + " [q:"; @@ -134,7 +113,7 @@ return ret; } - // gibt die Refinement-Chain zurück, die zu dem Knoten geführt hat + // returns the refinement chain leading to this node as string public String getRefinementChainString() { if(parent!=null) { String ret = parent.getRefinementChainString(); @@ -143,8 +122,8 @@ } else { return concept.toString(); } - } - + } + public String getTreeString() { return getTreeString(0).toString(); } @@ -173,6 +152,14 @@ ret += " ("+qualityEvaluationMethod+"), he:" + horizontalExpansion + "]"; return ret; + } + + public Set<Individual> getCoveredPositives() { + return coveredPositives; + } + + public Set<Individual> getCoveredNegatives() { + return coveredNegatives; } public Set<ExampleBasedNode> getChildren() { @@ -183,28 +170,35 @@ return childConcepts; } + public Description getConcept() { + return concept; + } + public QualityEvaluationMethod getQualityEvaluationMethod() { return qualityEvaluationMethod; + } + + public int getCoveredNegativeExamples() { + return coveredNegativeExamples; } - - public void setQualityEvaluationMethod(QualityEvaluationMethod qualityEvaluationMethod) { - this.qualityEvaluationMethod = qualityEvaluationMethod; + public int getHorizontalExpansion() { + return horizontalExpansion; } - - public Set<Individual> getCoveredPositives() { - return coveredPositives; + public boolean isQualityEvaluated() { + return isQualityEvaluated; } - - public void setCoveredPositives(Set<Individual> coveredPositives) { - this.coveredPositives = coveredPositives; + public boolean isRedundant() { + return isRedundant; } - - public Set<Individual> getCoveredNegatives() { - return coveredNegatives; + public boolean isTooWeak() { + return isTooWeak; } - public void setCoveredNegatives(Set<Individual> coveredNegatives) { - this.coveredNegatives = coveredNegatives; - } - -} + /** + * @return the parent + */ + public ExampleBasedNode getParent() { + return parent; + } + +} \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-04 19:10:55 UTC (rev 687) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-05 12:07:28 UTC (rev 688) @@ -217,37 +217,25 @@ } public void start() { - - // calculate quality threshold required for a solution allowedMisclassifications = (int) Math.round(noise * nrOfExamples); // start search with start class if(startDescription == null) { - Thing top = new Thing(); - startNode = new ExampleBasedNode(top); - // top covers all negatives - int coveredNegativeExamples = getNumberOfNegatives(); - startNode.setCoveredNegativeExamples(coveredNegativeExamples); - startNode.setCoveredPositives(learningProblem.getPositiveExamples()); - startNode.setCoveredNegatives(learningProblem.getNegativeExamples()); + startNode = new ExampleBasedNode(Thing.instance); + startNode.setCoveredExamples(learningProblem.getPositiveExamples(), learningProblem.getNegativeExamples()); } else { startNode = new ExampleBasedNode(startDescription); Set<Individual> coveredNegatives = rs.instanceCheck(startDescription, learningProblem.getNegativeExamples()); - startNode.setCoveredPositives(rs.instanceCheck(startDescription, learningProblem.getPositiveExamples())); - startNode.setCoveredNegatives(coveredNegatives); - startNode.setCoveredNegativeExamples(coveredNegatives.size()); + Set<Individual> coveredPositives = rs.instanceCheck(startDescription, learningProblem.getPositiveExamples()); + startNode.setCoveredExamples(coveredPositives, coveredNegatives); } candidates.add(startNode); candidatesStable.add(startNode); - // note that TOP may already be a solution + ExampleBasedNode bestNode = startNode; -// solutionFound = (coveredNegativeExamples == 0); -// solutions = new LinkedList<Concept>(); -// if(solutionFound) -// solutions.add(top); - + int loop = 0; algorithmStartTime = System.nanoTime(); @@ -571,8 +559,7 @@ // quality is the number of misclassifications (if it is not too weak) quality = (nrOfPositiveExamples - newlyCoveredPositives.size()) + newlyCoveredNegatives.size(); - newNode.setCoveredNegatives(newlyCoveredNegatives); - newNode.setCoveredPositives(newlyCoveredPositives); + newNode.setCoveredExamples(newlyCoveredPositives, newlyCoveredNegatives); } } @@ -588,7 +575,7 @@ solutions.add(refinement); } - newNode.setCoveredNegativeExamples(quality); +// newNode.setCoveredNegativeExamples(quality); newCandidates.add(newNode); // candidates.add(newNode); // candidatesStable.add(newNode); Added: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-03-05 12:07:28 UTC (rev 688) @@ -0,0 +1,114 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.refexamples; + +import org.dllearner.utilities.ConceptComparator; + +/** + * This heuristic combines the following criteria to assign a + * double score value to a node: + * <ul> + * <li>quality/accuracy of a concept (based on the full training set, not + * the negative example coverage as the flexible heuristic)</li> + * <li>horizontal expansion</li> + * <li>accuracy gain: The heuristic takes into account the accuracy + * difference between a node and its parent. If there is no gain (even + * though we know that the refinement is proper) it is unlikely (although + * not excluded) that the refinement is a necessary path to take towards a + * solution.</li> + * </ul> + * + * The heuristic has two parameters: + * <ul> + * <li>expansion penalty factor: describes how much accuracy gain is worth + * an increase of horizontal expansion by one (typical value: 0.01)</li> + * <li>gain bonus factor: describes how accuracy gain should be weighted + * versus accuracy itself (typical value: 1.00)</li> + * </ul> + * + * The value of a node is calculated as follows: + * + * <p><code>value = accuracy + gain bonus factor * accuracy gain - expansion penalty + * factor * horizontal expansion</code></p> + * + * <p><code>accuracy = (TP + TN)/(P + N)</code></p> + * + * <p><code> + * TP = number of true positives (= covered positives)<br /> + * TN = number of true negatives (= nr of negatives examples - covered negatives)<br /> + * P = number of positive examples<br /> + * N = number of negative examples<br /> + * </code></p> + * + * @author Jens Lehmann + * + */ +public class MultiHeuristic implements ExampleBasedHeuristic { + + private ConceptComparator conceptComparator = new ConceptComparator(); + + // heuristic parameters + private double expansionPenaltyFactor = 0.01; + private double gainBonusFactor = 1.00; + + // examples + private int nrOfNegativeExamples; + private int nrOfExamples; + + public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, double expansionPenaltyFactor, double gainBonusFactor) { + this.nrOfNegativeExamples = nrOfNegativeExamples; + nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; + this.expansionPenaltyFactor = expansionPenaltyFactor; + this.gainBonusFactor = gainBonusFactor; + } + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(ExampleBasedNode node1, ExampleBasedNode node2) { + double score1 = getNodeScore(node1); + double score2 = getNodeScore(node2); + double diff = score1 - score2; + if(diff>0) + return 1; + else if(diff<0) + return -1; + else + // TODO: would it be OK to simply return 0 here (?) + // could improve performance a bit + return conceptComparator.compare(node1.getConcept(), node2.getConcept()); + } + + public double getNodeScore(ExampleBasedNode node) { + double accuracy = getAccuracy(node.getCoveredPositives().size(),node.getCoveredNegatives().size()); + ExampleBasedNode parent = node.getParent(); + double gain = 0; + if(parent != null) { + double parentAccuracy = getAccuracy(parent.getCoveredPositives().size(),parent.getCoveredNegatives().size()); + gain = accuracy - parentAccuracy; + } + return accuracy + gainBonusFactor * gain - expansionPenaltyFactor * node.getHorizontalExpansion(); + } + + private double getAccuracy(int coveredPositives, int coveredNegatives) { + return (coveredPositives + nrOfNegativeExamples - coveredNegatives)/(double)nrOfExamples; + + } +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-03-04 19:10:55 UTC (rev 687) +++ trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-03-05 12:07:28 UTC (rev 688) @@ -1,3 +1,22 @@ +/** + * 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.owl; import java.util.Map; @@ -2,13 +21,11 @@ - - +/** + * Implementation of owl:nothing/BOTTOM. + * + * @author Jens Lehmann + * + */ public class Nothing extends Description { - /* - @Override - protected void calculateSets(FlatABox abox, SortedSet<String> adcPosSet, SortedSet<String> adcNegSet) { - posSet = abox.bottom; - negSet = abox.top; - } - */ + public static final Nothing instance = new Nothing(); @@ -48,5 +65,4 @@ visitor.visit(this); } - } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Thing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-03-04 19:10:55 UTC (rev 687) +++ trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-03-05 12:07:28 UTC (rev 688) @@ -1,3 +1,22 @@ +/** + * 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.owl; import java.util.Map; @@ -2,12 +21,19 @@ +/** + * Implementation of owl:thing/TOP. + * + * TODO: According to the OWL 1.1 spec, owl:thing is special instance of + * class, so it might be better to put a method there for retrieving + * a/the instance of owl:thing. However, some algorithms require parent + * links e.g. in EXISTS r.TOP we may need to know where TOP belongs + * (especially for genetic operators). This is instance dependant, i.e. + * two different instances of TOP can have different parent links. + * + * @author Jens Lehmann + * + */ public class Thing extends Description { - /* - @Override - protected void calculateSets(FlatABox abox, SortedSet<String> adcPosSet, SortedSet<String> adcNegSet) { - posSet = abox.top; - negSet = abox.bottom; - } - */ - + public static final Thing instance = new Thing(); + public String toString(String baseURI, Map<String,String> prefixes) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-04 19:11:41
|
Revision: 687 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=687&view=rev Author: jenslehmann Date: 2008-03-04 11:10:55 -0800 (Tue, 04 Mar 2008) Log Message: ----------- reasoning bug fixes and extensions Modified Paths: -------------- trunk/examples/commandcollection.txt trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/examples/commandcollection.txt =================================================================== --- trunk/examples/commandcollection.txt 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/examples/commandcollection.txt 2008-03-04 19:10:55 UTC (rev 687) @@ -66,3 +66,4 @@ import("http://dbpedia.openlinksw.com:8890/sparql","SPARQL"); sparql.instances = {}; +posNegDefinition.percentPerLengthUnit = 0.10; \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-03-04 19:10:55 UTC (rev 687) @@ -149,6 +149,22 @@ return ret; } + // convenience method returning those values which have value "false" for this + // datatype property + public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); + SortedSet<Individual> ret = new TreeSet<Individual>(); + for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { + SortedSet<Constant> values = e.getValue(); + for(Constant c : values) { + boolean v = Boolean.parseBoolean(c.getLiteral()); + if(v == false) + ret.add(e.getKey()); + } + } + return ret; + } + public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Modified: trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-03-04 19:10:55 UTC (rev 687) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public class TypedConstant extends Constant { +public class TypedConstant extends Constant implements Comparable<TypedConstant> { private Datatype datatype; @@ -47,7 +47,8 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return literal + "^^" + datatype; + return literal; +// return literal + "^^" + datatype; } /** @@ -62,6 +63,19 @@ */ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(TypedConstant o) { + // the first criteria is the datatype + int datatypeComparision = datatype.getURI().compareTo(datatype.getURI()); + if(datatypeComparision == 0) { + // the second criterion is the literal value + return literal.compareTo(o.literal); + } else + return datatypeComparision; } } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-03-04 19:10:55 UTC (rev 687) @@ -204,6 +204,10 @@ // and cannot parser its own generated file // DisjointClassesAxiom disjointAtomTypes = getDisjointClassesAxiom(atomTypes); // kb.addAxiom(disjointAtomTypes); + String[] mainClasses = new String[] {"Compound", "Atom", "Bond", "Structure"}; + Set<String> mainClassesSet = new HashSet<String>(Arrays.asList(mainClasses)); + DisjointClassesAxiom disjointAtomTypes = getDisjointClassesAxiom(mainClassesSet); + kb.addAxiom(disjointAtomTypes); // all different axiom (UNA) // exporting differentIndividuals axioms is broken in OWL API @@ -230,9 +234,12 @@ String confHeader = "import(\"pte.owl\");\n\n"; confHeader += "reasoner = fastInstanceChecker;\n"; confHeader += "algorithm = refexamples;\n"; -// confHeader += "refinement.writeSearchTree = true;"; -// confHeader += "refinement.searchTreeFile = \"log/carcinogenesis/searchTree.log\""; - confHeader += "\n\n"; + confHeader += "refexamples.noisePercentage = 35;\n"; + confHeader += "refexamples.startClass = " + getURI2("Compound") + ";\n"; + confHeader += "refexamples.writeSearchTree = false;\n"; + confHeader += "refexamples.searchTreeFile = \"log/carcinogenesis/searchTree.log\";\n"; + confHeader += "posNegDefinition.percentPerLengthUnit = 0.10;\n"; + confHeader += "\n"; Files.appendFile(confTrainFile, confHeader); // generating training examples @@ -338,7 +345,9 @@ } else if (headName.equals("has_property")) { String compoundName = head.getArgument(0).toPLString(); String testName = head.getArgument(1).toPLString(); - boolean testResult = Boolean.parseBoolean(head.getArgument(2).toPLString()); + String resultStr = head.getArgument(2).toPLString(); + boolean testResult = (resultStr.equals("p")) ? true : false; + // create a new datatype property if it does not exist already if(!tests.contains(testName)) { String axiom1 = "DPDOMAIN(" + getURI2(testName) + ") = " + getURI2("Compound") + ".\n"; @@ -453,7 +462,7 @@ private static DisjointClassesAxiom getDisjointClassesAxiom(Set<String> classes) { Set<Description> descriptions = new HashSet<Description>(); for(String namedClass : classes) - descriptions.add(new NamedClass(namedClass)); + descriptions.add(new NamedClass(getURI(namedClass))); return new DisjointClassesAxiom(descriptions); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-03-04 19:10:55 UTC (rev 687) @@ -56,6 +56,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.utilities.Helper; /** * Reasoner for fast instance checks. It works by completely dematerialising the @@ -76,6 +77,8 @@ private static Logger logger = Logger.getLogger(FastInstanceChecker.class); + private boolean defaultNegation = true; + private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private SortedSet<DatatypeProperty> datatypeProperties; @@ -96,10 +99,9 @@ // object property mappings private Map<ObjectProperty, Map<Individual, SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty, Map<Individual, SortedSet<Individual>>>(); // datatype property mappings - // (for booleans we assume that just one mapping exists, e.g. - // hasValue(object,true) and hasValue(object,false) will - // lead to undefined behaviour (they are logical contradictions) - private Map<DatatypeProperty, SortedSet<Individual>> bd = new TreeMap<DatatypeProperty, SortedSet<Individual>>(); + // we have one mapping for true and false for efficiency reasons + private Map<DatatypeProperty, SortedSet<Individual>> bdPos = new TreeMap<DatatypeProperty, SortedSet<Individual>>(); + private Map<DatatypeProperty, SortedSet<Individual>> bdNeg = new TreeMap<DatatypeProperty, SortedSet<Individual>>(); // for int and double we assume that a property can have several values, // althoug this should be rare, // e.g. hasValue(object,2) and hasValue(object,3) @@ -151,20 +153,39 @@ // FastRetrievalReasoner later) long dematStartTime = System.currentTimeMillis(); - for (NamedClass atomicConcept : rs.getAtomicConcepts()) { - classInstancesPos.put(atomicConcept, rs.retrieval(atomicConcept)); - Negation negatedAtomicConcept = new Negation(atomicConcept); - classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); + logger.debug("dematerialising concepts"); + + for (NamedClass atomicConcept : rs.getAtomicConcepts()) { + + SortedSet<Individual> pos = rs.retrieval(atomicConcept); + classInstancesPos.put(atomicConcept, pos); + + if(defaultNegation) { + classInstancesNeg.put(atomicConcept, Helper.difference(individuals,pos)); + } else { + // Pellet needs approximately infinite time to answer negated queries + // on the carcinogenesis data set (and probably others), so we have to + // be careful here + Negation negatedAtomicConcept = new Negation(atomicConcept); + classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); + } + + } + logger.debug("dematerialising object properties"); + for (ObjectProperty atomicRole : atomicRoles) { opPos.put(atomicRole, rc.getRoleMembers(atomicRole)); } + logger.debug("dematerialising datatype properties"); + for (DatatypeProperty dp : booleanDatatypeProperties) { - bd.put(dp, rc.getTrueDatatypeMembers(dp)); + bdPos.put(dp, rc.getTrueDatatypeMembers(dp)); + bdNeg.put(dp, rc.getFalseDatatypeMembers(dp)); } - + for (DatatypeProperty dp : intDatatypeProperties) { id.put(dp, rc.getIntDatatypeMembers(dp)); } @@ -269,9 +290,9 @@ if(value) { // check whether the individual is in the set of individuals mapped // to true by this datatype property - return bd.get(dp).contains(individual); + return bdPos.get(dp).contains(individual); } else { - return !bd.get(dp).contains(individual); + return bdNeg.get(dp).contains(individual); } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-03-04 19:10:55 UTC (rev 687) @@ -248,7 +248,8 @@ reasoner = new uk.ac.manchester.cs.factplusplus.owlapi.Reasoner(manager); } catch (Exception e) { e.printStackTrace(); - } + } + System.out.println("Using FaCT++."); } else { // instantiate Pellet reasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-04 13:40:00 UTC (rev 686) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-03-04 19:10:55 UTC (rev 687) @@ -115,7 +115,7 @@ private Map<NamedClass,Set<DatatypeProperty>> mgbd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); private Map<NamedClass,Set<DatatypeProperty>> mgdd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); - // comparator für Konzepte + // concept comparator private ConceptComparator conceptComparator = new ConceptComparator(); // Statistik @@ -129,6 +129,11 @@ private boolean useNegation = true; private boolean useBooleanDatatypes = true; + // caches for reasoner queries +// private Map<NamedClass,Map<NamedClass,Boolean>> abDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); + private Map<NamedClass,Map<NamedClass,Boolean>> notABDisjoint = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); +// private Map<NamedClass,Map<NamedClass,Boolean>> notABMeaningful = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); + public RhoDRDown(ReasoningService reasoningService) { this(reasoningService, true, true, true, true, true, true, null); } @@ -562,7 +567,7 @@ m2.add(c); else { NamedClass a = (NamedClass) c; - if(!isNotADisjoint(a, nc) && isNotAMeaningFul(a, nc)) + if(!isNotADisjoint(a, nc) && isNotAMeaningful(a, nc)) m2.add(new Negation(a)); } } @@ -697,19 +702,29 @@ // we need to test whether NOT A AND B is equivalent to BOTTOM private boolean isNotADisjoint(NamedClass a, NamedClass b) { - Description notA = new Negation(a); - Description d = new Intersection(notA, b); - return rs.subsumes(new Nothing(), d); + Map<NamedClass,Boolean> tmp = notABDisjoint.get(a); + Boolean tmp2 = null; + if(tmp != null) + tmp2 = tmp.get(b); + + if(tmp2==null) { + Description notA = new Negation(a); + Description d = new Intersection(notA, b); + Boolean result = rs.subsumes(new Nothing(), d); + // ... add to cache ... + return result; + } else + return tmp2; } // we need to test whether NOT A AND B = B // (if not then NOT A is not meaningful in the sense that it does // not semantically add anything to B) - private boolean isNotAMeaningFul(NamedClass a, NamedClass b) { + private boolean isNotAMeaningful(NamedClass a, NamedClass b) { Description notA = new Negation(a); Description d = new Intersection(notA, b); // check b subClassOf b AND NOT A (if yes then it is not meaningful) return !rs.subsumes(d, b); - } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-04 13:40:27
|
Revision: 686 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=686&view=rev Author: tonytacker Date: 2008-03-04 05:40:00 -0800 (Tue, 04 Mar 2008) Log Message: ----------- changed methods to get nanoseconds, add percent-method Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-04 12:02:49 UTC (rev 685) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-04 13:40:00 UTC (rev 686) @@ -90,36 +90,53 @@ * Show Statistics. */ public void showStats() { + Long algorithmRunTime = null; + Long overallReasoningTime = null; + Long instanceCheckReasoningTime = null; + Long retrievalReasoningTime = null; + Long subsumptionReasoningTime = null; infoArea.setText(""); - // best solution - if (config.getLearningAlgorithm().getBestSolution() != null) + // best solutions + if (config.getLearningAlgorithm().getBestSolutions(5) != null) infoArea.append("BestSolution:\n" - + config.getLearningAlgorithm().getBestSolution().toString() + "\n\n"); + + config.getLearningAlgorithm().getBestSolutions(5).toString() + "\n\n"); // solution score -// if (config.getLearningAlgorithm().getSolutionScore() != null) -// infoArea.append("SolutionScore:\n" -// + config.getLearningAlgorithm().getSolutionScore().toString() + "\n\n"); + // if (config.getLearningAlgorithm().getSolutionScore() != null) + // infoArea.append("SolutionScore:\n" + // + config.getLearningAlgorithm().getSolutionScore().toString() + // + "\n\n"); + // reasoner statistics - if (config.getAlgorithmRunTime() != null) - infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + "\n"); - infoArea.append("OverallReasoningTime: " - + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + if (config.getAlgorithmRunTime() != null) { + algorithmRunTime = config.getAlgorithmRunTime(); + infoArea.append("Algorithm Runtime: " + makeTime(algorithmRunTime) + "\n"); + } + overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); + infoArea.append("OverallReasoningTime: " + makeTime(overallReasoningTime) + + Percent(overallReasoningTime, algorithmRunTime) + "\n"); infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + "): "); - if (config.getReasoningService().getNrOfInstanceChecks() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) - + "\n"); - else + if (config.getReasoningService().getNrOfInstanceChecks() > 0) { + instanceCheckReasoningTime = config.getReasoningService() + .getInstanceCheckReasoningTimeNs(); + infoArea.append(makeTime(instanceCheckReasoningTime) + + Percent(instanceCheckReasoningTime, algorithmRunTime) + "\n"); + } else infoArea.append(" - \n"); infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + "): "); - if (config.getReasoningService().getNrOfRetrievals() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + "\n"); - else + if (config.getReasoningService().getNrOfRetrievals() > 0) { + retrievalReasoningTime = config.getReasoningService().getRetrievalReasoningTimeNs(); + infoArea.append(makeTime(retrievalReasoningTime) + + Percent(retrievalReasoningTime, algorithmRunTime) + "\n"); + } else infoArea.append(" - \n"); - if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) + if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) { + subsumptionReasoningTime = config.getReasoningService().getSubsumptionReasoningTimeNs(); infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " - + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + + makeTime(subsumptionReasoningTime) + + Percent(subsumptionReasoningTime, algorithmRunTime) + "\n"); + } } /** @@ -161,4 +178,20 @@ time += nanos + "ns "; return time; } + + /** + * Get a percent string like this: "(10,5 %)" + * + * @param a + * @param b + * @return + */ + public String Percent(Long a, Long b) { + if (a != null && b != null) { + Double c = (double) a / (double) b * (double) 100; + c = Math.ceil(c * 10) / 10; + return " (" + c.toString() + " %) "; + } + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-04 12:02:49 UTC (rev 685) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-04 13:40:00 UTC (rev 686) @@ -41,6 +41,11 @@ @Override public void run() { if (config.getThreadIsRunning()) { + try { + sleep(1000); // sleep 1 second + } catch (InterruptedException e) { + e.printStackTrace(); + } while (config.getThreadIsRunning()) { try { runPanel.showStats(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-03-04 12:02:59
|
Revision: 685 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=685&view=rev Author: sknappe Date: 2008-03-04 04:02:49 -0800 (Tue, 04 Mar 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 12:01:07 UTC (rev 684) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 12:02:49 UTC (rev 685) @@ -394,7 +394,7 @@ foreach ($concepts as $con){ $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".$con."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs - $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."</div>"; + $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; $i++; } $concept.="</table>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-03-04 12:01:22
|
Revision: 684 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=684&view=rev Author: sknappe Date: 2008-03-04 04:01:07 -0800 (Tue, 04 Mar 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 11:56:16 UTC (rev 683) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 12:01:07 UTC (rev 684) @@ -364,8 +364,8 @@ session_id($sid); session_start(); - $positives=$_SESSION['positive']; - $negatives=$_SESSION['negative']; + if (isset($_SESSION['positive'])) $positives=$_SESSION['positive']; + if (isset($_SESSION['negative'])) $negatives=$_SESSION['negative']; $id=$_SESSION['id']; $ksID=$_SESSION['ksID']; session_write_close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-03-04 11:56:53
|
Revision: 683 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=683&view=rev Author: sknappe Date: 2008-03-04 03:56:16 -0800 (Tue, 04 Mar 2008) Log Message: ----------- deactivated getConceptLength Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-03-04 11:50:48 UTC (rev 682) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-03-04 11:56:16 UTC (rev 683) @@ -44,7 +44,7 @@ { $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedFilter", 5); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedFilter", 1); $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedEndpoint", 1); $this->client->setReasoner($this->id, "dig"); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 11:50:48 UTC (rev 682) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-03-04 11:56:16 UTC (rev 683) @@ -394,7 +394,7 @@ foreach ($concepts as $con){ $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".$con."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs - $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; + $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."</div>"; $i++; } $concept.="</table>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-04 11:51:01
|
Revision: 682 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=682&view=rev Author: jenslehmann Date: 2008-03-04 03:50:48 -0800 (Tue, 04 Mar 2008) Log Message: ----------- small bug fix in string output Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-03-04 08:17:44 UTC (rev 681) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-03-04 11:50:48 UTC (rev 682) @@ -51,11 +51,6 @@ return 0; } - @Override - public String toString() { - return name; - } - public String toString(String baseURI, Map<String,String> prefixes) { return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-04 08:17:55
|
Revision: 681 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=681&view=rev Author: jenslehmann Date: 2008-03-04 00:17:44 -0800 (Tue, 04 Mar 2008) Log Message: ----------- TreeModel for search tree GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/EBNodeTreeModel.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-04 03:54:48 UTC (rev 680) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-04 08:17:44 UTC (rev 681) @@ -344,4 +344,8 @@ algorithm.stop(); } + public ExampleBasedNode getStartNode() { + return algorithm.getStartNode(); + } + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-04 03:54:48 UTC (rev 680) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-04 08:17:44 UTC (rev 681) @@ -103,6 +103,9 @@ // setting to true gracefully stops the algorithm private boolean stop = false; + // node from which algorithm has started + private ExampleBasedNode startNode; + // solution protocol private boolean solutionFound = false; private List<Description> solutions = new LinkedList<Description>(); @@ -220,7 +223,6 @@ allowedMisclassifications = (int) Math.round(noise * nrOfExamples); // start search with start class - ExampleBasedNode startNode; if(startDescription == null) { Thing top = new Thing(); startNode = new ExampleBasedNode(top); @@ -748,6 +750,8 @@ return learningProblem.computeScore(getBestSolution()); } - + public ExampleBasedNode getStartNode() { + return startNode; + } } Added: trunk/src/dl-learner/org/dllearner/gui/EBNodeTreeModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/EBNodeTreeModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/EBNodeTreeModel.java 2008-03-04 08:17:44 UTC (rev 681) @@ -0,0 +1,116 @@ +/** + * 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.gui; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +import org.dllearner.algorithms.refexamples.ExampleBasedNode; +import org.dllearner.algorithms.refexamples.NodeComparatorStable; + +/** + * A tree model used for displaying example based nodes. A search tree + * can become very large, so lazy loading should be used, i.e. never + * load the full search tree but only the nodes selected by the user. + * Note that the search tree changes over time. + * + * @author Jens Lehmann + * + */ +public class EBNodeTreeModel implements TreeModel { + + // root of the search tree + private ExampleBasedNode rootNode; + + // a mapping from nodes to their children; + // the main problem is that example based nodes use sets instead + // of lists, so we need to convert these sets to lists and store + // them here + private Map<ExampleBasedNode,List<ExampleBasedNode>> childrenMap = new TreeMap<ExampleBasedNode,List<ExampleBasedNode>>(new NodeComparatorStable()); + + // listeners for this model + private List<TreeModelListener> treeModelListeners = + new LinkedList<TreeModelListener>(); + + public EBNodeTreeModel(ExampleBasedNode rootNode) { + this.rootNode = rootNode; + } + + public void addTreeModelListener(TreeModelListener l) { + treeModelListeners.add(l); + } + + public Object getChild(Object parent, int index) { + return getChildren((ExampleBasedNode)parent).get(index); + } + + public int getChildCount(Object parent) { + return ((ExampleBasedNode)parent).getChildren().size(); + } + + public int getIndexOfChild(Object parent, Object child) { + return getChildren((ExampleBasedNode)parent).indexOf(child); + } + + public Object getRoot() { + return rootNode; + } + + public boolean isLeaf(Object node) { + return (getChildCount(node)==0); + } + + public void removeTreeModelListener(TreeModelListener l) { + treeModelListeners.remove(l); + } + + public void valueForPathChanged(TreePath path, Object newValue) { + + } + + private void fireTreeStructureChanged(ExampleBasedNode node) { + TreeModelEvent e = new TreeModelEvent(this, + new Object[] {node}); + for (TreeModelListener tml : treeModelListeners) { + tml.treeStructureChanged(e); + } + } + + // convert the set of children to a list and store it in this model + private List<ExampleBasedNode> getChildren(ExampleBasedNode node) { + List<ExampleBasedNode> children = childrenMap.get(node); + // if the children have not been cached or the list is outdated + // (node has more children now) we do an update + if(children == null || children.size() != node.getChildren().size()) { + children = new LinkedList<ExampleBasedNode>(node.getChildren()); + childrenMap.put(node, children); + fireTreeStructureChanged(node); + } + return children; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-04 03:55:05
|
Revision: 680 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=680&view=rev Author: tonytacker Date: 2008-03-03 19:54:48 -0800 (Mon, 03 Mar 2008) Log Message: ----------- I made statistics in an extra thread. It will be auto updated every 5 seconds. /examples/test.conf was generated and can be overwritten, deleted or what you want. This file is not necessary but useful. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/examples/test.conf trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java Added: trunk/examples/test.conf =================================================================== --- trunk/examples/test.conf (rev 0) +++ trunk/examples/test.conf 2008-03-04 03:54:48 UTC (rev 680) @@ -0,0 +1,7 @@ +import("father.kb"); + ++"http://localhost/foo#bernd" ++"http://localhost/foo#gabi" + +-"http://localhost/foo#markus" + Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-03 23:51:39 UTC (rev 679) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-04 03:54:48 UTC (rev 680) @@ -35,13 +35,12 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton, - getReasonerStatsButton; + private JButton runButton, stopButton; private JTextArea infoArea; private Config config; private ThreadRun thread; - private Boolean runBoolean = new Boolean(false); + // private Boolean runBoolean = new Boolean(false); private JPanel showPanel = new JPanel(); private JPanel infoPanel = new JPanel(); @@ -57,15 +56,6 @@ stopButton = new JButton("Stop"); stopButton.addActionListener(this); - getBestSolutionButton = new JButton("GetBestSolution"); - getBestSolutionButton.addActionListener(this); - - getSolutionScoreButton = new JButton("GetSolutionScore"); - getSolutionScoreButton.addActionListener(this); - - getReasonerStatsButton = new JButton("GetReasonerStats"); - getReasonerStatsButton.addActionListener(this); - infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); @@ -74,10 +64,6 @@ infoPanel.add(infoScroll); - solutionPanel.add(getBestSolutionButton); - solutionPanel.add(getSolutionScoreButton); - solutionPanel.add(getReasonerStatsButton); - add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); add(solutionPanel, BorderLayout.PAGE_END); @@ -90,48 +76,50 @@ thread = new ThreadRun(config); config.getReasoningService().resetStatistics(); thread.start(); - this.runBoolean = true; + // this.runBoolean = true; + ThreadStatistics threadStatistics = new ThreadStatistics(config, this); + threadStatistics.start(); } // stop if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { thread.exit(); } - // getBestSolution - if (e.getSource() == getBestSolutionButton && runBoolean) { - if (config.getLearningAlgorithm().getBestSolution() != null) - infoArea.setText(config.getLearningAlgorithm().getBestSolution().toString()); - } - // getSolutionScore - if (e.getSource() == getSolutionScoreButton && runBoolean) { - if (config.getLearningAlgorithm().getSolutionScore() != null) - infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); - } - // ReasonerStats - if (e.getSource() == getReasonerStatsButton && runBoolean) { - infoArea.setText(""); - if (config.getAlgorithmRunTime() != null) - infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) - + "\n"); - infoArea.append("OverallReasoningTime: " - + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); - infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() - + "): "); - if (config.getReasoningService().getNrOfInstanceChecks() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) - + "\n"); - else - infoArea.append(" - \n"); - infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() - + "): "); - if (config.getReasoningService().getNrOfRetrievals() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) - + "\n"); - else - infoArea.append(" - \n"); + } + + /** + * Show Statistics. + */ + public void showStats() { + infoArea.setText(""); + // best solution + if (config.getLearningAlgorithm().getBestSolution() != null) + infoArea.append("BestSolution:\n" + + config.getLearningAlgorithm().getBestSolution().toString() + "\n\n"); + // solution score +// if (config.getLearningAlgorithm().getSolutionScore() != null) +// infoArea.append("SolutionScore:\n" +// + config.getLearningAlgorithm().getSolutionScore().toString() + "\n\n"); + // reasoner statistics + if (config.getAlgorithmRunTime() != null) + infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + "\n"); + infoArea.append("OverallReasoningTime: " + + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + + "): "); + if (config.getReasoningService().getNrOfInstanceChecks() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + "): "); + if (config.getReasoningService().getNrOfRetrievals() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + "\n"); + else + infoArea.append(" - \n"); + if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); - } } /** @@ -142,6 +130,8 @@ * @return a string like this: 3h 10min 46s 753ms */ public String makeTime(Long nanoSeconds) { + if (nanoSeconds == null) + return null; Long hours = 0L, minutes = 0L, seconds = 0L, millis = 0L, mikros = 0L, nanos = 0L; String time = ""; Added: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-04 03:54:48 UTC (rev 680) @@ -0,0 +1,55 @@ +package org.dllearner.gui; + +/** + * 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/>. + * + */ + +/** + * Start statistics in a new thread. + * + * @author Tilo Hielscher + */ +public class ThreadStatistics extends Thread { + + Config config; + RunPanel runPanel; + + public ThreadStatistics(Config config, RunPanel runPanel) { + this.config = config; + this.runPanel = runPanel; + } + + /** + * method to start thread + */ + @Override + public void run() { + if (config.getThreadIsRunning()) { + while (config.getThreadIsRunning()) { + try { + runPanel.showStats(); + sleep(5000); // sleep 5 seconds + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + runPanel.showStats(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-03 23:51:42
|
Revision: 679 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=679&view=rev Author: tonytacker Date: 2008-03-03 15:51:39 -0800 (Mon, 03 Mar 2008) Log Message: ----------- removed some bugs and outputs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-03 23:51:39 UTC (rev 679) @@ -301,14 +301,18 @@ } /** - * Get time in ns for run of algorithm. + * Get time in ns for run of algorithm. If algorithm is still running return + * time between RunStartTime and now. * * @return time in ns */ public Long getAlgorithmRunTime() { - if (algorithmRunStartTime != null && algorithmRunStopTime != null) - if (algorithmRunStartTime < algorithmRunStopTime) - return algorithmRunStopTime - algorithmRunStartTime; + if (algorithmRunStartTime != null) + if (algorithmRunStopTime != null) { + if (algorithmRunStartTime < algorithmRunStopTime) + return algorithmRunStopTime - algorithmRunStartTime; + } else + return System.nanoTime() - algorithmRunStartTime; return null; } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-03-03 23:51:39 UTC (rev 679) @@ -169,6 +169,7 @@ config.getLearningAlgorithm().init(); config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); } catch (ComponentInitException e) { e.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -95,7 +95,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitKnowledgeSource(false); - setSource(); + init(); } if (e.getSource() == setButton) { @@ -120,6 +120,7 @@ * after this, next tab can be used */ public void init() { + setSource(); if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -82,16 +82,16 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + choosenClassIndex = cb.getSelectedIndex(); updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningAlgorithm(false); - setLearningAlgorithm(); + init(); } if (e.getSource() == autoInitButton) Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -93,7 +93,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { this.choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningProblem(false); - setLearningProblem(); + init(); } if (e.getSource() == setButton) Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -94,7 +94,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitReasoner(false); - setReasoner(); + init(); } if (e.getSource() == setButton) { Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -23,9 +23,7 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import javax.swing.*; -import org.dllearner.utilities.Helper; /** * RunPanel let algorithm start and stop and show informations about. @@ -87,8 +85,10 @@ public void actionPerformed(ActionEvent e) { // start - if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { + if (e.getSource() == runButton && config.getLearningAlgorithm() != null + && !config.getThreadIsRunning()) { thread = new ThreadRun(config); + config.getReasoningService().resetStatistics(); thread.start(); this.runBoolean = true; } @@ -98,17 +98,20 @@ } // getBestSolution if (e.getSource() == getBestSolutionButton && runBoolean) { - infoArea.setText(config.getLearningAlgorithm().getBestSolution().toString()); + if (config.getLearningAlgorithm().getBestSolution() != null) + infoArea.setText(config.getLearningAlgorithm().getBestSolution().toString()); } // getSolutionScore if (e.getSource() == getSolutionScoreButton && runBoolean) { - infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); + if (config.getLearningAlgorithm().getSolutionScore() != null) + infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } // ReasonerStats - if (e.getSource() == getReasonerStatsButton /* && runBoolean*/) { -/* infoArea.setText(""); - infoArea.append("Algorithm Runtime: " - + makeTime(config.getAlgorithmRunTime()) + "\n"); + if (e.getSource() == getReasonerStatsButton && runBoolean) { + infoArea.setText(""); + if (config.getAlgorithmRunTime() != null) + infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + + "\n"); infoArea.append("OverallReasoningTime: " + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() @@ -128,48 +131,32 @@ infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); - -*/ infoArea.setText(makeTime(9927255727L)); - } } /** - * Build a String form nanoSeconds. + * Build a String from nanoSeconds. * * @param nanoSeconds * is type of Long and represent a time interval in ns - * @return a string like this: 3h 12min 46s 753ms + * @return a string like this: 3h 10min 46s 753ms */ - public String makeTime(long nanoSeconds) { + public String makeTime(Long nanoSeconds) { + Long hours = 0L, minutes = 0L, seconds = 0L, millis = 0L, mikros = 0L, nanos = 0L; String time = ""; - long hours, minutes, seconds, millis, mikros, nanos; - // it cuts last decimals - nanos = nanoSeconds; - mikros = nanos / 1000; - millis = mikros / 1000; - seconds = millis / 1000; - minutes = seconds / 60; - hours = minutes / 60; - - // and calculate back - minutes -= hours * 60; - seconds -= minutes * 60; - millis -= seconds * 1000; - mikros -= millis * 1000; - nanos -= mikros * 1000; - - System.out.println("TEST: " + hours + "h " + minutes + "min " + seconds + "s " + millis + "ms " + mikros + "mikro " + nanos + "nano "); - - - - - - System.out.println(Helper.prettyPrintNanoSeconds(nanoSeconds, true, true)); - - - + nanos = nanoSeconds % 1000; + nanoSeconds /= 1000; + mikros = nanoSeconds % 1000; + nanoSeconds /= 1000; + millis = nanoSeconds % 1000; + nanoSeconds /= 1000; + seconds = nanoSeconds % 60; + nanoSeconds /= 60; + minutes = nanoSeconds % 60; + nanoSeconds /= 60; + hours = nanoSeconds; + if (hours > 0) time += hours + "h "; if (minutes > 0) @@ -178,12 +165,10 @@ time += seconds + "s "; if (millis > 0) time += millis + "ms "; - if (mikros > 0) - time += mikros + "ms "; - if (nanos > 0) - time += nanos + "ms "; - - // System.out.println("time: " + time); + if (false) + time += mikros + "\xB5s "; + if (false) + time += nanos + "ns "; return time; } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-03 23:51:39 UTC (rev 679) @@ -51,6 +51,7 @@ public void exit() { if (config.getLearningAlgorithm() != null) config.getLearningAlgorithm().stop(); - System.out.println("stop"); + config.setThreadIsRunning(false); + System.out.println("stop run"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-03-03 23:51:39 UTC (rev 679) @@ -147,7 +147,8 @@ try { ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Boolean: " + configOption.getName() + " = " + value); + // System.out.println("set Boolean: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-03-03 23:51:39 UTC (rev 679) @@ -144,7 +144,8 @@ try { ConfigEntry<Double> specialEntry = new ConfigEntry<Double>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Double: " + configOption.getName() + " = " + value); + // System.out.println("set Double: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-03-03 23:51:39 UTC (rev 679) @@ -145,7 +145,8 @@ try { ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Integer: " + configOption.getName() + " = " + value); + // System.out.println("set Integer: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-03-03 23:51:39 UTC (rev 679) @@ -159,7 +159,8 @@ try { ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + configOption.getName() + " = " + value); + // System.out.println("set String: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-03 23:51:39 UTC (rev 679) @@ -286,7 +286,8 @@ ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set StringSet: " + configOption.getName() + " = " + value); + // System.out.println("set StringSet: " + configOption.getName() + // + " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-03-03 23:51:39 UTC (rev 679) @@ -233,8 +233,8 @@ ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out - .println("set StringTupleList: " + configOption.getName() + " = " + value); + // System.out.println("set StringTupleList: " + + // configOption.getName() + " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-03-03 20:07:34
|
Revision: 678 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=678&view=rev Author: jenslehmann Date: 2008-03-03 12:06:17 -0800 (Mon, 03 Mar 2008) Log Message: ----------- added support for specifying a start class (the search starts from there instead of owl:Thing) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 19:38:48 UTC (rev 677) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 20:06:17 UTC (rev 678) @@ -299,6 +299,7 @@ rs, operator, algHeuristic, + startClass, // usedConcepts, // usedRoles, noisePercentage/(double)100, Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 19:38:48 UTC (rev 677) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 20:06:17 UTC (rev 678) @@ -80,6 +80,7 @@ private ReasoningService rs; private PosNegLP learningProblem; private PosOnlyDefinitionLP posOnlyLearningProblem; + private Description startDescription; private boolean posOnly = false; private int nrOfExamples; private int nrOfPositiveExamples; @@ -171,6 +172,7 @@ ReasoningService rs, RefinementOperator operator, ExampleBasedHeuristic heuristic, + Description startDescription, // Set<AtomicConcept> allowedConcepts, // Set<AtomicRole> allowedRoles, double noise, @@ -197,6 +199,7 @@ nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; this.rs = rs; this.operator = (RhoDRDown) operator; + this.startDescription = startDescription; // initialise candidate set with heuristic as ordering candidates = new TreeSet<ExampleBasedNode>(heuristic); this.noise = noise; @@ -216,19 +219,28 @@ // calculate quality threshold required for a solution allowedMisclassifications = (int) Math.round(noise * nrOfExamples); - // start search with most general concept - Thing top = new Thing(); - ExampleBasedNode topNode = new ExampleBasedNode(top); - // top covers all negatives - int coveredNegativeExamples = getNumberOfNegatives(); - topNode.setCoveredNegativeExamples(coveredNegativeExamples); - topNode.setCoveredPositives(learningProblem.getPositiveExamples()); - topNode.setCoveredNegatives(learningProblem.getNegativeExamples()); - candidates.add(topNode); - candidatesStable.add(topNode); + // start search with start class + ExampleBasedNode startNode; + if(startDescription == null) { + Thing top = new Thing(); + startNode = new ExampleBasedNode(top); + // top covers all negatives + int coveredNegativeExamples = getNumberOfNegatives(); + startNode.setCoveredNegativeExamples(coveredNegativeExamples); + startNode.setCoveredPositives(learningProblem.getPositiveExamples()); + startNode.setCoveredNegatives(learningProblem.getNegativeExamples()); + } else { + startNode = new ExampleBasedNode(startDescription); + Set<Individual> coveredNegatives = rs.instanceCheck(startDescription, learningProblem.getNegativeExamples()); + startNode.setCoveredPositives(rs.instanceCheck(startDescription, learningProblem.getPositiveExamples())); + startNode.setCoveredNegatives(coveredNegatives); + startNode.setCoveredNegativeExamples(coveredNegatives.size()); + } + candidates.add(startNode); + candidatesStable.add(startNode); // note that TOP may already be a solution - ExampleBasedNode bestNode = topNode; + ExampleBasedNode bestNode = startNode; // solutionFound = (coveredNegativeExamples == 0); // solutions = new LinkedList<Concept>(); // if(solutionFound) @@ -272,7 +284,7 @@ } } expandedNodes.clear(); - treeString += topNode.getTreeString(); + treeString += startNode.getTreeString(); treeString += "\n"; if(replaceSearchTree) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |