spot  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
satsolver.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2013 Laboratoire de Recherche et Développement
3 // de l'Epita.
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #ifndef SPOT_MISC_SATSOLVER_HH
21 #define SPOT_MISC_SATSOLVER_HH
22 
23 #include "common.hh"
24 #include "tmpfile.hh"
25 #include <vector>
26 #include <stdexcept>
27 #include <iosfwd>
28 
29 namespace spot
30 {
31  class printable;
32 
34  {
35  private:
36  int count_;
37 
38  public:
40  : count_(0)
41  {
42  }
43 
44  void check() const
45  {
46  if (count_ < 0)
47  throw std::runtime_error("too many SAT clauses (more than INT_MAX)");
48  }
49 
50  clause_counter& operator++()
51  {
52  ++count_;
53  check();
54  return *this;
55  }
56 
57  clause_counter& operator+=(int n)
58  {
59  count_ += n;
60  check();
61  return *this;
62  }
63 
64  int nb_clauses() const
65  {
66  return count_;
67  }
68  };
69 
81  class SPOT_API satsolver
82  {
83  public:
84  satsolver();
85  ~satsolver();
86 
87  void start();
88  std::ostream& operator()();
89 
90  typedef std::vector<int> solution;
91  typedef std::pair<int, solution> solution_pair;
92  solution_pair get_solution();
93  private:
94  temporary_file* cnf_tmp_;
95  std::ostream* cnf_stream_;
96  };
97 
99  SPOT_API satsolver::solution
100  satsolver_get_solution(const char* filename);
101 }
102 
103 #endif // SPOT_MISC_SATSOLVER_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sat Dec 6 2014 12:28:44 for spot by doxygen 1.8.4