3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-10 17:58:06 +00:00

adding totalizer

This commit is contained in:
Nikolaj Bjorner 2022-06-29 08:17:39 -07:00
parent fd8ee34564
commit 5afcb489e0
6 changed files with 194 additions and 0 deletions

44
src/opt/totalizer.h Normal file
View file

@ -0,0 +1,44 @@
/*++
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;
vector<expr_ref_vector> m_clauses;
void ensure_bound(node* n, unsigned k);
public:
totalizer(expr_ref_vector const& literals);
~totalizer();
expr* at_least(unsigned k);
vector<expr_ref_vector>& clauses() { return m_clauses; }
};
}