Statistics.java
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Mikael Lagerkvist <lagerkvist@gecode.org> 00004 * Guido Tack <tack@gecode.org> 00005 * 00006 * Copyright: 00007 * Mikael Lagerkvist, 2006 00008 * Guido Tack, 2006 00009 * 00010 * Last modified: 00011 * $Date: 2006-02-09 16:32:56 +0100 (Thu, 09 Feb 2006) $ by $Author: tack $ 00012 * $Revision: 2943 $ 00013 * 00014 * This file is part of Gecode, the generic constraint 00015 * development environment: 00016 * http://www.gecode.org 00017 * 00018 * See the file "LICENSE" for information on usage and 00019 * redistribution of this file, and for a 00020 * DISCLAIMER OF ALL WARRANTIES. 00021 * 00022 */ 00023 00024 package org.gecode.explorer; 00025 00026 public class Statistics { 00027 private int solutions; 00028 private int failures; 00029 private int choices; 00030 private int open; 00031 private int undetermined; 00032 private int depth; 00033 00034 private StatisticsListener solutionListener; 00035 00036 public Statistics() { 00037 reset(); 00038 } 00039 00040 public void reset() { 00041 solutions = 0; 00042 failures = 0; 00043 choices = 0; 00044 open = 0; 00045 undetermined = 1; 00046 depth = 0; 00047 } 00048 00049 public void registerSolutionListener(StatisticsListener e) { 00050 solutionListener = e; 00051 } 00052 00053 public void close() { open--; } 00054 public void newFailure() { 00055 failures++; 00056 solutionListener.newNode(); 00057 } 00058 public void newChoice() { 00059 choices++; 00060 solutionListener.newNode(); 00061 } 00062 public void newSolution() { 00063 solutions++; 00064 solutionListener.newSolution(solutions); 00065 solutionListener.newNode(); 00066 } 00067 public void newOpen() { open++; } 00068 public void newDetermined() { --undetermined; } 00069 public void newUndetermined(int u) { undetermined += u; } 00070 public void newDepth(int d) { 00071 if (d > depth) depth = d; 00072 } 00073 00074 public int getSolutions() { 00075 return solutions; 00076 } 00077 public int getFailures() { 00078 return failures; 00079 } 00080 public int getChoices() { 00081 return choices; 00082 } 00083 public int getOpen() { 00084 return open; 00085 } 00086 public int getUndetermined() { 00087 return undetermined; 00088 } 00089 public int getDepth() { 00090 return depth; 00091 } 00092 }
