dp-state-designer
npx machina-cli add skill a5c-ai/babysitter/dp-state-designer --openclawFiles (1)
SKILL.md
2.0 KB
DP State Designer Skill
Purpose
Assist in designing optimal dynamic programming states, transitions, and optimizations for complex DP problems.
Capabilities
- Identify subproblem structure from problem description
- Suggest state representations (dimensions, parameters)
- Derive transition formulas
- Identify optimization opportunities (rolling array, bitmask compression)
- Generate state space complexity estimates
- Detect overlapping subproblems
Target Processes
- dp-pattern-matching
- dp-state-optimization
- dp-transition-derivation
- advanced-dp-techniques
DP Design Framework
- Subproblem Identification: What smaller problems compose the solution?
- State Definition: What parameters uniquely identify a subproblem?
- Transition Formula: How do we combine subproblem solutions?
- Base Cases: What are the trivial subproblems?
- Computation Order: In what order should we solve subproblems?
- Space Optimization: Can we reduce memory usage?
Input Schema
{
"type": "object",
"properties": {
"problemDescription": { "type": "string" },
"constraints": { "type": "object" },
"examples": { "type": "array" },
"requestType": {
"type": "string",
"enum": ["fullDesign", "stateOnly", "transitions", "optimize"]
}
},
"required": ["problemDescription", "requestType"]
}
Output Schema
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"state": {
"type": "object",
"properties": {
"definition": { "type": "string" },
"parameters": { "type": "array" },
"complexity": { "type": "string" }
}
},
"transitions": { "type": "array" },
"baseCases": { "type": "array" },
"optimizations": { "type": "array" }
},
"required": ["success"]
}
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/algorithms-optimization/skills/dp-state-designer/SKILL.mdView on GitHub Overview
Assists in designing optimal dynamic programming states, transitions, and optimizations for complex problems. It helps identify subproblem structure, choose state parameters, derive transitions, and spot memory-saving tricks like rolling arrays or bitmasks.
How This Skill Works
By analyzing the problem description and constraints, it identifies subproblems, proposes state definitions (dimensions and parameters), derives transition formulas, and lists base cases and computation order. It also surfaces optimization opportunities and outputs a structured design that can be implemented directly.
When to Use It
- You have a DP problem with unclear or large state space and need a systematic way to define state parameters.
- You want to derive clean transition formulas and ensure all subproblems are covered without duplicates.
- You seek memory or time optimizations (e.g., rolling arrays, bitmask compression) and want to quantify potential gains.
- You need a reproducible design framework to verify base cases and computation order.
- You want to compare multiple DP design options (state definitions vs. transitions) for a given problem.
Quick Start
- Step 1: Provide problemDescription and requestType (fullDesign, stateOnly, transitions, optimize).
- Step 2: Identify subproblems and draft initial state definitions (parameters and dimensions).
- Step 3: Derive transitions, specify base cases and computation order, then note any space/time optimizations.
Best Practices
- Start with Subproblem Identification: break the problem into smaller, overlapping subproblems.
- Define Minimal State: choose state parameters that uniquely identify subproblems with the smallest necessary dimensionality.
- Derive Clear Transitions: express how subproblem solutions combine to form larger problems.
- Pin Base Cases and Order: specify trivial subproblems and a feasible computation order for DP.
- Validate with Optimizations: assess potential space/time optimizations and verify correctness against constraints.
Example Use Cases
- Knapsack with rolling array optimization to reduce space from O(nW) to O(W).
- Longest Common Subsequence by clearly defining indices as state dimensions.
- Edit Distance via transitions on character operations and base cases for empty strings.
- Subset Sum using bitmask compression to represent reachable sums.
- Grid path counting by defining position and step count as state parameters.
Frequently Asked Questions
Add this skill to your agents