Liking cljdoc? Tell your friends :D

vaelii.impl.asp.clingo

In-process ASP solver: a JNA binding to the native clingo C API (which embeds clasp). Drop-in for vaelii.impl.asp.clasp/solve — same (solve aspif-text mode) contract and return shape — but without the subprocess + JSON round-trip.

Why in-process: it drops the per-solve fork and JSON round-trip the subprocess pays, which is the whole win on the small programs vaelii.impl.asp.solver routes here.

The four modes map to clingo configuration passed as command-line arguments to clingo_control_new (clingo accepts clasp's flags): --opt-mode=optN so brave/cautious enumerate over optimal models only, --enum-mode=brave|cautious, --models=0|1. Shown atoms come back as the s/c/a label strings vaelii emits via ASPIF type-4 show statements; the lexicographic cost vector comes from clingo_model_cost.

Native lib: a system libclingo (brew install clingo) reachable via jna.library.path, or an absolute path in -Dvaelii.clingo.lib. Crash isolation is lost vs the subprocess — every native return is checked and every Control is freed in a finally; a malformed program throws rather than segfaults.

In-process ASP solver: a JNA binding to the native clingo C API (which
embeds clasp). Drop-in for `vaelii.impl.asp.clasp/solve` — same
`(solve aspif-text mode)` contract and return shape — but without the
subprocess + JSON round-trip.

Why in-process: it drops the per-solve fork and JSON round-trip the
subprocess pays, which is the whole win on the small programs
`vaelii.impl.asp.solver` routes here.

The four modes map to clingo configuration passed as command-line arguments
to clingo_control_new (clingo accepts clasp's flags): --opt-mode=optN so
brave/cautious enumerate over optimal models only, --enum-mode=brave|cautious,
--models=0|1. Shown atoms come back as the s/c/a label strings vaelii emits
via ASPIF type-4 show statements; the lexicographic cost vector comes from
clingo_model_cost.

Native lib: a system libclingo (brew install clingo) reachable via
jna.library.path, or an absolute path in -Dvaelii.clingo.lib. Crash isolation
is lost vs the subprocess — every native return is checked and every Control
is freed in a finally; a malformed program throws rather than segfaults.
raw docstring

*clingo-lib*clj

Library name (resolved via jna.library.path) or absolute path to libclingo.

Library name (resolved via jna.library.path) or absolute path to libclingo.
raw docstring

available?clj

(available?)

True if libclingo can be loaded and called in this JVM.

True if libclingo can be loaded and called in this JVM.
raw docstring

classify-bothclj

(classify-both aspif-text)

Load aspif-text ONCE and run both classify enumerations over the one control, switching solve.enum_mode between them — avoiding the second control_new + load_aspif that two separate solve calls pay. Returns {:cautious <result> :brave <result>}, each shaped like solve for the corresponding classify mode.

Load `aspif-text` ONCE and run both classify enumerations over the one control,
switching `solve.enum_mode` between them — avoiding the second control_new +
load_aspif that two separate `solve` calls pay. Returns
`{:cautious <result> :brave <result>}`, each shaped like `solve` for the
corresponding classify mode.
raw docstring

delete-keep-temps!clj

(delete-keep-temps! keep)

Delete every temp File in a control's :keep vector — the ASPIF file load-block!/open-control wrote. Call AFTER free-control!. Non-File keep entries (JNA buffers) are left for GC. run-solve .deletes its one-shot temp in its own finally; a live control outlives its solve, so classify-both calls this instead of leaning on deleteOnExit — which in a long-running daemon holds one .aspif file, and one never-GC'd JVM DeleteOnExitHook entry, per classify.

Delete every temp File in a control's `:keep` vector — the ASPIF file
`load-block!`/`open-control` wrote. Call AFTER `free-control!`. Non-File
keep entries (JNA buffers) are left for GC. `run-solve` .deletes its one-shot
temp in its own finally; a live control outlives its solve, so `classify-both`
calls this instead of leaning on deleteOnExit — which in a long-running daemon
holds one .aspif file, and one never-GC'd JVM DeleteOnExitHook entry, per
classify.
raw docstring

free-control!clj

(free-control! ctl)

Free a live control and let its keep-alive buffers/temps be reclaimed. Freeing twice is a native double free, so a caller frees exactly once — classify-both does it in a finally.

Free a live control and let its keep-alive buffers/temps be reclaimed. Freeing
twice is a native double free, so a caller frees exactly once — `classify-both`
does it in a finally.
raw docstring

open-controlclj

(open-control arg-strs aspif-text)

Create a live Control with arg-strs flags and load the base aspif-text. Returns {:ctl Pointer :keep [..]}:keep holds JNA buffers and temp files that must outlive the control (free it with free-control!).

Create a live Control with `arg-strs` flags and load the base `aspif-text`.
Returns `{:ctl Pointer :keep [..]}` — `:keep` holds JNA buffers and temp
files that must outlive the control (free it with `free-control!`).
raw docstring

solveclj

(solve aspif-text mode)

Run clingo in-process on aspif-text (via load_aspif) in one of the supported modes. See finalize for the return contract.

Run clingo in-process on `aspif-text` (via load_aspif) in one of the supported
modes. See `finalize` for the return contract.
raw docstring

solve-controlclj

(solve-control ctl assume-lits)

Solve a live control under assume-lits (signed program literals assumed for THIS solve only). Drains every model. Returns {:result :models} like the one-shot path. The mode flags are fixed at open-control time; witness symbols come off the output table, the same show-shown view run-solve reads.

Solve a live control under `assume-lits` (signed program literals assumed
for THIS solve only). Drains every model. Returns `{:result :models}` like
the one-shot path. The mode flags are fixed at `open-control` time; witness
symbols come off the output table, the same `show-shown` view `run-solve` reads.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close