Generated on Thu Nov 2 14:49:35 2006 for Gecode/J by doxygen 1.5.0

Statistics.java

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