-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathtotalizer.h
46 lines (33 loc) · 1022 Bytes
/
totalizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*++
Copyright (c) 2022 Microsoft Corporation
Module Name:
totalizer.h
Abstract:
Incremental totalizer for at least constraints
Author:
Nikolaj Bjorner (nbjorner) 2022-06-27
--*/
#pragma once
#include "ast/ast.h"
namespace opt {
class totalizer {
struct node {
node* m_left = nullptr;
node* m_right = nullptr;
expr_ref_vector m_literals;
node(expr_ref_vector& l): m_literals(l) {}
};
ast_manager& m;
expr_ref_vector m_literals;
node* m_tree = nullptr;
expr_ref_vector m_clauses;
vector<std::pair<expr_ref, expr_ref>> m_defs;
void ensure_bound(node* n, unsigned k);
public:
totalizer(expr_ref_vector const& literals);
~totalizer();
expr* at_least(unsigned k);
expr_ref_vector& clauses() { return m_clauses; }
vector<std::pair<expr_ref, expr_ref>>& defs() { return m_defs; }
};
}