Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integer-based interface supporting SCM work #53

Draft
wants to merge 248 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
dd93b27
Fix export of Consistency
hbierlee Sep 7, 2023
a8ba646
Make fields of Model struct private
hbierlee Sep 8, 2023
cb4bbd6
Generalize Model/Lin, adding independent BDD decomposition
hbierlee Sep 11, 2023
07cdb42
Add BddEncoder::decompose for model::encode
hbierlee Sep 11, 2023
fa8a47e
Fix Model::propagate
hbierlee Sep 11, 2023
9645f0b
Make ub/lb propagation more consistent
hbierlee Sep 11, 2023
2ea1357
Replace BTreeSet arg for &[C] in IntVar constructor
hbierlee Sep 11, 2023
61dacf9
Add/refactor Model::decompose
hbierlee Sep 11, 2023
ffb8114
Use Comparator i/o LimitComp for Model
hbierlee Sep 11, 2023
8528e2d
Add basic LinExp struct for Lin constraint
hbierlee Sep 11, 2023
810b84c
Implement and handle integer Terms
hbierlee Sep 12, 2023
072456c
Support reading LP/OPB files into Model
hbierlee Sep 12, 2023
f7a2064
Replace LimitComp for Comparator, add Model test suite
hbierlee Sep 14, 2023
db7fe8e
Refactor Display implementations
hbierlee Sep 19, 2023
c5df844
Add write to OPB
hbierlee Sep 19, 2023
490fe37
Support >= for BDD decomposition
hbierlee Sep 19, 2023
8e8d323
Export Format
hbierlee Sep 19, 2023
351e336
Simplify BDD decomposition
hbierlee Sep 19, 2023
58b137c
Fix display and implement Mul for Term
hbierlee Sep 22, 2023
8787f51
Parse (non-official) Doms section for LPs
hbierlee Sep 22, 2023
4fe757a
Generalize Tern encoder to (n-variable) Lin encoder
hbierlee Sep 22, 2023
2f4695d
Merge branch 'develop' into feature/add-int-interface
hbierlee Oct 6, 2023
ad9947a
Construct scm.rs at compile time from archive
hbierlee Oct 7, 2023
1fa2c42
Integrate scm.rs
hbierlee Oct 7, 2023
c0823b3
Support Two's Complement and offset binary encoding
hbierlee Oct 9, 2023
827fda6
Make headway in handling negative constants for SCM
hbierlee Oct 10, 2023
7825e44
Canonicalize test_lp! output / comparisons
hbierlee Oct 10, 2023
c65f83f
Support consistency for domain gaps for IntVarBin
hbierlee Oct 10, 2023
a897bbc
Clippy
hbierlee Oct 10, 2023
5fe4775
Fallback TernLeEncoder to encode ternaries
hbierlee Oct 10, 2023
3f56b2b
First step for supporting negative coefficients for IntVarOrd
hbierlee Oct 10, 2023
ffcfb55
Refactor encoding unary constraints
hbierlee Oct 11, 2023
92f92fc
Remove test_lp macro, simplifying and fixing trace
hbierlee Oct 11, 2023
3db794d
Fix remaining GreaterEq bugs for TernLeEncoder
hbierlee Oct 11, 2023
3a62a02
Integrate SCM optimized for SAT
hbierlee Oct 15, 2023
03f5dc5
Add IntVarId
hbierlee Oct 16, 2023
aa0aa15
Fix BDD regression using tuple_windows to get next IntVarId
hbierlee Oct 17, 2023
e8d3b8a
Fix Binary/Order non-decomposition encoding
hbierlee Oct 18, 2023
842638f
Take start/end of BDD interval based on comp
hbierlee Oct 18, 2023
1f54bec
Add public interface for model creation and checking
hbierlee Oct 19, 2023
95abb25
Add IntVarRef type
hbierlee Oct 19, 2023
bd5be66
Add more descriptive Fail CheckError for inconsistency/unsatisfiable
hbierlee Oct 19, 2023
83f8ff4
Update SCM
hbierlee Oct 19, 2023
32e6b5a
Small clean up
hbierlee Oct 22, 2023
607c519
Add xor/carry functional, conservative circuits
hbierlee Oct 22, 2023
48d7a94
Integrate functional log_enc_add and fix neg. coef bug
hbierlee Oct 23, 2023
09c13e2
Do not retain domain gaps when adding binary encs
hbierlee Oct 23, 2023
cad1f01
Clean up
hbierlee Oct 23, 2023
1565637
Optimize away redundant sign bits
hbierlee Oct 23, 2023
8730b81
Clean up
hbierlee Oct 24, 2023
93bb31b
Remove unnecessary generic from required_lits
hbierlee Oct 24, 2023
a394497
Add power-of-two decomp method for c*(x:B) SCM
hbierlee Oct 25, 2023
5fe4656
Update scm database
hbierlee Oct 25, 2023
20dafc5
Fix missing SCM recipes, and provide fallback method
hbierlee Oct 25, 2023
f4aec35
Convert constants to binary without using hardware bit operations
hbierlee Oct 27, 2023
c9b4542
Avoid always creating an extra adder output var
hbierlee Oct 27, 2023
5cfd2d4
Fix off-by-one in SCM
hbierlee Oct 27, 2023
10f7b44
"Heap" sort final linear (inefficiently)
hbierlee Oct 27, 2023
c688669
Update scm DB
hbierlee Oct 27, 2023
62fdd66
Disable regressed tests
hbierlee Oct 27, 2023
087740e
Add Dnf method + its Ecm database
hbierlee Oct 31, 2023
2455cb8
Add range-set based Dom struct
hbierlee Nov 1, 2023
9a14ec4
Clippy
hbierlee Nov 1, 2023
7baff53
Update ECM/SCM
hbierlee Nov 1, 2023
a09110a
Fix
hbierlee Nov 1, 2023
a85ecaa
Update exact ECM to 12 bits
hbierlee Nov 1, 2023
e81ef32
Add cutoff to ModelConfig
hbierlee Nov 11, 2023
8c1766b
Add cutoff to ModelConfig
hbierlee Nov 11, 2023
77b5daf
Improve display
hbierlee Nov 11, 2023
6a9ab0f
Update
hbierlee Nov 12, 2023
c7bdead
Implement multiplication for order encoding
hbierlee Nov 22, 2023
20af037
Add add_consistency option to ModelConfig
hbierlee Nov 23, 2023
6242846
Support propagate in ModelConfig
hbierlee Nov 23, 2023
96f17da
Fix syntax
hbierlee Nov 23, 2023
d1c8f26
Make cons public for now
hbierlee Nov 23, 2023
6cd77a0
Fix Dom propagation and add invariant
hbierlee Nov 27, 2023
203dba5
Add missing decomposers and propagate all comparators
hbierlee Nov 27, 2023
7148609
Implement (pos/neg) multiplication for ord
hbierlee Nov 29, 2023
d3de886
Check decomposition using brute force
hbierlee Nov 29, 2023
141961a
Fix gt decomp
hbierlee Nov 29, 2023
fd74fe7
Update
hbierlee Dec 2, 2023
dd97354
Update
hbierlee Dec 2, 2023
b981e14
Fix generics for Wcnf
hbierlee Dec 2, 2023
936f17e
Store ub_iv i/o just upper bound
hbierlee Dec 4, 2023
b65fea6
Add cadical as solver
hbierlee Dec 6, 2023
3f2ae25
Fix most unit tests
hbierlee Dec 6, 2023
071fa4f
Fix remaining tests
hbierlee Dec 6, 2023
d28a0b6
Improve TestDB
hbierlee Dec 8, 2023
254ec7d
Fix remaining BDD inconsistency for MBSSP
hbierlee Dec 8, 2023
e3e87f0
Process comparator >=/= for Gt
hbierlee Dec 8, 2023
691b3b0
Fix Scm::Pow
hbierlee Dec 9, 2023
ec3990f
Add constraint checker
hbierlee Dec 9, 2023
e66b06a
Update
hbierlee Dec 9, 2023
b750914
Enable consistency constraints
hbierlee Dec 10, 2023
64ddcc9
Propagate decompostion
hbierlee Dec 10, 2023
c9868dd
Equalize intermediate binary auxs
hbierlee Dec 11, 2023
13da9ea
Refactor and enable general linear encoding for order
hbierlee Jan 30, 2024
d1605f0
Add initial bin.rs
hbierlee Jan 31, 2024
9412e20
Migrate over basic EncBin
hbierlee Feb 1, 2024
b20e917
Implement binary ineq/ineqs methods
hbierlee Feb 7, 2024
4d5b964
Fix encoding order/binary linears for all (principal) encoding specs
hbierlee Feb 9, 2024
da5dcd6
Fix almost all enc specs incl. aux vars
hbierlee Feb 13, 2024
d23e5cb
Fix SWC decomp (but misses prop step like GT)
hbierlee Feb 14, 2024
23509c3
Make var enc testing a little more conservative
hbierlee Feb 14, 2024
49237d9
Add SCM and Adder encodings
hbierlee Feb 22, 2024
0778a75
Fix most issues related to SCM/Dnf encoding step
hbierlee Feb 29, 2024
a533235
Fix remaining issues by grounding binary at LB
hbierlee Feb 29, 2024
b8a4c90
Do not use Gt/Swc/Bdd decomposers for n<=2
hbierlee Feb 29, 2024
64adcd5
Add encoding specifications
hbierlee Mar 1, 2024
1e64296
Avoid encoding SCM vars in tests
hbierlee Mar 4, 2024
a92626c
Refactor SCM/Lin decomposition steps
hbierlee Mar 4, 2024
c57b876
Improve output/logging
hbierlee Mar 5, 2024
8a0f657
Support equalizing ternaries for LinDecomposer
hbierlee Mar 5, 2024
d302db3
Clippy
hbierlee Mar 5, 2024
6917356
Fix CHECK_CONSTRAINTS
hbierlee Mar 7, 2024
dd38e0c
Finalize current testing configs and resolve issues
hbierlee Mar 7, 2024
a453ca0
Cover x's domain bounds with Bin::ineqs
hbierlee Mar 10, 2024
bdc1e26
Refactor unsigned_binary_range
hbierlee Mar 10, 2024
6ae1374
Refactor of collect -> try_collect
hbierlee Mar 10, 2024
b127df0
Refactor Bin::ineqs and fix mismatch of dom value with cnf
hbierlee Mar 10, 2024
ed9deeb
Fix all tests by using BinEnc::ineqs for BinEnc::ineq
hbierlee Mar 10, 2024
7500090
Limit unit test max number of clauses
hbierlee Mar 11, 2024
ec9ab64
Refactor + small fixes
hbierlee Mar 11, 2024
3421608
fixup! Limit unit test max number of clauses
hbierlee Mar 11, 2024
942c81d
Fix binary consistency constraint leading to unsat + tests
hbierlee Mar 11, 2024
d5a0515
Support Dom argument for Bin::ineqs(..)
hbierlee Mar 12, 2024
22251de
Don't ignore scm.rs
hbierlee Mar 21, 2024
ca9c4e3
Support showing aux vars
hbierlee Mar 21, 2024
7937672
Add special case for (x+y<=y):B
hbierlee Mar 26, 2024
94a799b
Omit some dom optimization for bin coupling
hbierlee Mar 26, 2024
9091e99
Return multiple models from decompose_with
hbierlee Mar 27, 2024
f18eade
Create var_encs once in testing
hbierlee Mar 27, 2024
a3dd892
Trace scm::dnf function
hbierlee Mar 27, 2024
f243491
Selectively apply equalize_ternaries
hbierlee Mar 27, 2024
fa6f6a5
Improve Lin display
hbierlee Apr 1, 2024
1cb0c85
Add test CHECK_CONFIG_I option
hbierlee Apr 1, 2024
209465c
Don't reverse term::dom for negative coefficient
hbierlee Apr 1, 2024
bcfccb8
fixup! Improve Lin display
hbierlee Apr 1, 2024
4371906
Pass lit_assignments as slice of vecs
hbierlee Apr 1, 2024
0caa734
Refactor coupling
hbierlee Apr 1, 2024
415519e
Skip redundant clauses in order encoding coupling
hbierlee Apr 1, 2024
e7e2e93
Support is_implied bool for binary ineqs
hbierlee Apr 2, 2024
51cc1d6
Fix is_implied for Bin for !up
hbierlee Apr 2, 2024
defa654
Minor refactor
hbierlee Apr 2, 2024
39fba9d
Support integer encoding spec in lp's
hbierlee Apr 2, 2024
c989626
Filter redundant clause in Bin::ineq
hbierlee Apr 3, 2024
226c20d
Refactor coupling loop to prepare avoiding implied ineq(..)
hbierlee Apr 3, 2024
b9ee2c8
Add more prep for avoiding implied consequents
hbierlee Apr 3, 2024
77f47d6
Stop encoding early using recursive encoding
hbierlee Apr 5, 2024
a2cbbaf
Refactor ineqs/ineq
hbierlee Apr 5, 2024
4e33d5b
Fix all tests for ord/binary coupling
hbierlee Apr 8, 2024
7eeccd7
Small refactor
hbierlee Apr 8, 2024
5e57b9e
Refactor Dom::ineq
hbierlee Apr 8, 2024
364a336
Add Dom::d returning domain value by index
hbierlee Apr 8, 2024
dd1400f
Remove implication chained clauses implying same consequent
hbierlee Apr 9, 2024
05bb5c4
Refactor model.rs into {int_var,term,con}.rs
hbierlee Apr 9, 2024
e9cd13f
Support both antecedent and consequent implication checking
hbierlee Apr 11, 2024
fdde529
Add filter cnf method
hbierlee Apr 11, 2024
14e8cfe
Clean up
hbierlee Apr 12, 2024
b026e71
Fix dimacs path for cadical
hbierlee Apr 15, 2024
1e3e463
Add single-var coupling and improve SCM
hbierlee Apr 15, 2024
545e4d4
Fix empty domain init
hbierlee Apr 15, 2024
514760c
Fix last decomp for unary constraints
hbierlee Apr 15, 2024
f055288
Couple single variables correctly
hbierlee Apr 16, 2024
5700fa2
Clean up
hbierlee Apr 16, 2024
1ad8c33
Fix lint
hbierlee Apr 16, 2024
1ec8a78
Clippy
hbierlee Apr 16, 2024
c03c686
Fix unit tests (SCM and constraint simplification)
hbierlee Apr 17, 2024
767626e
Couple using views for single literal variables
hbierlee Apr 17, 2024
d6c8a10
Improve FIND_UNSAT feature
hbierlee Apr 17, 2024
a8d7e2b
Enable last rewrite
hbierlee Apr 17, 2024
de0b44f
Fix coupling and last constraints
hbierlee Apr 17, 2024
0ba8838
Clean up
hbierlee Apr 17, 2024
723d90d
Add default Binary dom when reading Lps
hbierlee Apr 17, 2024
7c7ba30
Initial limit of ub of equalize_ternaries
hbierlee Apr 17, 2024
84048d9
Fix display dom
hbierlee Apr 17, 2024
d63791e
Fix test brute force
hbierlee Apr 18, 2024
7adb897
Fix tests
hbierlee Apr 18, 2024
cb85c57
Enable limited view coupling
hbierlee Apr 18, 2024
a519181
Add new coupling
hbierlee Apr 18, 2024
c5cef9c
Disable old method for removing imp clausees
hbierlee Apr 18, 2024
560bd42
Revert
hbierlee Apr 18, 2024
8e62b5e
Quick fix of coupling constraint order
hbierlee Apr 18, 2024
dea349a
Support non-redundant coupling for both cmps
hbierlee Apr 18, 2024
5ba33a2
Fix all but one test for coupling
hbierlee Apr 19, 2024
3f82ea4
Clippy
hbierlee Apr 19, 2024
c052b04
Fix last coupling test
hbierlee Apr 19, 2024
228569a
Enable coupling view in both directions
hbierlee Apr 19, 2024
dd47715
Clean up
hbierlee Apr 19, 2024
9015fbf
Show literals for each int var (tentative)
hbierlee Apr 19, 2024
57b9844
Make coupling (order) variables consistent
hbierlee Apr 19, 2024
5ffa343
Implement TryInto<usize> for Literal to speed up statics
hbierlee Apr 20, 2024
3127372
Add ENCODE_ONLY option
hbierlee Apr 20, 2024
f37f7c1
Fix pyndakaas
hbierlee Apr 20, 2024
b30fd98
Use proper coupling for terms with non-one coefs
hbierlee Apr 20, 2024
5e08650
Fix ELIPSIZE
hbierlee Apr 20, 2024
8a33c3f
Add option to couple var over term
hbierlee Apr 20, 2024
e3e09cf
Support channelling
hbierlee Apr 21, 2024
6ca7d8f
Clean up
hbierlee Apr 21, 2024
0bafb16
Fix channel decomp bug
hbierlee Apr 21, 2024
9c3a7b5
Change name
hbierlee Apr 21, 2024
7b1211a
Use functional RCA
hbierlee Apr 21, 2024
bb097af
Change bdd sort order
hbierlee Apr 21, 2024
5a470f8
Revert bdd sort order
hbierlee Apr 21, 2024
7506410
Skip implied clause in order ineq encoding
hbierlee Apr 22, 2024
2626abd
Update display of doms
hbierlee Apr 22, 2024
f2bfa68
Clean up
hbierlee Apr 22, 2024
88996d0
Decompose models i/o constraints + add CSE
hbierlee Apr 25, 2024
d27cece
Fix tests / SCM / coupling
hbierlee Apr 25, 2024
7ca4575
SHOW_LITS false
hbierlee Apr 25, 2024
4a90fa8
Turn off SHOW_IDS
hbierlee Apr 25, 2024
0e7a952
Refactor (?) slightly lin decomposer
hbierlee Apr 25, 2024
b062be0
Support limited sol checking
hbierlee Apr 25, 2024
459a850
Fix CSE bug maybe
hbierlee Apr 25, 2024
798420a
Update
hbierlee Apr 25, 2024
0a6db2c
Make more decomp stuff public
hbierlee Apr 26, 2024
367f712
Optimize BDD decomposer
hbierlee Apr 26, 2024
9e1b996
Optimize Dom::geq
hbierlee Apr 26, 2024
5fb2472
Return domain value along with position in Dom::geq
hbierlee Apr 26, 2024
6f04d0b
Limit number of decomps
hbierlee Apr 26, 2024
e8cc74d
Fix Dom::Geq
hbierlee Apr 26, 2024
a19669c
Disable long running test
hbierlee Apr 26, 2024
bcc1540
Re-add Scm::Add (with CSE support)
hbierlee May 6, 2024
7405d68
Handle -1*x:B using complement
hbierlee May 7, 2024
6109778
Clippy
hbierlee May 7, 2024
9ca61cc
Fix (a*x-b*y):B
hbierlee May 8, 2024
f8064d8
Only test uniform encodings
hbierlee May 8, 2024
04efd45
Fix minor issues
hbierlee May 8, 2024
9e0e54c
Merge develop into feature/refactor-linear-encoding
hbierlee May 15, 2024
13ea725
Clean up, clippy, refactor
hbierlee May 15, 2024
35e8c3a
Add basic usage and resolve more TODOs
hbierlee May 15, 2024
25a6b6a
Resolve more TODOs
hbierlee May 15, 2024
6da06d5
Implement Debug for types
Dekker1 May 8, 2024
59c8909
Merge
hbierlee May 15, 2024
31640cb
Merge branch 'develop' into feature/refactor-linear-encoding
hbierlee May 15, 2024
7664a8a
Fixes
hbierlee May 15, 2024
55fa669
Fix unused imports
hbierlee May 15, 2024
687af73
Clean up, small
hbierlee May 15, 2024
49e4a48
Remove Sorted (into feature branch)
hbierlee May 15, 2024
961d389
Refactor
hbierlee May 15, 2024
a64303e
Move cmdline_solver to feature branch
hbierlee May 15, 2024
72d4758
Fix GitHub checks
hbierlee May 15, 2024
fccd690
Fix handling neg coeff for unencoded x:B's
hbierlee May 16, 2024
6c54c7e
Format scm_db
hbierlee May 16, 2024
81283ec
Try out -diff to mark res folder as binary
hbierlee May 16, 2024
e92d48a
Fix dir
hbierlee May 16, 2024
fb17fb2
Make more specific
hbierlee May 16, 2024
ac57ced
Fix more tests by handling missing cases
hbierlee May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crates/pindakaas/src/int/res/scm_db.rs -diff
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/target
Cargo.lock
crates/pindakaas/res/scm
!crates/pindakaas/res/scm.tar.gz
crates/pindakaas/src/int/scm_db.rs
crates/pindakaas/tmp

