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
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:154
prop_minimizet::weightt
long long signed int weightt
Definition: prop_minimize.h:51
prop_minimizet::operator()
void operator()()
Try to cover all objectives.
Definition: prop_minimize.cpp:97
prop_minimizet::objective
void objective(const literalt condition, const weightt weight=1)
Add an objective.
Definition: prop_minimize.cpp:27
prop_minimizet::current
objectivest::reverse_iterator current
Definition: prop_minimize.h:82
prop_minimizet
Computes a satisfying assignment of minimal cost according to a const function using incremental SAT.
Definition: prop_minimize.h:25
prop_minimizet::size
std::size_t size() const
Definition: prop_minimize.h:44
prop_convt
Definition: prop_conv.h:21
prop_minimizet::objectivet::fixed
bool fixed
Definition: prop_minimize.h:59
prop_minimizet::log
messaget log
Definition: prop_minimize.h:77
prop_minimizet::prop_conv
prop_convt & prop_conv
Definition: prop_minimize.h:76
prop_minimizet::iterations
unsigned iterations() const
Definition: prop_minimize.h:39
prop_minimizet::objectivet
Definition: prop_minimize.h:56
prop_minimizet::_iterations
unsigned _iterations
Definition: prop_minimize.h:72
prop_minimizet::_number_objectives
std::size_t _number_objectives
Definition: prop_minimize.h:74
prop_minimizet::prop_minimizet
prop_minimizet(prop_convt &_prop_conv, message_handlert &message_handler)
Definition: prop_minimize.cpp:19
message_handlert
Definition: message.h:27
prop_minimizet::_number_satisfied
std::size_t _number_satisfied
Definition: prop_minimize.h:73
prop_minimizet::fix_objectives
void fix_objectives()
Fix objectives that are satisfied.
Definition: prop_minimize.cpp:42
prop_minimizet::_value
weightt _value
Definition: prop_minimize.h:75
literal.h
prop_minimizet::objectivest
std::map< weightt, std::vector< objectivet > > objectivest
Definition: prop_minimize.h:68
prop_minimizet::objectives
objectivest objectives
Definition: prop_minimize.h:69
prop_minimizet::objectivet::condition
literalt condition
Definition: prop_minimize.h:58
literalt
Definition: literal.h:25
prop_minimizet::number_satisfied
std::size_t number_satisfied() const
Definition: prop_minimize.h:34
prop_minimizet::constraint
literalt constraint()
Build constraints that require us to improve on at least one goal, greedily.
Definition: prop_minimize.cpp:65
message.h
prop_minimizet::objectivet::objectivet
objectivet(const literalt _condition)
Definition: prop_minimize.h:61