1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 3 /* 4 * Main authors: 5 * Guido Tack <guido.tack@monash.edu> 6 */ 7 8 /* This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 11 12 #pragma once 13 14 #include <iterator> 15 16 namespace MiniZinc { 17 18 class Statistics { 19 protected: 20 // time in milliseconds 21 unsigned long long _time; 22 // search nodes 23 unsigned long long _nodes; 24 // failures/ backtracks 25 unsigned long long _failures; 26 // current objective value 27 double _objective; 28 29 public: Statistics()30 Statistics() : _time(0), _nodes(0), _failures(0) {} 31 32 virtual void print(std::ostream& os); 33 34 void time(unsigned long long t); 35 void nodes(unsigned long long n); 36 void failures(unsigned long long f); 37 void objective(double o); 38 39 unsigned long long time() const; 40 unsigned long long nodes() const; 41 unsigned long long failures() const; 42 double objective() const; 43 44 Statistics& operator+=(Statistics& s); 45 cleanup()46 virtual void cleanup() { _time = _nodes = _failures = 0; } 47 }; 48 } // namespace MiniZinc 49