Runs an autonomous research loop to discover the best cuOpt solve strategy for MIP instances from the same family, improving feasible solution quality and reducing optimality gaps.
Ships in cuopt-mip-algorithm-discovery. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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.
A working cuOpt Python installation with a compatible NVIDIA GPU. Use additional Python libraries, including GPU libraries such as CuPy or Numba, when useful.
The user should provide:
The main outputs of the research loop are:
solve.py that 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"
experiments directory containing experiment artifacts and a concise summary.md beside solve.py describing 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.dashboard.html copied from assets/dashboard.html into the working directory beside instances/ and experiments/ 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: Return Optimal or FeasibleFound with a solution, Infeasible when 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 of solve across 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.
| 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. |
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.
Before running anything, settle the inputs and send the user a dedicated message:
Optimal can go undetected. The user must review the final solve to confirm its bound is valid.dashboard.html into 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.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.
For each full experiment:
solve.py in a new experiment directory and run evaluate.py on the full development set. Supply --experiment-name (≤80 characters) and --experiment-description (≤1,000 characters describing the change and hypothesis). Omit --baseline-dir for 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.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.
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.
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.
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.
BENCHMARK.md (opens in a new tab)assets/dashboard.html (opens in a new tab)evals/evals.json (opens in a new tab)scripts/check_feasibility.py (opens in a new tab)scripts/check_modifications.py (opens in a new tab)scripts/evaluate.py (opens in a new tab)scripts/solve.py (opens in a new tab)skill-card.md (opens in a new tab)skill.oms.sig (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/cuopt-mip-algorithm-discovery:cuopt-mip-algorithm-discoveryfrom cuopt-mip-algorithm-discovery
npx claudepluginhub nvidia/cuopt --plugin cuopt-mip-algorithm-discoveryOther plugins' skills for the same job