this repo has no description
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#include <minizinc/statistics.hh>
13
14#include <iostream>
15
16namespace MiniZinc {
17
18/// TODO all key words should be standard and defined in 1 place
19void Statistics::print(std::ostream& os) {
20 os << "%%%mzn-stat: solveTime=" << _time << std::endl
21 << "%%%mzn-stat: nodes=" << _nodes << std::endl
22 << "%%%mzn-stat: failures=" << _failures << std::endl
23 << "%%%mzn-stat: objective=" << _objective << std::endl;
24};
25
26void Statistics::time(unsigned long long t) { _time = t; }
27void Statistics::nodes(unsigned long long n) { _nodes = n; }
28void Statistics::failures(unsigned long long f) { _failures = f; }
29void Statistics::objective(double o) { _objective = o; }
30
31unsigned long long Statistics::time() const { return _time; };
32unsigned long long Statistics::nodes() const { return _nodes; };
33unsigned long long Statistics::failures() const { return _failures; };
34double Statistics::objective() const { return _objective; };
35
36Statistics& Statistics::operator+=(Statistics& s) {
37 _time += s.time();
38 _nodes += s.nodes();
39 _failures += s.failures();
40 _objective = s.objective();
41 return *this;
42}
43
44} // namespace MiniZinc