ITIVector -> gtl::ITIVector; experimental LNS code for SAT

This commit is contained in:
Laurent Perron
2018-06-26 21:24:10 +02:00
parent ae79a832cc
commit c1ab121ff7
54 changed files with 260 additions and 257 deletions

View File

@@ -68,7 +68,8 @@ class SatPostsolver {
//
// This can be called more than once. But each call must refer to the current
// variables set (after all the previous mapping have been applied).
void ApplyMapping(const ITIVector<BooleanVariable, BooleanVariable>& mapping);
void ApplyMapping(
const gtl::ITIVector<BooleanVariable, BooleanVariable>& mapping);
// Extracts the current assignment of the given solver and postsolve it.
//
@@ -109,7 +110,7 @@ class SatPostsolver {
// All the added clauses will be mapped back to the initial variables using
// this reverse mapping. This way, clauses_ and associated_literal_ are only
// in term of the initial problem.
ITIVector<BooleanVariable, BooleanVariable> reverse_mapping_;
gtl::ITIVector<BooleanVariable, BooleanVariable> reverse_mapping_;
// This will stores the fixed variables value and later the postsolved
// assignment.
@@ -146,7 +147,7 @@ class SatPresolver {
// Registers a mapping to encode equivalent literals.
// See ProbeAndFindEquivalentLiteral().
void SetEquivalentLiteralMapping(
const ITIVector<LiteralIndex, LiteralIndex>& mapping) {
const gtl::ITIVector<LiteralIndex, LiteralIndex>& mapping) {
equiv_mapping_ = mapping;
}
@@ -181,7 +182,7 @@ class SatPresolver {
// clause pointing to them. This return a mapping that maps this interval to
// [0, new_size) such that now all variables are used. The unused variable
// will be mapped to BooleanVariable(-1).
ITIVector<BooleanVariable, BooleanVariable> VariableMapping() const;
gtl::ITIVector<BooleanVariable, BooleanVariable> VariableMapping() const;
// Loads the current presolved problem in to the given sat solver.
// Note that the variables will be re-indexed according to the mapping given
@@ -273,7 +274,7 @@ class SatPresolver {
BooleanVariable variable;
double weight;
};
ITIVector<BooleanVariable, PQElement> var_pq_elements_;
gtl::ITIVector<BooleanVariable, PQElement> var_pq_elements_;
AdjustablePriorityQueue<PQElement> var_pq_;
// Literal priority queue for BVA. The literals are ordered by descending
@@ -304,7 +305,7 @@ class SatPresolver {
// Temporary data for SimpleBva().
std::set<LiteralIndex> m_lit_;
std::vector<ClauseIndex> m_cls_;
ITIVector<LiteralIndex, int> literal_to_p_size_;
gtl::ITIVector<LiteralIndex, int> literal_to_p_size_;
std::vector<std::pair<LiteralIndex, ClauseIndex>> flattened_p_;
std::vector<Literal> tmp_new_clause_;
@@ -319,17 +320,17 @@ class SatPresolver {
// Occurrence list. For each literal, contains the ClauseIndex of the clause
// that contains it (ordered by clause index).
ITIVector<LiteralIndex, std::vector<ClauseIndex>> literal_to_clauses_;
gtl::ITIVector<LiteralIndex, std::vector<ClauseIndex>> literal_to_clauses_;
// Because we only lazily clean the occurrence list after clause deletions,
// we keep the size of the occurrence list (without the deleted clause) here.
ITIVector<LiteralIndex, int> literal_to_clause_sizes_;
gtl::ITIVector<LiteralIndex, int> literal_to_clause_sizes_;
// Used for postsolve.
SatPostsolver* postsolver_;
// Equivalent literal mapping.
ITIVector<LiteralIndex, LiteralIndex> equiv_mapping_;
gtl::ITIVector<LiteralIndex, LiteralIndex> equiv_mapping_;
int num_trivial_clauses_;
SatParameters parameters_;
@@ -388,7 +389,7 @@ int ComputeResolvantSize(Literal x, const std::vector<Literal>& a,
void ProbeAndFindEquivalentLiteral(
SatSolver* solver, SatPostsolver* postsolver,
DratProofHandler* drat_proof_handler,
ITIVector<LiteralIndex, LiteralIndex>* mapping);
gtl::ITIVector<LiteralIndex, LiteralIndex>* mapping);
// Given a 'solver' with a problem already loaded, this will try to simplify the
// problem (i.e. presolve it) before calling solver->Solve(). In the process,