CBMC
prop_minimize.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: SAT Minimizer
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_SOLVERS_PROP_PROP_MINIMIZE_H
13 #define CPROVER_SOLVERS_PROP_PROP_MINIMIZE_H
14 
15 #include <map>
16 
17 #include <util/message.h>
18 
19 #include "literal.h"
20 
21 class prop_convt;
22 
26 {
27 public:
28  prop_minimizet(prop_convt &_prop_conv, message_handlert &message_handler);
29 
30  void operator()();
31 
32  // statistics
33 
34  std::size_t number_satisfied() const
35  {
36  return _number_satisfied;
37  }
38 
39  unsigned iterations() const
40  {
41  return _iterations;
42  }
43 
44  std::size_t size() const
45  {
46  return _number_objectives;
47  }
48 
49  // managing the objectives
50 
51  typedef long long signed int weightt;
52 
53  // adds an objective with given weight
54  void objective(const literalt condition, const weightt weight = 1);
55 
56  struct objectivet
57  {
59  bool fixed;
60 
61  explicit objectivet(const literalt _condition)
62  : condition(_condition), fixed(false)
63  {
64  }
65  };
66 
67  // the map of objectives, sorted by weight
68  typedef std::map<weightt, std::vector<objectivet>> objectivest;
70 
71 protected:
72  unsigned _iterations = 0;
73  std::size_t _number_satisfied = 0;
74  std::size_t _number_objectives = 0;
78 
80  void fix_objectives();
81 
82  objectivest::reverse_iterator current;
83 };
84 
85 #endif // CPROVER_SOLVERS_PROP_PROP_MINIMIZE_H
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
Computes a satisfying assignment of minimal cost according to a const function using incremental SAT.
Definition: prop_minimize.h:26
objectivest objectives
Definition: prop_minimize.h:69
prop_minimizet(prop_convt &_prop_conv, message_handlert &message_handler)
void fix_objectives()
Fix objectives that are satisfied.
prop_convt & prop_conv
Definition: prop_minimize.h:76
std::size_t number_satisfied() const
Definition: prop_minimize.h:34
std::size_t _number_objectives
Definition: prop_minimize.h:74
unsigned _iterations
Definition: prop_minimize.h:72
std::size_t _number_satisfied
Definition: prop_minimize.h:73
std::size_t size() const
Definition: prop_minimize.h:44
long long signed int weightt
Definition: prop_minimize.h:51
literalt constraint()
Build constraints that require us to improve on at least one goal, greedily.
std::map< weightt, std::vector< objectivet > > objectivest
Definition: prop_minimize.h:68
void operator()()
Try to cover all objectives.
unsigned iterations() const
Definition: prop_minimize.h:39
void objective(const literalt condition, const weightt weight=1)
Add an objective.
objectivest::reverse_iterator current
Definition: prop_minimize.h:82
objectivet(const literalt _condition)
Definition: prop_minimize.h:61