|
| 1 | +--- |
| 2 | +name: gecode |
| 3 | +description: "Gecode architecture, modeling, cookbook-style modeling patterns, set/float/scheduling guidance, propagators, branchers, memory management, search engine usage and implementation, recomputation/cloning behavior, and debugging/performance diagnosis. Use for any materially Gecode-specific task: building or refining Gecode models, implementing custom constraints or branchers, tuning DFS/BAB/RBS/PBS/LDS search, diagnosing weak propagation or search pathologies, or reasoning about set/float/resource-style models." |
| 4 | +--- |
| 5 | + |
| 6 | +# Gecode |
| 7 | + |
| 8 | +Use this skill as the entry point for any Gecode-specific task. Carry the universal Gecode runtime model in mind for every response, then load only the additional reference files needed for the task. |
| 9 | + |
| 10 | +## Always-On Mental Model |
| 11 | +- Space is the home for variables, propagators, branchers, and optimization order. |
| 12 | +- Propagation is explicit: call `status()`. |
| 13 | +- Search primitives are `status()`, `choice()`, `clone()`, `commit()`, and `constrain()`. |
| 14 | +- Space status values are `SS_FAILED`, `SS_SOLVED`, and `SS_BRANCH`. |
| 15 | +- Choice is a space-independent descriptor; alternatives are indexed `0..n-1`. |
| 16 | +- Choice compatibility is clone-based: a choice is valid for its source space and clones. |
| 17 | +- `choice()` invalidates previous choices for later `commit()` on that space. |
| 18 | +- Clone only stable, non-failed spaces. |
| 19 | +- Branchers run in posting order. |
| 20 | +- Recomputation can be nondeterministic with weakly monotonic propagation while remaining sound and complete. |
| 21 | +- Model as `class M : public Space`, implement copy constructor and virtual `copy()`, and update variable arrays with `x.update(home, s.x)` during cloning. |
| 22 | +- After `status()==SS_BRANCH`, compute `choice()` immediately. |
| 23 | +- Treat returned solutions as owned `Space` objects and delete seed models, choices, and solution spaces explicitly. |
| 24 | +- Do not assume posting performs full propagation. |
| 25 | +- Do not call the `Space` copy constructor directly instead of `clone()`. |
| 26 | +- Do not reuse stale choices after another `choice()` call. |
| 27 | + |
| 28 | +## Default Gecode Heuristics |
| 29 | +- Tighten variable domains as early as possible. |
| 30 | +- Prefer global constraints over weak manual decompositions. |
| 31 | +- Keep branching explicit and problem-specific rather than relying on generic defaults. |
| 32 | +- Treat symmetry handling as first-class design work. |
| 33 | +- Use `DFS` as the baseline complete search engine. |
| 34 | +- Use `BAB` for optimization unless there is a concrete reason to move to restart or portfolio search. |
| 35 | +- Treat restart, portfolio, and parallel search behavior as intentionally nondeterministic. |
| 36 | +- Remember that clone footprint matters when designing actor state and cached data. |
| 37 | +- Use explicit disposal discipline for external or heap-backed resources. |
| 38 | + |
| 39 | +## Routing |
| 40 | +- Read `references/modeling.md` for model structure, variables, constraints, branching setup, and built-in search configuration. |
| 41 | +- Read `references/modeling-cookbook.md` when the user needs concrete recipe-style guidance for channeling, symmetry, branching, optimization setup, or choosing globals versus decompositions. |
| 42 | +- Read `references/debugging-workflow.md` for weak propagation, exploding search trees, stale choices, recomputation bugs, memory growth, or tracing/profiling workflow. |
| 43 | +- Read `references/set-and-float-modeling.md` for set-variable modeling, float-specific caveats, or mixed-domain modeling. |
| 44 | +- Read `references/scheduling-patterns.md` for cumulative/resource-style models, sequencing/order constraints, and scheduling-oriented branching or symmetry choices. |
| 45 | +- Read `references/propagator-implementation.md` for custom propagator design, posting, propagation lifecycle, advisors, and rewriting. |
| 46 | +- Read `references/brancher-implementation.md` for custom branchers, choices, commits, archiving, and NGL support. |
| 47 | +- Read `references/memory-handling.md` for space/region/heap allocation, handles, clone footprint, and disposal obligations. |
| 48 | +- Read `references/search-engines.md` for using and tuning built-in engines such as `DFS`, `BAB`, `LDS`, restart, and portfolio search. |
| 49 | +- Read `references/search-engine-implementation.md` for custom engine orchestration, recomputation strategy, LAO, and completeness invariants. |
| 50 | +- Read `references/general-knowledge.md` only for broad conceptual explanations, tracing/observability guidance, or staged model-improvement workflow discussion that goes beyond the always-on mental model. |
| 51 | + |
| 52 | +## Operating Rules |
| 53 | +- Read only the reference file or files needed for the current task. |
| 54 | +- Combine references only when the task genuinely crosses boundaries, such as a custom propagator with nontrivial memory strategy or a search-engine bug tied to choice compatibility. |
| 55 | +- Prefer the narrowest useful reference set first, then expand if the user asks for adjacent concerns. |
| 56 | +- Keep answers Gecode-specific. If the request is generic CMake, generic C++ memory, or generic CP theory without a real Gecode angle, do not over-apply this skill. |
| 57 | +- Use this `SKILL.md` alone for broad explanations, initial modeling guidance, and many runtime/debugging answers before reaching for extra references. |
| 58 | + |
| 59 | +## Reference Index |
| 60 | +- `references/general-knowledge.md`: advanced observability, staged improvement workflow, and broad conceptual framing beyond the always-on core. |
| 61 | +- `references/modeling.md`: variable selection, globals, reification, symmetry, branching, and search setup in ordinary models. |
| 62 | +- `references/modeling-cookbook.md`: concrete modeling recipes for globals, channeling, symmetry, branching, optimization, and “propagation versus search” decisions. |
| 63 | +- `references/debugging-workflow.md`: symptom-driven diagnosis for weak models, stale choices, recomputation issues, performance pathologies, and observability tooling. |
| 64 | +- `references/set-and-float-modeling.md`: set-variable patterns, float-specific caveats, and mixed-domain modeling reminders. |
| 65 | +- `references/scheduling-patterns.md`: scheduling/resource modeling patterns, sequencing constraints, and search guidance for schedule-like problems. |
| 66 | +- `references/propagator-implementation.md`: actor lifecycle, `ExecStatus`, propagation conditions, iterators, advisors, and rewrite patterns. |
| 67 | +- `references/brancher-implementation.md`: `status`, `choice`, `commit`, archive compatibility, NGLs, and heuristic encoding. |
| 68 | +- `references/memory-handling.md`: memory areas, lazy vs eager allocation, shared/local handles, and `AP_DISPOSE` discipline. |
| 69 | +- `references/search-engines.md`: engine selection, restart/portfolio tradeoffs, no-goods, parallel semantics, and completeness caveats. |
| 70 | +- `references/search-engine-implementation.md`: custom engine state, replay/recomputation, ownership, branch-and-bound integration, and invariants. |
0 commit comments