Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SmtSolverTimeoutTestUtils.h
Go to the documentation of this file.
1#pragma once
2
3#include "storm-config.h"
4#include "test/storm_gtest.h"
5
6#include <chrono>
7
11
12namespace storm::test {
13
19 uint64_t const pigeons = holes + 1;
20 std::vector<std::vector<storm::expressions::Variable>> inHole(pigeons);
21 for (uint64_t p = 0; p < pigeons; ++p) {
22 for (uint64_t h = 0; h < holes; ++h) {
23 inHole[p].push_back(manager.declareBooleanVariable("p" + std::to_string(p) + "h" + std::to_string(h)));
24 }
25 }
26 storm::expressions::Expression formula = manager.boolean(true);
27 // Each pigeon sits in some hole.
28 for (uint64_t p = 0; p < pigeons; ++p) {
29 storm::expressions::Expression somewhere = manager.boolean(false);
30 for (uint64_t h = 0; h < holes; ++h) {
31 somewhere = somewhere || inHole[p][h];
32 }
33 formula = formula && somewhere;
34 }
35 // No two pigeons share a hole.
36 for (uint64_t h = 0; h < holes; ++h) {
37 for (uint64_t p1 = 0; p1 < pigeons; ++p1) {
38 for (uint64_t p2 = p1 + 1; p2 < pigeons; ++p2) {
39 formula = formula && !(inHole[p1][h] && inHole[p2][h]);
40 }
41 }
42 }
43 return formula;
44}
45
50 solver.setTimeout(10);
51 solver.add(pigeonholeFormula(manager, 12));
52 auto const start = std::chrono::steady_clock::now();
54 EXPECT_LT(std::chrono::steady_clock::now() - start, std::chrono::seconds(1));
55
56 // After unsetting the timeout, the solver can be used again.
57 solver.unsetTimeout();
58 solver.reset();
59 storm::expressions::Variable x = manager.declareBooleanVariable("x");
60 solver.add(x);
62}
63
64} // namespace storm::test
This class is responsible for managing a set of typed variables and all expressions using these varia...
An interface that captures the functionality of an SMT solver.
Definition SmtSolver.h:21
storm::expressions::Expression pigeonholeFormula(storm::expressions::ExpressionManager &manager, uint64_t holes)
Create the (unsatisfiable) pigeonhole formula for the given number of holes and one more pigeon.
void checkSmtSolverTimeout(storm::solver::SmtSolver &solver, storm::expressions::ExpressionManager &manager)
Checks that the given solver aborts a hard query once the timeout is exceeded and remains usable afte...