@Override public double getNodeScore(OENode node) { // accuracy as baseline double score = node.getAccuracy(); // being better than the parent gives a bonus; if(!node.isRoot()) { double accuracyGain = node.getAccuracy() - node.getParent().getAccuracy(); score += accuracyGain * gainBonusFactor; // the root node also gets a bonus to possibly spawn useful disjunctions } else { score += startNodeBonus; } // penalty for horizontal expansion score -= node.getHorizontalExpansion() * expansionPenaltyFactor; // penalty for having many child nodes (stuck prevention) score -= node.getRefinementCount() * nodeRefinementPenalty; return score; }
@Override public OWLClassExpression getExpression() { return getDescription(); }
public String getShortDescription(String baseURI) { return getShortDescription(baseURI, null); }
private TreeSet<OWLClassExpression> refineNode(LengthLimitedRefinementOperator operator, OENode node) { MonitorFactory.getTimeMonitor("refineNode").start(); // we have to remove and add the node since its heuristic evaluation changes through the expansion // (you *must not* include any criteria in the heuristic which are modified outside of this method, // otherwise you may see rarely occurring but critical false ordering in the nodes set) searchTree.updatePrepare(node); int horizExp = node.getHorizontalExpansion(); TreeSet<OWLClassExpression> refinements = (TreeSet<OWLClassExpression>) operator.refine(node.getDescription(), horizExp+1); // System.out.println("refinements: " + refinements); node.incHorizontalExpansion(); node.setRefinementCount(refinements.size()); // System.out.println("refined node: " + node); searchTree.updateDone(node); MonitorFactory.getTimeMonitor("refineNode").stop(); return refinements; }
private OENode getNextNodeToExpand() { // we expand the best node of those, which have not achieved 100% accuracy // already and have a horizontal expansion equal to their length // (rationale: further extension is likely to add irrelevant syntactical constructs) synchronized (searchTree) { Iterator<OENode> it = searchTree.descendingIterator(); while(it.hasNext()) { OENode node = it.next(); if (currentlyProcessedNodes.contains(node)) continue; if (isExpandAccuracy100Nodes() && node.getHorizontalExpansion() < OWLClassExpressionUtils.getLength(node.getDescription())) { currentlyProcessedNodes.add(node); return node; } else { if(node.getAccuracy() < 1.0 || node.getHorizontalExpansion() < OWLClassExpressionUtils.getLength(node.getDescription())) { currentlyProcessedNodes.add(node); return node; } } } } // this should practically never be called, since for any reasonable learning // task, we will always have at least one node with less than 100% accuracy return null;//nodes.last(); }
private void updateMinMaxHorizExp(OENode node) { int newHorizExp = node.getHorizontalExpansion(); double scoreThreshold = heuristic.getNodeScore(node) + 1 - node.getAccuracy(); if(n.getHorizontalExpansion() == minHorizExp) {
OENode node = new OENode(description, accuracy); searchTree.addNode(parentNode, node); OWLClassExpression niceDescription = rewrite(node.getExpression());
int horizExp = nextNode.getHorizontalExpansion();
private TreeSet<OWLClassExpression> refineNode(OENode node) { logger.trace(sparql_debug,"REFINE NODE " + node); MonitorFactory.getTimeMonitor("refineNode").start(); // we have to remove and add the node since its heuristic evaluation changes through the expansion // (you *must not* include any criteria in the heuristic which are modified outside of this method, // otherwise you may see rarely occurring but critical false ordering in the nodes set) searchTree.updatePrepare(node); int horizExp = node.getHorizontalExpansion(); TreeSet<OWLClassExpression> refinements = (TreeSet<OWLClassExpression>) operator.refine(node.getDescription(), horizExp+1); // System.out.println("refinements: " + refinements); node.incHorizontalExpansion(); node.setRefinementCount(refinements.size()); // System.out.println("refined node: " + node); searchTree.updateDone(node); MonitorFactory.getTimeMonitor("refineNode").stop(); return refinements; }
private OENode getNextNodeToExpand() { // we expand the best node of those, which have not achieved 100% accuracy // already and have a horizontal expansion equal to their length // (rationale: further extension is likely to add irrelevant syntactical constructs) Iterator<OENode> it = searchTree.descendingIterator(); if (logger.isTraceEnabled()) { for (OENode N:searchTree.getNodeSet()) { logger.trace(sparql_debug,"`getnext:"+N); } } while(it.hasNext()) { OENode node = it.next(); logger.trace(sparql_debug,"``"+node+node.getAccuracy()); if (isExpandAccuracy100Nodes() && node.getHorizontalExpansion() < OWLClassExpressionUtils.getLength(node.getDescription())) { return node; } else { if(node.getAccuracy() < 1.0 || node.getHorizontalExpansion() < OWLClassExpressionUtils.getLength(node.getDescription())) { return node; } } } // this should practically never be called, since for any reasonable learning // task, we will always have at least one node with less than 100% accuracy throw new RuntimeException("CELOE could not find any node with lesser accuracy."); }
private void updateMinMaxHorizExp(OENode node) { int newHorizExp = node.getHorizontalExpansion(); double scoreThreshold = heuristic.getNodeScore(node) + 1 - node.getAccuracy(); if(n.getHorizontalExpansion() == minHorizExp) {
OENode node = new OENode(description, accuracy); OWLClassExpression niceDescription = node.getExpression();//rewrite(node.getExpression());
int horizExp = nextNode.getHorizontalExpansion();
@Override public double getNodeScore(OENode node) { double score = node.getAccuracy(); if(!node.isRoot()) { double accuracyGain = node.getAccuracy() - node.getParent().getAccuracy(); score += accuracyGain * gainBonusFactor; score -= node.getHorizontalExpansion() * expansionPenaltyFactor; score -= node.getRefinementCount() * nodeRefinementPenalty; OWLClassExpression expression = node.getExpression();//System.out.println(expression);
@Override public int compare(OENode node1, OENode node2) { return ComparisonChain.start() .compare(getNodeScore(node1), getNodeScore(node2)) .compare(node1.getDescription(), node2.getDescription()) .result(); }
@Override public String toString() { return getShortDescription(null); }
(ConceptTransformation.getForallOccurences(description) > ConceptTransformation.getForallOccurences(parentNode.getDescription()))) { SortedSet<PropertyContext> parentContexts = ConceptTransformation.getForallContexts(parentNode.getDescription()); contexts.removeAll(parentContexts);
(ConceptTransformation.getForallOccurences(description) > ConceptTransformation.getForallOccurences(parentNode.getDescription()))) { SortedSet<PropertyContext> parentContexts = ConceptTransformation.getForallContexts(parentNode.getDescription()); contexts.removeAll(parentContexts);