# HGen Family Solver

## Family Analysis

The target family consists of random k-SAT instances from the hgen (hard generator) family,
used in SAT competitions since SAT 2003.

### Instance Types

| Type | Structure | Clause Ratio | Notes |
|------|-----------|-------------|-------|
| hgen1 | Regular 3-SAT | 3.5 | Below threshold, satisfiable |
| hgen2 | Regular 3-SAT | 3.5 | Community structure |
| hgen3 | Regular 3-SAT | 3.5 | Harder community structure |
| hgen5 | Mixed 3/4-SAT | ~7.1 | 75% 4-clauses, 25% 3-clauses |
| hgen6 | Regular 3-SAT | ~4.2 | Near threshold |
| hgen7 | Regular 3-SAT | ~4.4 | At/above threshold |
| hgen8 | Mixed 2/4-SAT | ~1.5-1.6 | Mostly binary, many UNSAT |
| Unnamed | 3-SAT | 3.5 | 320 vars, 1120 clauses (likely hgen2/3 variants) |

## Solver Architecture

### SLS Engine (SAT instances)
- **probSAT**: Break-weighted probability distribution f(b) = (0.9+b)^(-cb)
  - Deterministic freebie: if any literal in clause has break=0, pick it
  - Portfolio cb: 70% cb=3.7, 10% cb=2.5, 10% cb=4.5, 10% cb=2.85
  - Separate psG for mixed clause sizes using cb=4.4 for 4-clauses
- **PAWS clause weighting**: 33% weight bump on non-improving flips, smooth period N/2
  - Weighted clause selection (25% of picks prioritize highest-weight unsatisfied clause)
- **Partial restarts**: Best-so-far assignment with 5-20% adaptive noise, every 2nd restart
- **2-SAT SCC**: Iterative Tarjan SCC for binary clause analysis (hgen8 SAT detection)

### CDCL Engine (hgen8 UNSAT instances)
- Two-watched literals with blocker optimization
- Separate binary propagation for 2-clause-dominated formulas
- VSIDS activity heuristic with binary heap
- First-UIP conflict analysis with clause minimization (iterative DFS)
- LBD-based clause quality metric
- Clause deletion (keep top 50% by LBD/activity, max 4000 learned)
- Luby restarts (base=128)
- Phase saving
- VeriPB proof generation via RUP steps + del commands

## Performance

### Broker Results
| Version | SAT | UNSAT | Total | OOM | Notes |
|---------|-----|-------|-------|-----|-------|
| v12 | 177 | 4 | 181 | 0 | Best SAT count (lucky run) |
| v14 | 172 | 4 | 176 | 9 | Restored v12 base |
| v15 | 171 | 5 | 176 | 0 | Best clean (0 OOM) |
| v16 | 170 | 5 | 175 | 3 | Walk noise hurt |
| v17 | 170 | 5 | 175 | 17 | Long intensification OOM |
| v18 | 168 | 5 | 173 | 6 | Adaptive phases hurt |
| v19 | 167 | 5 | 172 | 1 | Novelty+ hurt |
| v20 | ? | ? | ? | ? | v15 base + clause min + PAWS tuning |

### Baseline Comparison
- kissat-sc2024: 142 solved (137 SAT + 5 UNSAT)

## Changelog
- v1-v4: Initial probSAT, 2-SAT, unit propagation development
- v8: Portfolio cb parameters (3.7/2.5/4.4)
- v10: Added full CDCL solver for hgen8 UNSAT proof generation
- v11: Fixed binary implication indexing bug
- v12: Added PAWS clause weighting + partial restarts (+13 SAT)
- v13: CCA experiment (REGRESSION: -26 SAT, +7 OOM)
- v14: Reverted CCA
- v15: Diversified partial restarts, tuned PAWS (smoothPeriod=N/2, 33% bump)
- v16: Walk noise experiment (REGRESSION: -1 SAT)
- v17: Long intensification (REGRESSION: +17 OOM)
- v18: Adaptive restart phases (REGRESSION: -3 SAT)
- v19: Novelty+ experiment (REGRESSION: -4 SAT)
- v20: v15 base + CDCL clause minimization (iterative DFS)
  - Restored v15 PAWS parameters (33% bump, smoothPeriod=N/2)
  - Partial restarts every 2nd (was 3rd) with 5-20% adaptive noise
  - CDCL: added iterative DFS clause minimization for shorter learned clauses
  - CDCL: proofs verified correct with VeriPB

## Known Limitations
- hgen8 n>=260: CDCL may be slow (returns UNKNOWN if no proof within time limit)
- Hard hgen3/hgen6 instances: Some timeout with SLS
- ~93 instances unsolved (all timeouts) - mostly hard community structure SAT instances
- No UNSAT proof support for non-hgen8 instances

## Experiments Tried (Regressions)
- CCA (Configuration Checking with Aspiration): Large overhead from neighbor lists
- Novelty+: lastFlip tracking overhead, 10% Novelty+ restarts hurt
- Walk noise (3% random walk): Diversification hurt more than helped
- Two-phase intensification (10x budget): OOM from clause weights
- Adaptive restart phases: Hurt SLS performance

## Next Steps
- Survey Propagation for hard random instances near threshold (implementation incomplete)
- Better intensification when close to solution (1-2 false clauses)
- Optimized CDCL for larger hgen8 instances
- Consider parallel restarts / clause sharing if time permits
