satzilla 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. satzilla-0.0.1.dist-info/METADATA +99 -0
  2. satzilla-0.0.1.dist-info/RECORD +39 -0
  3. satzilla-0.0.1.dist-info/WHEEL +5 -0
  4. satzilla-0.0.1.dist-info/top_level.txt +1 -0
  5. satzilla_features/__init__.py +15 -0
  6. satzilla_features/api.py +315 -0
  7. satzilla_features/liblpk5.so +0 -0
  8. satzilla_features/libsatzilla_features.so +0 -0
  9. satzilla_features/py.typed +1 -0
  10. satzilla_features/satzilla_Solvers/best[mean+cv],firstlmstep[mean+median+cv+q10+q90],bestavgimpr[mean+cv],firstlmratio[mean+cv],estacl +18 -0
  11. satzilla_features/satzilla_Solvers/cadical2023 +0 -0
  12. satzilla_features/satzilla_Solvers/kissatexe +0 -0
  13. satzilla_features/satzilla_Solvers/oo +17 -0
  14. satzilla_features/satzilla_Solvers/out +17 -0
  15. satzilla_features/satzilla_Solvers/satelite +0 -0
  16. satzilla_features/satzilla_Solvers/sbva +0 -0
  17. satzilla_features/satzilla_Solvers/sol +47 -0
  18. satzilla_features/satzilla_Solvers/ubcsat2006 +0 -0
  19. satzilla_features/satzilla_Solvers/ubcsatold +0 -0
  20. satzilla_features/satzilla_Solvers/yalsat-03v/FILES +14 -0
  21. satzilla_features/satzilla_Solvers/yalsat-03v/LICENSE +19 -0
  22. satzilla_features/satzilla_Solvers/yalsat-03v/README +12 -0
  23. satzilla_features/satzilla_Solvers/yalsat-03v/VERSION +1 -0
  24. satzilla_features/satzilla_Solvers/yalsat-03v/cflags.h +2 -0
  25. satzilla_features/satzilla_Solvers/yalsat-03v/config.c +25 -0
  26. satzilla_features/satzilla_Solvers/yalsat-03v/config.h +8 -0
  27. satzilla_features/satzilla_Solvers/yalsat-03v/configure.sh +61 -0
  28. satzilla_features/satzilla_Solvers/yalsat-03v/main.c +840 -0
  29. satzilla_features/satzilla_Solvers/yalsat-03v/makefile +28 -0
  30. satzilla_features/satzilla_Solvers/yalsat-03v/makefile.in +28 -0
  31. satzilla_features/satzilla_Solvers/yalsat-03v/mkconfig.sh +20 -0
  32. satzilla_features/satzilla_Solvers/yalsat-03v/palsat +0 -0
  33. satzilla_features/satzilla_Solvers/yalsat-03v/yals.c +4047 -0
  34. satzilla_features/satzilla_Solvers/yalsat-03v/yals.h +76 -0
  35. satzilla_features/satzilla_Solvers/yalsat-03v/yalsat +0 -0
  36. satzilla_features/satzilla_Solvers/yalsat-03v/yils.h +54 -0
  37. satzilla_features/satzilla_Solvers/yalsat-03v.zip +0 -0
  38. satzilla_features/satzilla_Solvers/zchaff07 +0 -0
  39. satzilla_features/satzilla_Solvers/zchaff_rand +0 -0
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: satzilla
3
+ Version: 0.0.1
4
+ Summary: Python wrapper for the Revisiting SATZilla 2024 feature extractor
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ Provides-Extra: pysat
8
+ Requires-Dist: python-sat; extra == "pysat"
9
+
10
+
11
+ # Revisiting SATZilla in 2024
12
+
13
+
14
+ Code for the paper: "Revisiting SATZilla Features in 2024" by Hadar Shavit and Holger H. Hoos accepted to SAT 2024.
15
+
16
+ ## Abstract
17
+ Boolean satisfiability (SAT) is an $\mathcal{NP}$-complete problem with important applications, notably in hardware and software verification.
18
+ Characterising a SAT instance by a set of features has shown great potential for various tasks, ranging from algorithm selection to benchmark generation.
19
+ In this work, we revisit the widely used SATZilla features and introduce a new version of the tool used to compute them.
20
+ In particular, we utilise a new preprocessor and SAT solvers, adjust the code to accommodate larger formulas, and determine better settings of the feature extraction time limits.
21
+ We evaluate the extracted features on three downstream tasks: satisfiability prediction, running time prediction, and algorithm selection.
22
+ We observe that our new tool is able to extract features from a broader range of instances than before.
23
+ We show that the new version of the feature extractor produces features that achieve up to $25\%$ lower RMSE for running time prediction, up to $5\%$ higher accuracy for satisfiability prediction, and up to $80\%$ higher closed gap for algorithm selection on benchmarks from recent SAT competitions.
24
+
25
+
26
+ ## Usage
27
+ We provide precompiled binaries for the SATZilla feature extraction tool for linux. Currently the SATZilla features extractor supports only linux.
28
+
29
+ SAT-feature-computation code contains the new SATZilla feature extraction tool.
30
+
31
+ Recompile by running `make`, then the executable `features` will be created.
32
+
33
+ To run a package-level smoke test for the extractor, use `make test` inside `SAT-features-competition2024`.
34
+
35
+ To compute features, simply run `./features [--timeout SECONDS] [--group-timeout SECONDS] [--preprocess-timeout SECONDS] [-base] [-structure] [-ncnf-graphs] [-ncnf-constraints] [-ncnf-rwh] [-dia] [-ls] [-lp] [-lobjois] INFILE OUTFILE`
36
+ Where -lp, -dia etc are the feature groups:
37
+
38
+ - base: Base feature group, including pre, KLB, and clause graph
39
+ - structure: Structural features from SATfeatPy
40
+ - ncnf-graphs: New-CNF graph features
41
+ - ncnf-constraints: New-CNF constraint features
42
+ - ncnf-rwh: New-CNF recursive weight heuristic features
43
+ - dia: Diameter
44
+ - ls: Local search (both GSAT and Sparrow)
45
+ - lp: Linear programming
46
+ - lobjois: Lobjois
47
+ - cl: Clause learning
48
+ - unit: Unit propagation
49
+ - sp: Survey propagation
50
+
51
+ To compute all features use the -all option.
52
+ The input INFILE is a DIMACS CNF file. NOTE: currently, only raw CNF files are supported, and not compressed one (like .cnf.xz)
53
+ The output is a CSV file containing the features for one instance.
54
+
55
+ Timeout controls:
56
+ - `--timeout`: total extraction timeout
57
+ - `--group-timeout`: per-feature-group timeout override; timed-out groups emit reserved values and extraction continues with the next selected group
58
+ - `--preprocess-timeout`: timeout override for the preprocessing step
59
+
60
+ ## Python Interface
61
+ Install from PyPI:
62
+
63
+ ```bash
64
+ pip install satzilla
65
+ ```
66
+
67
+ An importable Python interface is available in the `satzilla_features` package. It accepts PySAT `CNF` formulas directly and
68
+ calls the extractor through a bundled shared library using `ctypes`; it does not shell out to the CLI.
69
+
70
+ PySAT documents that `pysat.formula.CNF` exposes `clauses` and `nv`, and supports DIMACS I/O:
71
+ https://pysathq.github.io/docs/html/api/formula.html
72
+
73
+ Example:
74
+
75
+ ```python
76
+ from pysat.formula import CNF
77
+ from satzilla_features import extract_features
78
+
79
+ cnf = CNF(from_clauses=[[-1, 2], [-2, 3], [1, 3]])
80
+ features = extract_features(
81
+ cnf,
82
+ groups=["base", "structure", "ncnf-graphs"],
83
+ group_timeout=180,
84
+ )
85
+ print(features["variable_alpha"])
86
+ ```
87
+
88
+ You can also extract directly from a CNF file path with `extract_features_from_path(...)`.
89
+ Both Python entry points accept `timeout=...`, `group_timeout=...`, and `preprocess_timeout=...`.
90
+
91
+ When building the Python package, the C/C++ extractor is compiled into `libsatzilla_features.so` and packaged together with the
92
+ solver binaries it needs at runtime. The direct Python interface is currently Linux-only.
93
+
94
+
95
+ ## Experiments
96
+ rt_pred.py contains the code for running time prediction. sat_pred.py contains the code for satisfiability prediction. Both are using submitit for execution on a SLURM cluster.
97
+ For algorithm selection, the scenarios are available in the aslib directory. The AutoFolio code is available at https://github.com/hadarshavit/AutoFolio.
98
+ ## Contact
99
+ To contact us, please send an email to [shavit@aim.rwth-aachen.de](mailto:shavit@aim.rwth-aachen.de)
@@ -0,0 +1,39 @@
1
+ satzilla_features/__init__.py,sha256=Xa1580axPuw-I_q7zzFuZ4lb8BBwaoOKhyF-yn01Ti0,282
2
+ satzilla_features/api.py,sha256=uNMNZPEBX2PU7cVotW85lBJ9RQiBqE-80nPm6wA5HFg,9306
3
+ satzilla_features/liblpk5.so,sha256=V5qjAP_9qRikNbcTyxpRQLsBv82qupQ0xW5TSLCKxc0,1480072
4
+ satzilla_features/libsatzilla_features.so,sha256=fpVljd1mQ18MVjWUpkedMSp7lHEXIqDfubve2pvzCPU,2919080
5
+ satzilla_features/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
+ "satzilla_features/satzilla_Solvers/best[mean+cv],firstlmstep[mean+median+cv+q10+q90],bestavgimpr[mean+cv],firstlmratio[mean+cv],estacl",sha256=nGuNoGc5pt6tiUyj0z6-NX-AmD1NDU35i9rE1ic3i-M,313
7
+ satzilla_features/satzilla_Solvers/cadical2023,sha256=RX2gIx4RRTAMwsOm7-hyoCqnbx-Sh7sAsKESpFCVTBQ,1049976
8
+ satzilla_features/satzilla_Solvers/kissatexe,sha256=Q6doDsp3l9USOvTCd_DHjrVOgeK9IATRbdFCvsgwCWA,375384
9
+ satzilla_features/satzilla_Solvers/oo,sha256=cAeN1OZzf9k33AVT32hvawA2tlmEZe99-GZBuVz9NHI,412
10
+ satzilla_features/satzilla_Solvers/out,sha256=pkDEYH-3HjguD_HcB3v8XIiL3ESkGySg5L8ZC4coqy4,487
11
+ satzilla_features/satzilla_Solvers/satelite,sha256=OSWB1xB1h6act5XwV33GMBWJmf8fkKNzfkfUfd4yuO0,598625
12
+ satzilla_features/satzilla_Solvers/sbva,sha256=YkbdMdmi-SDBtoQeJ6GACMpzXwjPkJoVJ7jnNHkwttk,76736
13
+ satzilla_features/satzilla_Solvers/sol,sha256=yea9sjc-dqyQizdCmE8jxIGbNzJC3YxcOH-J0_i9W-c,942
14
+ satzilla_features/satzilla_Solvers/ubcsat2006,sha256=xS-FRWGyG6p5U-j91VbkRol9xdWMVD-Ix1yYSTZv4zI,505432
15
+ satzilla_features/satzilla_Solvers/ubcsatold,sha256=RWjPLb2OFxSTu4-JLiZOFxrekmifXxrlAIOVV33Nei0,300691
16
+ satzilla_features/satzilla_Solvers/yalsat-03v.zip,sha256=WWrZ63Kd39Z8Ilatsg_41NnXAYAE2Dj2tORJuLW-Qmo,33679
17
+ satzilla_features/satzilla_Solvers/zchaff07,sha256=6gVBR0gZ_VU_612QFL0xlh6kMT1aDsVSZsAFBXMCMVk,2056894
18
+ satzilla_features/satzilla_Solvers/zchaff_rand,sha256=aB3o0UcZP-qhU35i4UpHNhYky3gTCXqgqxRRKuruhjk,3341970
19
+ satzilla_features/satzilla_Solvers/yalsat-03v/FILES,sha256=9e4Pzm9BijPbbrDj1X3IzxltN5CVbtZ6YLN49V0BRA4,703
20
+ satzilla_features/satzilla_Solvers/yalsat-03v/LICENSE,sha256=Wu3iswNOpb5qA_hyw0pcVmozy8USy3wbBNdheT-vtUs,1090
21
+ satzilla_features/satzilla_Solvers/yalsat-03v/README,sha256=_gUo9eQ8SHupuYEk05racU-KTgM8dp12TpdIgUxVrzk,356
22
+ satzilla_features/satzilla_Solvers/yalsat-03v/VERSION,sha256=TRS5JySS2dhPbgVwaipCl6BZ6d8g2Fa21UcHIFKszyQ,4
23
+ satzilla_features/satzilla_Solvers/yalsat-03v/cflags.h,sha256=IdtxN2cPnGIkWKeGIknhSVi5AvcmktyM0pQcGi_VTCU,76
24
+ satzilla_features/satzilla_Solvers/yalsat-03v/config.c,sha256=xPCfAYPp-hefVUNJSM-Ov3FlyQDEj03yTcnBYNa90HU,754
25
+ satzilla_features/satzilla_Solvers/yalsat-03v/config.h,sha256=02STwvv6kFEJZDFc4dTqhVV_PHT09kscIN8pJVynn3Y,464
26
+ satzilla_features/satzilla_Solvers/yalsat-03v/configure.sh,sha256=ze3D7T4I4sMPgKBfhogOK_dOAPQaqAeSEY1hFZnIpzE,1228
27
+ satzilla_features/satzilla_Solvers/yalsat-03v/main.c,sha256=dLM7dEPKFFrtAJcKpxpD6dFJtxGbv3qw_SqiUawqmkQ,22977
28
+ satzilla_features/satzilla_Solvers/yalsat-03v/makefile,sha256=Qy91rAi1Os3KQZLNsy6oxnm3e-z_D06a2zeKWiW7eWk,929
29
+ satzilla_features/satzilla_Solvers/yalsat-03v/makefile.in,sha256=biQxUBT1KqiwOer3UaguE5LL1Uhp1nkScgQlWQ9q6WI,923
30
+ satzilla_features/satzilla_Solvers/yalsat-03v/mkconfig.sh,sha256=E1SzKMUUBec707fNwJRxDTGJSgYOFJCEIaepmNxvts8,571
31
+ satzilla_features/satzilla_Solvers/yalsat-03v/palsat,sha256=AZgJznjrnaeV4djAvQ496HPxQY5uuUKT0ZPbVnhqYdM,113144
32
+ satzilla_features/satzilla_Solvers/yalsat-03v/yals.c,sha256=AIAkKKKMScSyanv7HOI7xluVcTRNzT96f8zqiA-aDoE,104236
33
+ satzilla_features/satzilla_Solvers/yalsat-03v/yals.h,sha256=fCn_oDP_A8yu7C1F6nGg3jmF8qLg7A1m8MAap-cW8iE,2289
34
+ satzilla_features/satzilla_Solvers/yalsat-03v/yalsat,sha256=g9rcj5fPvE49LZ2V_ha3yePad9CHA9ejbKOhbLLPBnA,99928
35
+ satzilla_features/satzilla_Solvers/yalsat-03v/yils.h,sha256=9X8d5L3CoKM84abB7edgTJhLeNUt5dxZDmma3wPmFGU,1681
36
+ satzilla-0.0.1.dist-info/METADATA,sha256=MvYPbSquzPuTuFK0fB2M7_9p7grKBZ9Fwv6RcAC6OCU,4860
37
+ satzilla-0.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
38
+ satzilla-0.0.1.dist-info/top_level.txt,sha256=btiM7kEXFZEzdVsfMt4LxylSzVNaxtXs4SIYKq0bScs,18
39
+ satzilla-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ satzilla_features
@@ -0,0 +1,15 @@
1
+ from .api import (
2
+ ALL_GROUPS,
3
+ DEFAULT_GROUPS,
4
+ FeatureExtractionError,
5
+ extract_features,
6
+ extract_features_from_path,
7
+ )
8
+
9
+ __all__ = [
10
+ "ALL_GROUPS",
11
+ "DEFAULT_GROUPS",
12
+ "FeatureExtractionError",
13
+ "extract_features",
14
+ "extract_features_from_path",
15
+ ]
@@ -0,0 +1,315 @@
1
+ from __future__ import annotations
2
+
3
+ import ctypes
4
+ import subprocess
5
+ from pathlib import Path
6
+ from typing import Iterable, Mapping, Sequence
7
+
8
+
9
+ _PACKAGE_DIR = Path(__file__).resolve().parent
10
+ _REPO_ROOT = _PACKAGE_DIR.parent
11
+ _FEATURES_DIR = _REPO_ROOT / "SAT-features-competition2024"
12
+ _SOURCE_SHARED_LIBRARY = _FEATURES_DIR / "libsatzilla_features.so"
13
+ _PACKAGE_SHARED_LIBRARY = _PACKAGE_DIR / "libsatzilla_features.so"
14
+
15
+ ALL_GROUPS = (
16
+ "all",
17
+ "base",
18
+ "structure",
19
+ "ncnf-graphs",
20
+ "ncnf-constraints",
21
+ "ncnf-rwh",
22
+ "sp",
23
+ "dia",
24
+ "cl",
25
+ "lp",
26
+ "unit",
27
+ "ls",
28
+ "lobjois",
29
+ )
30
+
31
+ DEFAULT_GROUPS: tuple[str, ...] = ()
32
+
33
+
34
+ class FeatureExtractionError(RuntimeError):
35
+ pass
36
+
37
+
38
+ class _COptions(ctypes.Structure):
39
+ _fields_ = [
40
+ ("do_base", ctypes.c_int),
41
+ ("do_structure", ctypes.c_int),
42
+ ("do_ncnf_graphs", ctypes.c_int),
43
+ ("do_ncnf_constraints", ctypes.c_int),
44
+ ("do_ncnf_rwh", ctypes.c_int),
45
+ ("do_unit_probe", ctypes.c_int),
46
+ ("do_ls_probe", ctypes.c_int),
47
+ ("do_cl", ctypes.c_int),
48
+ ("do_dia", ctypes.c_int),
49
+ ("do_sp", ctypes.c_int),
50
+ ("do_lobjois", ctypes.c_int),
51
+ ("do_lp", ctypes.c_int),
52
+ ("timeout_seconds", ctypes.c_int),
53
+ ("group_timeout_seconds", ctypes.c_int),
54
+ ("preprocess_timeout_seconds", ctypes.c_int),
55
+ ("solver_root", ctypes.c_char_p),
56
+ ]
57
+
58
+
59
+ class _CResult(ctypes.Structure):
60
+ _fields_ = [
61
+ ("status_code", ctypes.c_int),
62
+ ("feature_count", ctypes.c_size_t),
63
+ ("feature_names", ctypes.POINTER(ctypes.c_char_p)),
64
+ ("feature_values", ctypes.POINTER(ctypes.c_double)),
65
+ ("error_message", ctypes.c_char_p),
66
+ ]
67
+
68
+
69
+ _GROUP_ATTRS = {
70
+ "base": "do_base",
71
+ "structure": "do_structure",
72
+ "ncnf-graphs": "do_ncnf_graphs",
73
+ "ncnf-constraints": "do_ncnf_constraints",
74
+ "ncnf-rwh": "do_ncnf_rwh",
75
+ "unit": "do_unit_probe",
76
+ "ls": "do_ls_probe",
77
+ "cl": "do_cl",
78
+ "dia": "do_dia",
79
+ "sp": "do_sp",
80
+ "lobjois": "do_lobjois",
81
+ "lp": "do_lp",
82
+ }
83
+
84
+ _LIB = None
85
+
86
+
87
+ def _normalize_groups(groups: Iterable[str] | None) -> list[str]:
88
+ if groups is None:
89
+ return []
90
+
91
+ normalized = []
92
+ for group in groups:
93
+ key = group.strip().lower()
94
+ if key not in ALL_GROUPS:
95
+ raise ValueError(
96
+ f"unknown feature group {group!r}; expected one of {', '.join(ALL_GROUPS)}"
97
+ )
98
+ normalized.append(key)
99
+ return normalized
100
+
101
+
102
+ def _candidate_library_paths() -> list[Path]:
103
+ return [_PACKAGE_SHARED_LIBRARY, _SOURCE_SHARED_LIBRARY]
104
+
105
+
106
+ def _find_default_solver_root(lib_path: Path) -> Path:
107
+ package_candidate = lib_path.parent
108
+ if (package_candidate / "satzilla_Solvers").exists():
109
+ return package_candidate
110
+ return _FEATURES_DIR
111
+
112
+
113
+ def _ensure_shared_library(build_if_missing: bool) -> Path:
114
+ for candidate in _candidate_library_paths():
115
+ if candidate.exists():
116
+ return candidate
117
+
118
+ if not build_if_missing:
119
+ raise FileNotFoundError(
120
+ "shared feature extractor library not found. "
121
+ "Build it with `make shared` in SAT-features-competition2024."
122
+ )
123
+
124
+ completed = subprocess.run(
125
+ ["make", "shared"],
126
+ cwd=_FEATURES_DIR,
127
+ text=True,
128
+ capture_output=True,
129
+ check=False,
130
+ )
131
+ if completed.returncode != 0:
132
+ raise FeatureExtractionError(
133
+ "failed to build shared feature extractor with `make shared`\n"
134
+ f"stdout:\n{completed.stdout}\n"
135
+ f"stderr:\n{completed.stderr}"
136
+ )
137
+
138
+ for candidate in _candidate_library_paths():
139
+ if candidate.exists():
140
+ return candidate
141
+
142
+ raise FileNotFoundError("`make shared` completed but no shared library was found")
143
+
144
+
145
+ def _load_library(build_if_missing: bool):
146
+ global _LIB
147
+ if _LIB is not None:
148
+ return _LIB
149
+
150
+ library_path = _ensure_shared_library(build_if_missing)
151
+ lib = ctypes.CDLL(str(library_path))
152
+ lib.satzilla_extract_from_dimacs_path.argtypes = [
153
+ ctypes.c_char_p,
154
+ ctypes.POINTER(_COptions),
155
+ ctypes.POINTER(_CResult),
156
+ ]
157
+ lib.satzilla_extract_from_dimacs_path.restype = ctypes.c_int
158
+ lib.satzilla_extract_from_clauses.argtypes = [
159
+ ctypes.c_int,
160
+ ctypes.c_size_t,
161
+ ctypes.POINTER(ctypes.c_int),
162
+ ctypes.POINTER(ctypes.c_size_t),
163
+ ctypes.POINTER(_COptions),
164
+ ctypes.POINTER(_CResult),
165
+ ]
166
+ lib.satzilla_extract_from_clauses.restype = ctypes.c_int
167
+ lib.satzilla_free_result.argtypes = [ctypes.POINTER(_CResult)]
168
+ lib.satzilla_free_result.restype = None
169
+ _LIB = lib
170
+ return lib
171
+
172
+
173
+ def _extract_cnf_data(cnf: object) -> tuple[Sequence[Sequence[int]], int]:
174
+ clauses = getattr(cnf, "clauses", None)
175
+ nv = getattr(cnf, "nv", None)
176
+ if clauses is None or nv is None:
177
+ raise TypeError(
178
+ "expected a PySAT CNF-like object exposing `clauses` and `nv`"
179
+ )
180
+ return clauses, int(nv)
181
+
182
+
183
+ def _build_options(
184
+ groups: Sequence[str],
185
+ timeout: int | None,
186
+ group_timeout: int | None,
187
+ preprocess_timeout: int | None,
188
+ solver_root: str | Path | None,
189
+ build_if_missing: bool,
190
+ ) -> _COptions:
191
+ lib_path = _ensure_shared_library(build_if_missing)
192
+ resolved_solver_root = (
193
+ Path(solver_root) if solver_root is not None else _find_default_solver_root(lib_path)
194
+ )
195
+
196
+ options = _COptions()
197
+ for group in groups:
198
+ if group == "all":
199
+ for attr in _GROUP_ATTRS.values():
200
+ setattr(options, attr, 1)
201
+ else:
202
+ setattr(options, _GROUP_ATTRS[group], 1)
203
+
204
+ options.timeout_seconds = -1 if timeout is None else int(timeout)
205
+ options.group_timeout_seconds = -1 if group_timeout is None else int(group_timeout)
206
+ options.preprocess_timeout_seconds = -1 if preprocess_timeout is None else int(preprocess_timeout)
207
+ options.solver_root = str(resolved_solver_root).encode("utf-8")
208
+ return options
209
+
210
+
211
+ def _decode_result(result: _CResult) -> Mapping[str, float]:
212
+ features: dict[str, float] = {}
213
+ for idx in range(result.feature_count):
214
+ name = result.feature_names[idx].decode("utf-8")
215
+ features[name] = result.feature_values[idx]
216
+ return features
217
+
218
+
219
+ def _raise_if_failed(status: int, result: _CResult) -> None:
220
+ if status == 0 and result.status_code == 0:
221
+ return
222
+
223
+ if result.error_message:
224
+ message = ctypes.cast(result.error_message, ctypes.c_char_p).value.decode("utf-8")
225
+ else:
226
+ message = f"feature extraction failed with status {status or result.status_code}"
227
+ raise FeatureExtractionError(message)
228
+
229
+
230
+ def extract_features(
231
+ cnf: object,
232
+ *,
233
+ groups: Iterable[str] | None = None,
234
+ timeout: int | None = None,
235
+ group_timeout: int | None = None,
236
+ preprocess_timeout: int | None = None,
237
+ solver_root: str | Path | None = None,
238
+ build_if_missing: bool = True,
239
+ ) -> Mapping[str, float]:
240
+ """
241
+ Extract SAT features for a PySAT CNF-like object.
242
+
243
+ PySAT documents `CNF` formulas in the `formula` module and exposes CNF data
244
+ through the formula object interface used here (`clauses` and `nv`).
245
+ Source: https://pysathq.github.io/docs/html/api/formula.html
246
+ """
247
+
248
+ clauses, nv = _extract_cnf_data(cnf)
249
+ normalized_groups = _normalize_groups(groups)
250
+ options = _build_options(
251
+ normalized_groups,
252
+ timeout,
253
+ group_timeout,
254
+ preprocess_timeout,
255
+ solver_root,
256
+ build_if_missing,
257
+ )
258
+ lib = _load_library(build_if_missing)
259
+
260
+ flat_literals: list[int] = []
261
+ clause_offsets = [0]
262
+ for clause in clauses:
263
+ flat_literals.extend(int(lit) for lit in clause)
264
+ clause_offsets.append(len(flat_literals))
265
+
266
+ literal_array = (ctypes.c_int * len(flat_literals))(*flat_literals) if flat_literals else None
267
+ offset_array = (ctypes.c_size_t * len(clause_offsets))(*clause_offsets)
268
+ result = _CResult()
269
+ try:
270
+ status = lib.satzilla_extract_from_clauses(
271
+ int(nv),
272
+ len(clauses),
273
+ literal_array,
274
+ offset_array,
275
+ ctypes.byref(options),
276
+ ctypes.byref(result),
277
+ )
278
+ _raise_if_failed(status, result)
279
+ return _decode_result(result)
280
+ finally:
281
+ lib.satzilla_free_result(ctypes.byref(result))
282
+
283
+
284
+ def extract_features_from_path(
285
+ cnf_path: str | Path,
286
+ *,
287
+ groups: Iterable[str] | None = None,
288
+ timeout: int | None = None,
289
+ group_timeout: int | None = None,
290
+ preprocess_timeout: int | None = None,
291
+ solver_root: str | Path | None = None,
292
+ build_if_missing: bool = True,
293
+ ) -> Mapping[str, float]:
294
+ normalized_groups = _normalize_groups(groups)
295
+ options = _build_options(
296
+ normalized_groups,
297
+ timeout,
298
+ group_timeout,
299
+ preprocess_timeout,
300
+ solver_root,
301
+ build_if_missing,
302
+ )
303
+ lib = _load_library(build_if_missing)
304
+
305
+ result = _CResult()
306
+ try:
307
+ status = lib.satzilla_extract_from_dimacs_path(
308
+ str(cnf_path).encode("utf-8"),
309
+ ctypes.byref(options),
310
+ ctypes.byref(result),
311
+ )
312
+ _raise_if_failed(status, result)
313
+ return _decode_result(result)
314
+ finally:
315
+ lib.satzilla_free_result(ctypes.byref(result))
Binary file
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,18 @@
1
+
2
+
3
+ Variables = 100
4
+ Clauses = 429
5
+ TotalLiterals = 1287
6
+ TotalCPUTimeElapsed = 0.000
7
+ FlipsPerSecond = inf
8
+ RunsExecuted = 10
9
+ SuccessfulRuns = 10
10
+ PercentSuccess = 100.00
11
+ Steps_Mean = 2874.6
12
+ Steps_CoeffVariance = 0.93334263389
13
+ Steps_Median = 1624
14
+ CPUTime_Mean = 0
15
+ CPUTime_CoeffVariance = 0
16
+ CPUTime_Median = 0
17
+
18
+
@@ -0,0 +1,17 @@
1
+
2
+
3
+ BestSolution_Mean = 0
4
+ BestSolution_CoeffVariance = 0
5
+ BestSolution_Min = 0
6
+ FirstLocalMinStep_Mean = 23
7
+ FirstLocalMinStep_CoeffVariance = 0
8
+ FirstLocalMinStep_Median = 23
9
+ FirstLocalMinStep_Q.10 = 23
10
+ FirstLocalMinStep_Q.90 = 23
11
+ BestAvgImprovement_Mean = 0.830985915493
12
+ BestAvgImprovement_CoeffVariance = 0
13
+ FirstLocalMinRatio_Mean = 0.881355932203
14
+ FirstLocalMinRatio_CoeffVariance = 0
15
+ EstACL_Mean = 828.382370599
16
+
17
+
@@ -0,0 +1,17 @@
1
+
2
+
3
+ BestSolution_Mean = 2151.5
4
+ BestSolution_CoeffVariance = 0.0667135308541
5
+ FirstLocalMinStep_Mean = 19123.7
6
+ FirstLocalMinStep_CoeffVariance = 0.00537800205029
7
+ FirstLocalMinStep_Median = 19159.5
8
+ FirstLocalMinStep_Q.10 = 18871
9
+ FirstLocalMinStep_Q.90 = 19201
10
+ BestAvgImprovement_Mean = 0.63046249781
11
+ BestAvgImprovement_CoeffVariance = 0.168727935973
12
+ FirstLocalMinRatio_Mean = 0.892689448924
13
+ FirstLocalMinRatio_CoeffVariance = 0.00309376829386
14
+ EstACL_Mean = 228138913.529
15
+ SuccessfulRuns = 0
16
+
17
+
Binary file
@@ -0,0 +1,47 @@
1
+ c
2
+ c UBCSAT version 1.2-b18 BETA -- avoid using for published results
3
+ c
4
+ c http://ubcsat.dtompkins.com
5
+ c
6
+ c ubcsat -h for help
7
+ c
8
+ c -runs 10
9
+ c -cutoff 200
10
+ c -timeout 0
11
+ c -gtimeout 0
12
+ c -abstime 0
13
+ c -systime 0
14
+ c -timeres 1000
15
+ c -noimprove 0
16
+ c -earlysteps 0
17
+ c -earlyqual 0
18
+ c -earlywqual 0
19
+ c -strikes 0
20
+ c -target 0
21
+ c -wtarget 0
22
+ c -seed 466967371
23
+ c -solve 1
24
+ c -find,-numsol 1
25
+ c -findunique 0
26
+ c -srestart 0
27
+ c -prestart 0
28
+ c -drestart 0
29
+ c
30
+ c -alpha 1.3
31
+ c -rho 0.8
32
+ c -ps 0.05
33
+ c -wp 0.01
34
+ c -sapsthresh -0.1
35
+ c
36
+ s SATISFIABLE
37
+ v -1 2 3 4 5 6 -7 8 9 -10
38
+ v 11 -12 -13 -14 -15 16 -17 -18 19 -20
39
+ v -21 22 -23 -24 25 26 27 -28 -29 30
40
+ v 31 -32 33 -34 -35 -36 37 38 39 -40
41
+ v -41 -42 43 44 45 -46 47 48 49 -50
42
+ v 51 52 53 -54 55 -56 -57 -58 -59 -60
43
+ v -61 -62 63 64 -65 -66 -67 68 69 -70
44
+ v -71 -72 -73 -74 -75 76 -77 -78 79 -80
45
+ v 81 82 -83 84 -85 86 -87 -88 -89 90
46
+ v -91 92 93 94 95 -96 97 98 -99 100
47
+ v 0
@@ -0,0 +1,14 @@
1
+ yalsat executable SAT solver
2
+ palsat executable SAT solver simple portfolio version
3
+ main.c front-end, e.g. dimacs parser, connects to library
4
+ libyals.a actual library
5
+ yals.h library include file
6
+ yals.c library implementation
7
+ yils.h internal API calls
8
+ config.c prints banner (includes configuration)
9
+ config.h automatically generated from './mkconfig.sh'
10
+ makefile instantiated from 'makfile.in' by './configure.sh'
11
+ configure.sh configure script (try './configure -h')
12
+ mkconfig.sh prints version and compile time information
13
+ getgidid.sh determine current 'git id' (or of release)
14
+ makefile.in makefile template
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013-2019, Armin Biere, Johannes Kepler University.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ YalSAT
2
+
3
+ This is yet another local search SAT solver.
4
+
5
+ To build run './configure.sh && make'. See also './configure.sh -h',
6
+ particularly the usage of './configure.sh -g' to compile a version
7
+ with debugging, checking and logging support.
8
+
9
+ This will build both the library 'libyals.a' with its API in file 'yals.h'
10
+ and the stand-alone SAT solver 'yalsat'.
11
+
12
+
@@ -0,0 +1,2 @@
1
+ #define YALS_CC "gcc (GCC) 12.3.0"
2
+ #define YALS_CFLAGS "-Wall -DNDEBUG -O3"