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. |