Subprocess wrapper around the clasp ASP solver, or the clingo executable, which takes
the same flags and answers the same JSON (*clasp-binary*).
Takes ASPIF text on stdin and reads the JSON Result of --outf=2. clasp's exit
codes encode the solve outcome (10 sat, 20 unsat, 30 optimum) and are not errors; a
run throws only when clasp does not run or answers nothing parseable. The five modes
are solve's. The search flags are search-args, and the limits are docs/asp.md's
"The solve limit" and "The time limit".
run-clasp owns the process: it returns only after the process has exited, and kills
it with every descendant at the deadline and on a throw out of the wait.
Subprocess wrapper around the clasp ASP solver, or the clingo executable, which takes the same flags and answers the same JSON (`*clasp-binary*`). Takes ASPIF text on stdin and reads the JSON `Result` of `--outf=2`. clasp's exit codes encode the solve outcome (10 sat, 20 unsat, 30 optimum) and are not errors; a run throws only when clasp does not run or answers nothing parseable. The five modes are `solve`'s. The search flags are `search-args`, and the limits are docs/asp.md's "The solve limit" and "The time limit". `run-clasp` owns the process: it returns only after the process has exited, and kills it with every descendant at the deadline and on a throw out of the wait.
Name (or absolute path) of the executable solve runs: clasp, or clingo, whose
application takes clasp's flags and writes the same --outf=2 JSON. Read once at load
from configured-binary; bind to point solve at another install or a test stub.
Name (or absolute path) of the executable `solve` runs: clasp, or clingo, whose application takes clasp's flags and writes the same `--outf=2` JSON. Read once at load from `configured-binary`; bind to point `solve` at another install or a test stub.
(available?)True if the clasp binary runs in the current environment.
True if the clasp binary runs in the current environment.
(mode-flags mode {:keys [among models project?]})mode's flags under solve options opts, or nil for a mode mode-args lacks.
:among sets which models count: :optimal (the mode's own), :all
(--opt-mode=ignore), or a cost vector (--opt-mode=enum,…, every model whose cost is
lexicographically at most it). A positive :models caps an :all-optima enumeration,
and :project? adds --project, one model per distinct projection.
`mode`'s flags under solve options `opts`, or nil for a mode `mode-args` lacks. `:among` sets which models count: `:optimal` (the mode's own), `:all` (`--opt-mode=ignore`), or a cost vector (`--opt-mode=enum,…`, every model whose cost is lexicographically at most it). A positive `:models` caps an `:all-optima` enumeration, and `:project?` adds `--project`, one model per distinct projection.
(optimal-only? opts)Do solve options opts count optimal models only, as mode-flags reads :among?
Do solve options `opts` count optimal models only, as `mode-flags` reads `:among`?
(search-args)(search-args {:keys [opt-strategy solve-limit]})The flags under which a solve's search is a function of its program alone: one
thread, clasp's own default seed (1) stated rather than assumed, the optimization
strategy, and --solve-limit=N for a positive solve limit. The strategy and the limit
are solve options opts' :opt-strategy (clasp's spelling) and :solve-limit, else
config/asp-opt-strategy and config/asp-solve-limit. The limit counts
conflicts, so it stops a search at the same point on any machine, where
--time-limit stops it wherever the machine has got to. In-process clingo's control
takes the same flags (vaelii.impl.asp.clingo).
The flags under which a solve's search is a function of its program alone: one thread, clasp's own default seed (1) stated rather than assumed, the optimization strategy, and `--solve-limit=N` for a positive solve limit. The strategy and the limit are solve options `opts`' `:opt-strategy` (clasp's spelling) and `:solve-limit`, else `config/asp-opt-strategy` and `config/asp-solve-limit`. The limit counts conflicts, so it stops a search at the same point on any machine, where `--time-limit` stops it wherever the machine has got to. In-process clingo's control takes the same flags (`vaelii.impl.asp.clingo`).
(solve aspif-text mode)(solve aspif-text mode opts)Run clasp on aspif-text in mode under solve options opts (mode-flags,
search-args, time-limit). Modes: :label one minimum-cost witness, :sat the
first witness, :all-optima every minimum-cost witness (every witness :among admits),
and :classify-true / :classify-supportable the atoms in every / some such witness.
Returns:
:status — :optimum | :sat | :best-effort | :unsat | :interrupted | :unknown
:atoms — vector of atom-name strings
:cost — optimum cost, :costs its vector by level, highest first (nil if none)
:witnesses — vector of value vectors, :witness-costs their costs (:all-optima)
:raw — full parsed JSON (for diagnostics)
A :label solve runs under :sat's flags for a program with no objective, and for
opts admitting non-optimal models (optimal-only?).
:interrupted is a search the solve limit, the time limit or a signal stopped; a
stopped :label or :sat solve holding a witness is :best-effort instead.
Run clasp on `aspif-text` in `mode` under solve options `opts` (`mode-flags`, `search-args`, `time-limit`). Modes: `:label` one minimum-cost witness, `:sat` the first witness, `:all-optima` every minimum-cost witness (every witness `:among` admits), and `:classify-true` / `:classify-supportable` the atoms in every / some such witness. Returns: :status — :optimum | :sat | :best-effort | :unsat | :interrupted | :unknown :atoms — vector of atom-name strings :cost — optimum cost, `:costs` its vector by level, highest first (nil if none) :witnesses — vector of value vectors, `:witness-costs` their costs (`:all-optima`) :raw — full parsed JSON (for diagnostics) A `:label` solve runs under `:sat`'s flags for a program with no objective, and for `opts` admitting non-optimal models (`optimal-only?`). `:interrupted` is a search the solve limit, the time limit or a signal stopped; a stopped `:label` or `:sat` solve holding a witness is `:best-effort` instead.
(solve-seconds opts)The seconds one solve under opts may run: :time-limit, else config/asp-time-limit.
The seconds one solve under `opts` may run: `:time-limit`, else `config/asp-time-limit`.
(without-optimum result opts)result of a solve under opts, which claims no optimum when opts admit non-optimal
models (optimal-only?): its :optimum status reads :sat and its :cost and :costs
are nil. Under :among :all each :witness-costs entry is nil too: clasp reports no
cost when it ignores the objective.
`result` of a solve under `opts`, which claims no optimum when `opts` admit non-optimal models (`optimal-only?`): its `:optimum` status reads `:sat` and its `:cost` and `:costs` are nil. Under `:among :all` each `:witness-costs` entry is nil too: clasp reports no cost when it ignores the objective.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |