spot 2.2.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules 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 #pragma once
21
22 #include <spot/misc/common.hh>
23 #include <spot/misc/tmpfile.hh>
24 #include <vector>
25 #include <stdexcept>
26 #include <iosfwd>
27
28 namespace spot
29 {
30 class printable;
31
32 class clause_counter
33 {
34 private:
35 int count_;
36
37 public:
38 clause_counter()
39 : count_(0)
40 {
41 }
42
43 void check() const
44 {
45 if (count_ < 0)
46 throw std::runtime_error("too many SAT clauses (more than INT_MAX)");
47 }
48
49 clause_counter& operator++()
50 {
51 ++count_;
52 check();
53 return *this;
54 }
55
56 clause_counter& operator+=(int n)
57 {
58 count_ += n;
59 check();
60 return *this;
61 }
62
63 int nb_clauses() const
64 {
65 return count_;
66 }
67 };
68
80 class SPOT_API satsolver
81 {
82 public:
83 satsolver();
84 ~satsolver();
85
86 void start();
87 std::ostream& operator()();
88
89 typedef std::vector<int> solution;
90 typedef std::pair<int, solution> solution_pair;
91 solution_pair get_solution();
92 private:
93 temporary_file* cnf_tmp_;
94 std::ostream* cnf_stream_;
95 };
96
98 SPOT_API satsolver::solution
99 satsolver_get_solution(const char* filename);
100 }
spot
Definition: graph.hh:32
spot::temporary_file
Temporary file name.
Definition: tmpfile.hh:49
spot::clause_counter
Definition: satsolver.hh:32
spot::satsolver
Interface with a SAT solver.
Definition: satsolver.hh:80

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.