Skip to content

Latest commit

 

History

History
204 lines (138 loc) · 4.92 KB

File metadata and controls

204 lines (138 loc) · 4.92 KB

View Reference

UCCE views are virtual containers over combinatorial spaces. They expose the same operational contract even when the underlying mathematical space is different:

view.len();
view.arity();
view.get_into(&index, &mut out);
view.stream_into(&start, &end, |coord| { /* ... */ });

The important rule is that get_into(i) addresses the view's own dense index space. For unconstrained views, that index is the natural parent combinatorial rank. For constrained views, that index is dense over valid coordinates only.

Common Contract

Every view represents a finite ordered set of coordinates:

V = [coord_0, coord_1, ..., coord_{len-1}]

len() returns the number of coordinates in V. get_into(i, out) writes coord_i into the caller-provided buffer. stream_into(start, end, f) visits the half-open range:

coord_start, coord_{start+1}, ..., coord_{end-1}

Coordinates are positions into Universe::valid_indices() for universe-backed views. Domain callers map those positions to their own ids after the view has returned the coordinate.

CombinationView

CombinationView represents unordered subsets of size k without repetition:

0 <= a_0 < a_1 < ... < a_{k-1} < n

The count is:

C(n, k)

The ranking system is the combinatorial number system. UCCE can jump directly to the i-th combination without generating combinations 0..i.

Use it when the only constraint is cardinality.

CombinationWithRepView

CombinationWithRepView represents nondecreasing coordinates:

0 <= a_0 <= a_1 <= ... <= a_{k-1} < n

The count is:

C(n + k - 1, k)

This is useful for multisets where the same element may be selected more than once.

PermutationView

PermutationView represents ordered selections without repetition. A coordinate of arity k is:

(a_0, a_1, ..., a_{k-1})

with every a_i distinct. For full permutations k = n; for partial permutations k < n.

The count is:

n! / (n - k)!

The rank/unrank path uses factorial-style mixed radix arithmetic.

CartesianView

CartesianView represents dense products:

A_0 x A_1 x ... x A_{k-1}

When every axis has the same length n, the count is:

n^k

The rank/unrank path is stride arithmetic. This is the simplest view family and is usually the cheapest to index.

Linear ConstrainedCombinationView

ConstrainedCombinationView wraps a parent combination view and compiles an integer aggregate constraint into a countable diagram. The compile produces an owned FlatMdd, but the view can also be attached from a validated mapped image (from_mapped_image, from_mapped_bytes, or from_mapped_file with the mmap feature) and answer queries from it without decoding it.

The accessors reflect that: mdd() returns Option<&FlatMdd>, because a mapped view owns no decoded diagram; diagram() returns whichever representation is in use, and to_flat() materializes an owned FlatMdd when a caller insists on one.

Example predicate:

sum(score[i] for i in A) between L and U

The view is:

F = { A in C(n, k) | L <= sum(score[A]) <= U }

F receives its own dense index space:

0..|F|

This is not a stream filter over C(n, k). The MDD stores counts below each edge, so unranking can skip entire invalid subtrees.

See Constrained Combinations.

MonotoneCoverCombinationView

MonotoneCoverCombinationView is a constrained combination view for bitset coverage:

OR_{i in A} hit_mask[i] == all_requirements

It is the generic backend for hitting-set and coverage problems where a subset is valid if it covers every requirement bit. It supports exact compatibility policies and bounded realtime builds.

See Monotone Cover View.

StateContingentFeasibilityView

StateContingentFeasibilityView models payoff feasibility:

exists x_i >= 0
sum x_i = 1
for every state s:
    sum x_i * payoff_i[s] >= target

It compiles economic feasibility into dual cover requirements and uses MCCV for the final indexed combination space once the requirement family is closed.

See State-Contingent Feasibility.

VerifiedStateContingentStream

VerifiedStateContingentStream is not a full View. It is a budgeted, realtime stream that emits only combinations validated by the feasibility oracle. It may add dynamic cuts while streaming, so its candidate space can change and len/get are intentionally not exposed.

See Verified vs Exact Feasibility.

BinaryCoverJoinView

BinaryCoverJoinView is the specialized k=2 cover primitive:

cap[a] OR cap[b] == ALL

rewritten as:

miss[a] AND miss[b] == EMPTY

It groups equal missing masks and builds rankable group-pair blocks instead of checking every raw pair.

See Binary Cover Join Pair View.