Skip to content

Commit 2f01b69

Browse files
committed
Update CaDiCaL from 2.0.0 to 2.2.0
Update to the latest release.
1 parent 4fe3ade commit 2f01b69

File tree

6 files changed

+59
-12
lines changed

6 files changed

+59
-12
lines changed
File renamed without changes.

scripts/cadical_CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
file(GLOB sources "src/*.cpp" "src/*.hpp" "src/*.h")
1+
file(GLOB sources "src/*.cpp" "src/*.c" "src/*.hpp" "src/*.h")
22
# Remove "app" sources from list
33
list(REMOVE_ITEM sources
44
"${CMAKE_CURRENT_SOURCE_DIR}/src/cadical.cpp"
@@ -9,7 +9,14 @@ add_library(cadical ${sources})
99

1010
# Pass -DNBUILD to disable including the version information, which is not
1111
# needed since cbmc doesn't run the cadical binary
12-
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG)
12+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
13+
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG -Wno-error=switch-enum)
14+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
15+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
16+
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG -Wno-error=switch-enum)
17+
else()
18+
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG)
19+
endif()
1320

1421
set_target_properties(
1522
cadical

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ glucose-download:
186186
@(cd ../glucose-syrup; patch -p1 < ../scripts/glucose-syrup-patch)
187187
@$(RM) $(glucose_rev).tar.gz
188188

189-
cadical_release = rel-2.0.0
189+
cadical_release = rel-2.2.0
190190
cadical-download:
191191
@echo "Downloading CaDiCaL $(cadical_release)"
192192
@$(DOWNLOADER) https://github.com/arminbiere/cadical/archive/$(cadical_release).tar.gz

src/solvers/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ foreach(SOLVER ${sat_impl})
121121
message(STATUS "Building solvers with cadical")
122122

123123
download_project(PROJ cadical
124-
URL https://github.com/arminbiere/cadical/archive/rel-2.0.0.tar.gz
125-
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.0.0-patch
124+
URL https://github.com/arminbiere/cadical/archive/rel-2.2.0.tar.gz
125+
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.2.0-patch
126126
COMMAND cmake -E copy ${CBMC_SOURCE_DIR}/scripts/cadical_CMakeLists.txt CMakeLists.txt
127127
COMMAND ./configure
128-
URL_MD5 9fc2a66196b86adceb822a583318cc35
128+
URL_MD5 856484d1a022ca22826fc6d67432e1d1
129129
)
130130

131131
add_subdirectory(${cadical_SOURCE_DIR} ${cadical_BINARY_DIR})
@@ -144,10 +144,10 @@ foreach(SOLVER ${sat_impl})
144144
message(STATUS "Building with IPASIR solver linking against: CaDiCaL")
145145

146146
download_project(PROJ cadical
147-
URL https://github.com/arminbiere/cadical/archive/rel-2.0.0.tar.gz
148-
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.0.0-patch
147+
URL https://github.com/arminbiere/cadical/archive/rel-2.2.0.tar.gz
148+
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.2.0-patch
149149
COMMAND ./configure
150-
URL_MD5 9fc2a66196b86adceb822a583318cc35
150+
URL_MD5 856484d1a022ca22826fc6d67432e1d1
151151
)
152152

153153
message(STATUS "Building CaDiCaL")

src/solvers/sat/satcheck_cadical.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ tvt satcheck_cadical_baset::l_get(literalt a) const
2727
if(a.var_no() > narrow<unsigned>(solver->vars()))
2828
return tvt(tvt::tv_enumt::TV_UNKNOWN);
2929

30-
const int val = solver->val(a.dimacs());
30+
const int val = solver->val(a.var_no(), true);
3131
if(val>0)
32-
result = tvt(true);
32+
result = tvt(!a.sign());
3333
else if(val<0)
34-
result = tvt(false);
34+
result = tvt(a.sign());
3535
else
3636
return tvt(tvt::tv_enumt::TV_UNKNOWN);
3737

@@ -140,6 +140,35 @@ void satcheck_cadical_baset::set_assignment(literalt a, bool value)
140140
INVARIANT(false, "method not supported");
141141
}
142142

143+
# if 0
144+
/// Generate a new variable and return it as a literal
145+
/// \return New variable as literal
146+
literalt satcheck_cadical_baset::new_variable()
147+
{
148+
int new_var_index = solver->declare_more_variables(1);
149+
CHECK_RETURN(new_var_index >= 0);
150+
set_no_variables(new_var_index + 1);
151+
return literalt{static_cast<literalt::var_not>(new_var_index), false};
152+
}
153+
154+
/// Generate a vector of new variables.
155+
/// \return Vector of new variables.
156+
bvt satcheck_cadical_baset::new_variables(std::size_t width)
157+
{
158+
bvt result;
159+
result.reserve(width);
160+
161+
for(std::size_t i = _no_variables; i < _no_variables + width; ++i)
162+
result.emplace_back(i, false);
163+
164+
int new_max_var_index = solver->declare_more_variables(width);
165+
CHECK_RETURN(new_max_var_index >= 0);
166+
set_no_variables(new_max_var_index + 1);
167+
168+
return result;
169+
}
170+
# endif
171+
143172
satcheck_cadical_baset::satcheck_cadical_baset(
144173
int _preprocessing_limit,
145174
int _localsearch_limit,
@@ -150,6 +179,12 @@ satcheck_cadical_baset::satcheck_cadical_baset(
150179
localsearch_limit(_localsearch_limit)
151180
{
152181
solver->set("quiet", 1);
182+
// Explicitly disable bounded variable addition; this is disabled by default
183+
// in version 2.2.0, but will be enabled in the next major release. Early
184+
// experiments, however, suggest that this results in degraded performance. If
185+
// we ever choose to enable it then the above overrides of `new_variable` and
186+
// `new_variables` need to be enabled.
187+
solver->set("factor", 0);
153188
}
154189

155190
satcheck_cadical_baset::~satcheck_cadical_baset()

src/solvers/sat/satcheck_cadical.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class satcheck_cadical_baset : public cnf_solvert, public hardness_collectort
4444
}
4545
bool is_in_conflict(literalt a) const override;
4646

47+
#if 0
48+
literalt new_variable() override;
49+
bvt new_variables(std::size_t width) override;
50+
#endif
51+
4752
protected:
4853
resultt do_prop_solve(const bvt &assumptions) override;
4954

0 commit comments

Comments
 (0)