Cuopt Mip Algorithm Discovery
Install this skill
No account required. Pick your tool, then copy.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install skills-cuopt-mip-algorithm-discoveryWhat this does: Run an autonomous research loop to find the best cuOpt solve strategy for MIP instances from the same family, improving feasible solution quality and reducing optimality gaps.
Manual setup by platform
Claude Code
~/.claude/skills/skills-cuopt-mip-algorithm-discovery/SKILL.md
Signing
SignedSLSA L2- Signed by
- skills-hub.ai distributor
- Method
- Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
- Key
- skills-hub-ed25519-2026-11
- Signed
Instructions
cuOpt MIP algorithm discovery
Purpose
Reformulating a MIP model, tuning solver settings, adding custom algorithms, or orchestrating several solves can substantially improve feasible solution quality and reduce optimality gaps. This skill guides you through an autonomous iterative process to find the best solve strategy for a given set of instances.
Prerequisites
A working cuOpt Python installation with a compatible NVIDIA GPU. Use additional Python libraries, including GPU libraries such as CuPy or Numba, when useful.
Inputs
The user should provide:
- A set of development instances (MPS, LP, or QPS files) for evaluation and tuning, all from the same family of instances: the same optimization model with different data.
- A per-instance time limit.
- A time budget: the total duration of the research loop.
- A hardware allocation for each experiment: the GPU to use and the CPU thread limit.
- (Optional) A primary metric of interest: optimality gap (default), primal objective improvement, dual bound improvement, or time to best objective.
- (Optional) A set of held-out instances to assess how well the best solve strategy generalizes.
- (Optional) Additional context, such as a description of the problem or how the instances were generated.
Outputs
The main outputs of the research loop are:
- A Python script called
solve.pythat solves instances from the same family of instances using the best solve strategy found. Run it with:
export CUDA_VISIBLE_DEVICES=$GPU_ID
python solve.py --instance-path "$INSTANCE_PATH" --output-dir "$RUN_OUTPUT_DIR" --time-limit "$TIME_LIMIT" --num-cpu-threads "$NUM_CPU_THREADS"
- An
experimentsdirectory containing experiment artifacts and a concisesummary.mdbesidesolve.pydescribing the research loop and the best solve strategy found. Report the time used versus allocated, the number of distinct candidates evaluated on the full development set, and why the search ended. Include the ⚠️ dual bound warning explicitly, explaining where the final bound comes from and why it is valid. - A
dashboard.htmlcopied from assets/dashboard.html into the working directory besideinstances/andexperiments/for the user to track progress.
The scripts/solve.py script provides the reference implementation and is structured as follows:
def solve(model, time_limit, num_cpu_threads=-1):
"""🔥 Editable: any solve strategy, returning results in the original model's terms."""
...
return status, names, values, objective_value, dual_bound, incumbents_log
def run(instance_path, output_dir, time_limit, num_cpu_threads=-1, save_solution=True):
# ❄️ Frozen: load the instance, call solve, validate, and save outputs. Do not modify.
...
Modify only solve. Define any helpers and imports inside it. You may mutate model, but return results in the original model's terms.
status: ReturnOptimalorFeasibleFoundwith a solution,Infeasiblewhen proven, or the applicable cuOpt termination reason.names,values: For a returned solution, provide aligned 1-D NumPy arrays covering every original variable exactly once.objective_value,dual_bound: Report both on the original objective scale.incumbents_log: Record each incumbent improvement from any source as(elapsed_seconds, objective_value, dual_bound). Measure elapsed time from the start ofsolveacross all stages and restarts.
run rejects solutions that fail scripts/check_feasibility.py.
The script scripts/evaluate.py uses scripts/check_modifications.py to verify that only solve was modified. It then runs the candidate program on the development instances and aggregates the results into a metrics.csv file and a report.json file. The structure of the output is as follows:
.
├── solve.py # best experiment's `solve.py` program
├── check_feasibility.py
├── dashboard.html
├── summary.md
├── instances/
│ ├── instance_001.mps
│ ├── instance_002.mps
│ └── ...
└── experiments/
├── experiment_001/
│ ├── solve.py
│ ├── check_feasibility.py
│ ├── metrics.csv
│ ├── report.json
│ └── artifacts/
│ ├── instance_001/
│ │ ├── metrics.json
│ │ ├── solution.npz # skipped with --no-save-solution
│ │ ├── incumbents.csv
│ │ ├── stdout.log
│ │ └── stderr.log
│ └── ...
└── ...
You are free to add other utility scripts or files that help track experiments and their results.
Available Scripts
| Script | Purpose | Arguments |
|---|---|---|
| solve.py | Solve and validate one instance. | Required: --instance-path, --output-dir, --time-limit. Optional: --num-cpu-threads, --no-save-solution. |
| evaluate.py | Check the candidate, evaluate the instance set, and aggregate metrics. | Required: --experiment-dir, --instances-dir, --time-limit, --experiment-name, --experiment-description. Optional: --baseline-dir, --num-cpu-threads, --no-save-solution. |
| check_modifications.py | Check that only the candidate's solve function changed. | --code-path; also called by evaluate.py. |
| check_feasibility.py | Check a solution against the original instance. | Python helper imported by solve.py; no command-line interface. |
Metrics
The harness computes classic and symmetric scores for gaps (objective versus dual bound) and improvements (candidate versus baseline). Classic scores divide the difference by the magnitude of the objective for gaps or the baseline for improvements. Symmetric scores divide by the sum of both magnitudes.
During research, monitor symmetric gap and improvement scores throughout the run. Rank candidates by the user's primary metric (default: symmetric optimality gap), using the symmetric variant for gaps and improvements.
When reporting to the user, use classic gap and improvement scores in progress updates and the final summary. A near-zero denominator can turn a small change into a huge or infinite percentage. With an objective and dual bound of opposite signs, the classic gap can grow even as the absolute gap shrinks. If either compared value is near zero or their signs differ, report that metric’s symmetric score and label it as symmetric.
Each field below is the mean of the per-instance scores in metrics.csv, with equal weight for every development instance.
| Field for ranking | Goal | Per-instance score |
|---|---|---|
average_symmetric_optimality_gap | Minimize | Gap between the returned objective and its dual bound. Proven infeasibility scores 0. An unsolved instance, a missing finite bound, or a time-limit overrun scores infinity. |
average_symmetric_objective_improvement | Maximize | Signed improvement in the primal objective relative to that instance's baseline. |
average_symmetric_dual_bound_improvement | Maximize | Signed improvement in the dual bound relative to that instance's baseline. |
average_time_to_best | Minimize | Seconds until the run first reached its returned objective, or until it proved infeasibility. An unsolved instance or a time-limit overrun scores the full per-instance time limit. |
When average_symmetric_optimality_gap is infinite, compare the number of instances with finite gaps and inspect the remaining failures.
Instructions
Setup with the user
Before running anything, settle the inputs and send the user a dedicated message:
- Inputs. Restate the inputs, with defaults for optional ones, and ask only for what is missing. Without held-out instances, ask whether to reserve some development instances or proceed without a validated generalization claim.
- ⚠️ Dual bounds are not verified. The harness checks feasibility, not dual bounds, so a wrong gap or a false
Optimalcan go undetected. The user must review the finalsolveto confirm its bound is valid. - Budget. Estimate how many full experiments fit: GPUs × usable budget ÷ (development instances × per-instance time limit). Below about 16, warn that the search will be shallow.
- Monitoring. Copy
dashboard.htmlinto the working directory, serve it (e.g.,python -m http.server), and share its URL. Say they can message you during the run to steer the search.
Research loop
First, read the system clock, record the start time and deadline and evaluate the unmodified solve.py with evaluate.py on the entire development set to establish a baseline.
Then propose and test new candidates. Each full experiment evaluates one candidate solve.py on the entire development set. Use all available resources: run experiments in parallel, one per allocated GPU, launching a new candidate whenever a GPU is free, unless it depends on a running experiment's result. Number experiment directories in launch order so the user can follow progress in the directories and on the dashboard.
Experimental procedure
For each full experiment:
- Form a hypothesis. State what you will change, what evidence motivates it, and what result would support it. If the dual bound comes from anything other than a single cuOpt solve of the original model, explain why it is valid.
- Run the experiment. Save the candidate
solve.pyin a new experiment directory and runevaluate.pyon the full development set. Supply--experiment-name(≤80 characters) and--experiment-description(≤1,000 characters describing the change and hypothesis). Omit--baseline-dirfor the baseline and point it to the baseline experiment for later runs. If the run fails before meaningful optimization begins, record the cause, fix it and rerun in the same directory. - Check the prediction. Compare the candidate with the baseline and, for a refinement, with the candidate it builds on. Use per-instance results and logs to explain the aggregate result. Record whether the evidence supports, contradicts, or leaves the hypothesis unresolved.
- Choose the next experiment. Use what you learned to decide whether to refine the candidate, test a different hypothesis, or rerun a comparison. Record the reason in a sentence.
Implementation constraints
Pass the allocated CPU thread count to evaluate.py via --num-cpu-threads, including for the baseline. All workers and library thread pools share that allocation. Concurrent experiments must have separate CPU allocations.
Pass --no-save-solution to evaluate.py or solve.py when you do not need to analyze solution.npz, to avoid filling the disk.
Keep each candidate focused on the experiment. Remove unused code and inactive branches.
The strategy must generalize across the family of instances. Do not hard-code instance identifiers, known solutions, or instance-specific constants. Derive structural assumptions from the input and validate them before use. Keep each run of solve self-contained. Never pass state between runs through files.
The per-instance time limit covers everything inside solve. Any overrun counts as unsolved, including time spent waiting for cuOpt to return. The baseline reserves three seconds for overruns. You may adjust or remove that margin.
When changing model dimensions, build a fresh DataModel with the complete transformed data. Resizing a loaded model in place can leave stale RHS/row-type metadata and cause validation errors or NoTermination.
Use the preinstalled cuOpt for every LP or MIP solve, including auxiliary solves and diagnostics. Do not use any other LP or MIP solvers, even through scipy.
Keep mip_absolute_gap and mip_relative_gap at their cuOpt defaults in every cuOpt solve. Return Optimal only when the original objective and a valid dual bound satisfy cuOpt's gap criterion. Leave mip_heuristics_only unset.
The harness cannot validate the dual bound. Every reported bound must be valid for the original model. If it comes from anything other than a single cuOpt solve of that model, explain why it is valid.
Search space
Within the implementation constraints, you may use any strategy inside solve, including reformulating, restricting, relaxing or decomposing the model; cuOpt settings (presolve, cuts, branching, heuristics, etc.); custom heuristic or exact algorithms, including your own dual bounds; warm starts; and multiple cuOpt solves, staged or concurrent, with any split of the time limit. Use the model structure, solver logs, cuOpt source code and prior results to choose what to test. If cuOpt’s search underperforms, first test settings targeting the observed bottleneck (e.g., sub-MIP fixing rates and budgets, competing heuristics, presolve effort, or cut passes), including their interactions, before building a replacement.
Exploration and exploitation. Test substantially different approaches before spending many experiments refining one. When an approach improves the user's primary metric, use the results to choose which changes are worth refining.
Plateaus. Track optimality gap, primal objective improvement and dual bound improvement alongside the user's primary metric. If successive refinements move the primary metric only within observed run-to-run variation, inspect the per-instance results to identify what still limits progress. Test a substantially different approach to that limitation.
cuOpt nondeterminism. The same candidate can produce different results on identical inputs. When an apparent gain could change what you pursue or select, rerun the contenders under comparable load, typically once or twice. Concurrent solves contend for CPU memory bandwidth, so a result depends on what else was running.
Budget
Use the full time budget and complete as many full experiments as possible. Stop iterating early only if one candidate proves optimality on every development instance within the per-instance time limit.
You may also spend time on other work as needed (analyzing logs or solutions, profiling, testing ideas on small or synthetic instances etc.).
Evaluation is usually the bottleneck. Plan launches around observed evaluation times and available GPUs. Estimates of implementation time are unreliable, so implement promising strategies even when they seem time-consuming to code.
Reserve time for cleanup, a final evaluation on the full development set, and reporting.
Selection
Rank eligible candidates by the primary metric, robustness and code quality. Judge robustness by how consistently a candidate returns valid results within the time limit and how well its gains hold up across reruns and development instances. Average all runs per configuration, including failures. Check whether one large gain masks regressions elsewhere. Prefer simpler candidates when performance is comparable.
Reserve time for cleanup and validation. Remove unused code and test whether questionable rules or special cases can be dropped. Update the solve docstring to describe the final solve strategy. Re-evaluate the final solve.py on the full development set. Keep the baseline if none improves on it.
If held-out instances are available, finalize the candidate first, then evaluate it and the baseline on those instances without further tuning.
Security
Reviews (0)
Related skills
Browse all →More from skills
View source →More Build skills
Browse category →Frequently asked questions about cuopt-mip-algorithm-discovery
What does the cuopt-mip-algorithm-discovery skill do?
Run an autonomous research loop to find the best cuOpt solve strategy for MIP instances from the same family, improving feasible solution quality and reducing optimality gaps. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the cuopt-mip-algorithm-discovery skill?
Run `npx @skills-hub-ai/cli install skills-cuopt-mip-algorithm-discovery` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/skills-cuopt-mip-algorithm-discovery/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does cuopt-mip-algorithm-discovery work with?
cuopt-mip-algorithm-discovery runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the cuopt-mip-algorithm-discovery skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use cuopt-mip-algorithm-discovery after installing it?
In Claude Code, type `/skills-cuopt-mip-algorithm-discovery` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the cuopt-mip-algorithm-discovery skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/skills-cuopt-mip-algorithm-discovery)<a href="https://skills-hub.ai/skills/skills-cuopt-mip-algorithm-discovery"><img src="https://skills-hub.ai/api/badges/skill/skills-cuopt-mip-algorithm-discovery" alt="Install on Skills Hub"></a>More options in the badge docs.