Skip to content

macOS build support + exact small-weight counting (configurable CUDD epsilon)#2

Draft
HenryKautz wants to merge 1 commit into
vardigroup:masterfrom
HenryKautz:macos-build-and-exact-epsilon
Draft

macOS build support + exact small-weight counting (configurable CUDD epsilon)#2
HenryKautz wants to merge 1 commit into
vardigroup:masterfrom
HenryKautz:macos-build-and-exact-epsilon

Conversation

@HenryKautz

Copy link
Copy Markdown

Two small, independent improvements. No change to the counting algorithm, and the Linux build path is unchanged (the build change is guarded by IF(APPLE)).

1. Build on macOS (Apple clang)

  • CMakeLists.txt (guarded by IF(APPLE)): macOS clang can't fully static-link (-static), and -Ofast (-ffast-math) makes ADDMC's -infinity log-space sentinel undefined behavior — so the Apple branch uses -g -O3; non-Apple keeps the original -g -Ofast -static.
  • src/interface/util.hpp: add #include <sstream> (used by formula.cpp/join.cpp; libstdc++ pulled it in transitively, libc++ does not).

(One environment note, no code change: CMake ≥ 4 removed compatibility with CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12); configure with -DCMAKE_POLICY_VERSION_MINIMUM=3.5. Happy to bump the declared minimum instead if you prefer.)

2. Exact counting for tiny weighted counts (--ep)

Counter::getModelCount now calls mgr.SetEpsilon(cuddEpsilon). CUDD's built-in epsilon (1e-12) merges ADD terminals within that tolerance into the 0 terminal, which rounds legitimately tiny weighted counts down to 0. With small literal weights a count can be far below 1e-12 (e.g. exp(-69) ≈ 1e-30):

--ep 1e-12 (CUDD's built-in default): s wmc 0
--ep 0     (this PR's default):       s wmc 2e-30

The new --ep option sets the tolerance and defaults to 0 (exact, down to double-precision underflow); pass --ep <e> to trade exactness for the speed/memory of more terminal merging.

These two parts are independent — happy to split into separate PRs if you'd rather take them separately. Opened as a draft for your consideration.

🤖 Generated with Claude Code

…D epsilon)

Two independent, portability/correctness improvements. No change to the counting
algorithm; the Linux build path is unchanged.

1. Build on macOS (guarded by IF(APPLE), so the Linux flags are untouched):
   - CMakeLists.txt: macOS clang cannot fully static-link (-static), and -Ofast
     (-ffast-math) makes the -infinity log-space sentinel undefined behavior, so
     the Apple branch uses "-g -O3"; non-Apple keeps "-g -Ofast -static".
   - src/interface/util.hpp: add #include <sstream> (libstdc++ pulled it in
     transitively, libc++ does not).

2. Exact counting for tiny weighted counts, exposed as --ep:
   Counter::getModelCount now calls mgr.SetEpsilon(cuddEpsilon). CUDD's built-in
   epsilon (1e-12) merges ADD terminals within that tolerance into the 0 terminal,
   rounding legitimately tiny weighted counts (e.g. exp(-69) ~ 1e-30) down to 0.
   The new --ep option sets this tolerance and defaults to 0 (exact, down to
   double-precision underflow); pass --ep <e> to trade exactness for merging.

README documents the macOS build and the --ep / numerical behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant