From: <jen...@us...> - 2009-02-17 15:28:47
|
Revision: 1607 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1607&view=rev Author: jenslehmann Date: 2009-02-17 15:28:41 +0000 (Tue, 17 Feb 2009) Log Message: ----------- OE algorithm ctd. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-16 17:09:30 UTC (rev 1606) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-17 15:28:41 UTC (rev 1607) @@ -204,6 +204,7 @@ int horizExp = bestNode.getHorizontalExpansion(); // apply operator + System.out.println(bestNode.getDescription()); TreeSet<Description> refinements = refineNode(bestNode); while(refinements.size() != 0) { @@ -301,7 +302,8 @@ } private boolean terminationCriteriaSatisfied() { - return stop || (System.nanoTime() - nanoStartTime >= (configurator.getMaxExecutionTimeInSeconds()*1000000)); +// double runtimeSec = (System.nanoTime() - nanoStartTime; + return stop || (System.nanoTime() - nanoStartTime >= (configurator.getMaxExecutionTimeInSeconds()*1000000000)); } private void reset() { Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2009-02-16 17:09:30 UTC (rev 1606) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2009-02-17 15:28:41 UTC (rev 1607) @@ -19,21 +19,47 @@ */ package org.dllearner.algorithms.celoe; -import java.util.Comparator; - /** + * Search algorithm heuristic for the ontology engineering algorithm. The heuristic + * has a strong bias towards short descriptions (i.e. the algorithm is likely to be + * less suitable for learning complex descriptions). + * * @author Jens Lehmann * */ public class OEHeuristicRuntime implements OEHeuristic { - - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ + + // strong penalty for long descriptions + private double expansionPenaltyFactor = 0.1; + // bonus for being better than parent node + private double gainBonusFactor = 0.3; + // penalty if a node has very many children since exploring such a node is + // computationally very expensive + private double nodeChildPenalty = 0.0005; + @Override - public int compare(OENode o1, OENode o2) { - // TODO Auto-generated method stub - return 0; + public int compare(OENode node1, OENode node2) { + double diff = getNodeScore(node1) - getNodeScore(node2); + if(diff>0) + return 1; + else if(diff<0) + return -1; + else + return 0; } + public double getNodeScore(OENode node) { + // accuracy as baseline + double score = node.getAccuracy(); + // being better than the parent gives a bonus; + if(!node.isRoot()) { + double parentAccuracy = node.getParent().getAccuracy(); + score += (parentAccuracy - score) * gainBonusFactor; + } + // penalty for horizontal expansion + score -= node.getHorizontalExpansion() * expansionPenaltyFactor; + // penalty for having many child nodes (stuck prevention) + score -= node.getChildren().size() * nodeChildPenalty; + return score; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java 2009-02-16 17:09:30 UTC (rev 1606) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OENode.java 2009-02-17 15:28:41 UTC (rev 1607) @@ -19,6 +19,7 @@ */ package org.dllearner.algorithms.celoe; +import java.util.LinkedList; import java.util.List; import org.dllearner.core.owl.Description; @@ -47,7 +48,7 @@ private int horizontalExpansion; private OENode parent; - private List<OENode> children; + private List<OENode> children = new LinkedList<OENode>(); public OENode(OENode parentNode, Description description, double accuracy) { this.parent = parentNode; @@ -64,6 +65,10 @@ horizontalExpansion++; } + public boolean isRoot() { + return (parent == null); + } + /** * @return the description */ Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2009-02-16 17:09:30 UTC (rev 1606) +++ trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2009-02-17 15:28:41 UTC (rev 1607) @@ -20,13 +20,13 @@ package org.dllearner.core.configurators; /** - * Common options of refinement operators. + * Common options of refinement operators (manually created interface). * * @author Jens Lehmann * */ public abstract class RefinementOperatorConfigurator { + public abstract boolean getUseCardinalityRestrictions(); - } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-02-16 17:09:30 UTC (rev 1606) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-02-17 15:28:41 UTC (rev 1607) @@ -190,7 +190,9 @@ public RhoDRDown(ReasonerComponent reasoner, ClassHierarchy subHierarchy, RefinementOperatorConfigurator configurator) { this.rs = reasoner; this.subHierarchy = subHierarchy; + useCardinalityRestrictions = configurator.getUseCardinalityRestrictions(); // TODO add more options from configurator object + init(); } // TODO constructor which takes a RhoDRDownConfigurator object; @@ -212,9 +214,11 @@ this.useNegation = useNegation; this.useBooleanDatatypes = useBooleanDatatypes; this.useDoubleDatatypes = useDoubleDatatypes; + init(); + } // subHierarchy = rs.getClassHierarchy(); - + public void init() { // query reasoner for domains and ranges // (because they are used often in the operator) for(ObjectProperty op : rs.getObjectProperties()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |