N-ary constraints
Rules over several cells checked by enumeration (lines, sums, relations). Generated from the comments in the headers by Doxygen and tools/gen_cpp_reference.py; public members only.
nary.hpp
Generic multi-cell ("n-ary") constraints and their consistency engine.
A constraint is a scope of unique cells ("vars") plus a type-specific predicate over positions (positions index vars, so a cell may appear more than once, e.g. a line crossing itself). The engine enumerates assignments consistent with the current domains respecting pairwise distinctness (shared AllDiff groups / neq links / the constraint's own distinct flag) and pair-relation tables between scope cells with bound pruning, and returns per-var supports (generalized arc consistency), the number of consistent assignments, the intersection of their digit sets ("must contain") and whether that digit set is unique.
struct NSpec
input form (from Python dicts)
Fields
typeintastd::vector< int > — sum/set/table cells; arrow circlesegsstd::vector< std::vector< int > > — arrow: {line}; equal_sum: segmentstotalintdistinctint — -1 autosetkindint — set: 0 = consecutiverowsstd::vector< std::vector< int > > — tablequotastd::vector< int > — count: index = digit, -1 = unconstrainedline_kindint — >= 0: a line rule (LineKind)def_linesstd::vector< int >def_regsstd::vector< int > — derived leftovers: the defining lines / regionstotalsstd::vector< int > — sum with an unknown total from this set (incomplete clue); empty = totalnamedbool — table with a rule name (moves coded 6000 + index)offsetint — equal_sum: segment sums of (digit - offset)bounds_onlybool — sum: derived (BandLogic) brute force propagates bounds onlyseg_signstd::vector< int > — bounds_only: +1 / -1 per segment (outie cells subtracted); empty = all +1
struct NConstraint
| Name | What it does |
|---|---|
nv | number of distinct cells (variables) of the constraint |
Fields
typeintindexint — position inPuzzle::nary_specs(-1: derived from a cage group)groupint — cage group it was derived fromhouseint — derived innie/outie region: first house of the unioninnieint — derived innie/outie region: index intoPuzzle::big_inniesset_theorybool — derived by build_set_theory (arrows / little killers in the region)outiebooln_cagesintvarsstd::vector< int > — unique cellspvarstd::vector< int > — position -> var indextotalinttotalsstd::vector< int > — incomplete clue: the total is one of these (empty: total)distinctboolarithboolncircleint — arrow: positions [0, ncircle) are circle digitsseg_startstd::vector< int > — equal_sum: segment k = [seg_start[k], seg_start[k+1])setkindintarityintnamedbool — table with a rule nameoffsetint — equal_sum: segment sums of (digit - offset)bounds_onlybool — derived sum: bounds propagation in brute forcepartstd::vector< int > — bounds_only: var -> part id (cells of a part are pairwise distinct)partsstd::vector< std::vector< int > > — bounds_only: cells per partpart_signstd::vector< int > — bounds_only: +1 / -1 per part (empty = all +1)rowsstd::vector< uint8_t > — table rows over positionsquotastd::vector< int > — countline_kindint — >= 0: line rule (cells in line order = vars)differstd::vector< uint8_t > — nv*nvrelstd::vector< const uint32_t * > — nv*nv: rel_ex(var i -> var j) or nullorderstd::vector< int > — DFS order (vars)shapedouble
int nv() const
number of distinct cells (variables) of the constraint
struct GacReq
Fields
vintvarmaskuint64_t — some var in mask must take v
struct GacOut
Fields
supuint32_t[64]countpm_long — consistent assignments (capped when !complete)completebool — enumeration finished within budgetset_uniquebool — all assignments use the same digit setmustuint32_t — digits in every assignment (valid if complete)anybool