2 changes: 2 additions & 0 deletions crates/pindakaas-cadical/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
fn main() {
// TODO [?] something like this needs to be added to all build.rs files? Even better, pinpointing the specific files which could change?
println!("cargo:rerun-if-changed=vendor");
let src = [
"vendor/cadical/src/analyze.cpp",
"vendor/cadical/src/arena.cpp",
Expand Down
12 changes: 10 additions & 2 deletions crates/pindakaas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ edition = "2021"

[dependencies]
cached = "0.46"
iset = "0.2"
bzip2 = "0.4"
flate2 = "1.0"
itertools = "0.12.0"
rand = "0.8.5"
rustc-hash = "1.1"
# Dynamically load solver libraries (through IPASIR interfaces)
libloading = "0.8"
Expand All @@ -27,6 +29,13 @@ pindakaas-derive = { path = "../pindakaas-derive", optional = true }
pindakaas-intel-sat = { path = "../pindakaas-intel-sat", optional = true }
pindakaas-kissat = { path = "../pindakaas-kissat", optional = true }
splr = { version = "0.17", optional = true }
iset = "0.2.2"
# assert_ok = "1.0.2"

[build-dependencies]
itertools = "0.11"
tar = "0.4"
flate2 = "1.0"

[dev-dependencies]
splr = { version = "0.17", features = ["incremental_solver"] }
Expand All @@ -37,7 +46,6 @@ cadical = ["pindakaas-cadical", "pindakaas-derive"]
intel-sat = ["pindakaas-intel-sat", "pindakaas-derive"]
kissat = ["pindakaas-kissat", "pindakaas-derive"]
trace = ["tracing"]
default = ["cadical"]
ipasir-up = ["cadical"]

[lints]
Expand Down
107 changes: 107 additions & 0 deletions crates/pindakaas/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
use std::{fs, path::Path};

use flate2::read::GzDecoder;
use itertools::Itertools;
use tar::Archive;

// TODO [!] once recipes added, to be moved from build.rs to a rust script type thing: scm_db_res.rs
fn scm() -> Result<Vec<(usize, u32, Vec<ScmNode>)>, std::io::Error> {
if Path::new("./res/scm").exists() {
fs::remove_dir_all("./res/scm")?;
fs::create_dir("./res/scm")?;
} else {
fs::create_dir("./res/scm")?;
}

let db = Path::new("./res/scm.tar.gz");
assert!(db.exists());

Archive::new(GzDecoder::new(fs::File::open(db)?))
.unpack("./res/")
.unwrap();

Ok(fs::read_dir("./res/scm")?
.map(|f| {
let path = f.unwrap().path();
let scm = fs::read_to_string(&path)
.unwrap()
.lines()
.filter(|line| !(line.is_empty() || line.starts_with('#')))
.map(|line| match line.split(',').collect::<Vec<_>>()[..] {
[i, i1, sh1, add, i2, sh2] => ScmNode {
i: i.parse().unwrap(),
i1: i1.parse().unwrap(),
sh1: sh1.parse().unwrap(),
add: match add {
"+" => true,
"-" => false,
_ => unreachable!(),
},
i2: i2.parse().unwrap(),
sh2: sh2.parse().unwrap(),
},
_ => panic!("Unexpected line {line}"),
})
.collect();
let (bits, v) = path
.file_stem()
.unwrap()
.to_str()
.unwrap()
.split('_')
.collect::<Vec<_>>()
.into_iter()
.collect_tuple()
.unwrap();
(bits.parse().unwrap(), v.parse().unwrap(), scm)
})
.sorted_by_key(|(b, c, _)| (*b, *c))
.collect())
}

#[allow(dead_code)]
#[derive(Debug)]
pub(crate) struct ScmNode {
i: u32,
i1: u32,
sh1: u32,
add: bool,
i2: u32,
sh2: u32,
}

pub fn main() {
println!("cargo:rerun-if-changed=res/scm.tar.gz");
println!("cargo:rerun-if-changed=res/ecm.tar.gz");
println!("cargo:rerun-if-changed=build.rs");

let scm = scm().unwrap();

let scm_node_def = r"use crate::Coeff;
#[derive(Debug, Clone)]
pub(crate) struct ScmNode {
pub(crate) i: usize,
pub(crate) i1: usize,
pub(crate) sh1: u32,
pub(crate) add: bool,
pub(crate) i2: usize,
pub(crate) sh2: u32,
}";
// TODO make HashMap (but this is not easy using static/const)
let o = format!(
"{scm_node_def}
pub(crate) static SCM: [(u32, Coeff, &[ScmNode]); {}] = [\n{}\n];",
scm.len(),
scm.iter()
.map(|(x, c, scm)| format!("\t({}, {}, &{:?})", x, c, scm))
.join(",\n")
);
fs::write("./src/int/res/scm_db.rs", o).unwrap();

let db = Path::new("./res/ecm.tar.gz");
assert!(db.exists());

Archive::new(GzDecoder::new(fs::File::open(db).unwrap()))
.unpack("./res/")
.unwrap();
}
Binary file added crates/pindakaas/res/ecm.tar.gz
Binary file not shown.
Binary file added crates/pindakaas/res/scm.tar.gz
Binary file not shown.
4 changes: 0 additions & 4 deletions crates/pindakaas/src/cardinality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::{
CardinalityOne, CheckError, Checker, ClauseDatabase, Encoder, Lit, Valuation,
};

mod sorting_network;
pub use sorting_network::SortingNetworkEncoder;

#[derive(Clone, Debug)]
pub struct Cardinality {
pub(crate) lits: Vec<Lit>,
Expand Down Expand Up @@ -56,7 +53,6 @@ impl<DB: ClauseDatabase, Enc: Encoder<DB, Cardinality> + CardMarker> Encoder<DB,
// local marker trait, to ensure the previous definition only applies within this crate
pub(crate) trait CardMarker {}
impl<T: LinMarker> CardMarker for T {}
impl CardMarker for SortingNetworkEncoder {}

#[cfg(test)]
pub(crate) mod tests {
Expand Down
Loading
Loading