Milp Solver Workflow logo

Milp Solver Workflow

OrganizationPopular
benchflow-ai
milp-solver-workflow

Use for formulating, solving, debugging, and validating mixed-integer linear optimization models with open-source solvers, including variable indexing, sparse constraints, linearized costs, solver limits, MIP gaps, incumbent extraction, numerical tolerances, and deterministic output reporting.

Overview

Publisherbenchflow-ai
Repositoryskillsbench
Skill namemilp-solver-workflow
Stars
1.8K
Forks
371
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by benchflow-ai on GitHub. Read the source before you install it.

Installation

Install the Milp Solver Workflow AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/benchflow-ai/skillsbench/tree/main/tasks/energy-unit-commitment/environment/skills/milp-solver-workflow
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/benchflow-ai/skillsbench.git /tmp/skillsbench
mkdir -p .claude/skills
cp -r /tmp/skillsbench/tasks/energy-unit-commitment/environment/skills/milp-solver-workflow .claude/skills/milp-solver-workflow
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Milp Solver Workflow in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Milp Solver Workflow on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Milp Solver Workflow is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

MILP Solver Workflow

Use this skill for binary/integer decisions, linear constraints, and linear or piecewise-linear objectives. It is useful for time-expanded scheduling models with many repeated resource-period constraints.

This is a workflow and implementation guide, not a complete formulation for any one task.

Workflow

  1. Parse and normalize data into ordered arrays.
  2. Define decision states before coding: status, transitions, continuous quantities, slacks, segments, tiers.
  3. Build a deterministic variable map.
  4. Add constraints family by family: bounds, linking, balance, time coupling, capacity/ramp limits, cost logic.
  5. Solve with an available open-source MILP solver.
  6. Extract a candidate solution, rounding binaries only if near integral.
  7. Convert internal variables into the report convention.
  8. Independently validate extracted arrays.
  9. Recompute objective and summaries from extracted arrays.
  10. Write final output only after validation passes.

Variable Map Pattern

Use helper functions or dictionaries, not scattered index arithmetic.

python
offset = {}
n = 0

def alloc(name, shape, lb=0.0, ub=float("inf"), integer=False):
    global n
    size = int(np.prod(shape))
    idx = np.arange(n, n + size).reshape(shape)
    offset[name] = idx
    n += size
    return idx

u = alloc("commitment", (G, T), lb=0, ub=1, integer=True)
start = alloc("startup", (G, T), lb=0, ub=1, integer=True)
dispatch = alloc("dispatch", (G, T), lb=0)
reserve = alloc("reserve", (G, T), lb=0)

Keep variable ownership obvious: type, resource, period, and optional segment/tier.

Sparse Constraint Pattern

Use sparse rows for large time-expanded models:

python
rows, cols, vals = [], [], []
lb, ub = [], []
row = 0

def add_row(terms, lo, hi):
    global row
    for j, a in terms:
        if abs(a) > 0:
            rows.append(row)
            cols.append(j)
            vals.append(float(a))
    lb.append(float(lo))
    ub.append(float(hi))
    row += 1

Use equality rows for conservation/linking and upper/lower bound rows for capacity, reserve, ramping, timing, and logic.

Sign-Safe Encoding

Write the intended inequality first, then move variable terms to the left-hand side.

python
# Intended: x + y <= cap * u - reduction * start
# Row form: x + y - cap*u + reduction*start <= 0
add_row(
    [(x, 1.0), (y, 1.0), (u, -cap), (start, reduction)],
    lo=-INF,
    hi=0.0,
)

For non-obvious rows, test a tiny hand case. Example: set u=1, start=1 and check the remaining capacity equals the intended startup capability; set u=1, start=0 and check normal capacity returns.

Match Model Rows To Validation

Keep a checklist linking each model constraint family to a validation check:

text
transition linking      -> startup/shutdown match status
online capacity         -> offline zeroes and min/max output
joint reserve capacity  -> production plus reserve fits capability
ramp deliverability     -> reserve can be deployed within ramp-up
minimum durations       -> starts/stops imply required status windows
balance equations       -> demand/load/inventory conservation
cost-curve logic        -> recomputed objective matches report

If validation checks something not in the model, the solver may produce an invalid report. If the model has a constraint not validated after extraction, conversion bugs can slip through.

Piecewise-Linear Costs

Identify the curve convention before modeling:

  • total cost at output breakpoints;
  • marginal or incremental segment cost;
  • heat-rate curve;
  • first point as minimum-output or no-load-like cost.

For segment variables, constrain segment quantities to their widths and sum them to the modeled production quantity. Use slopes only when the data represents total-cost breakpoints or incremental segment costs consistently.

Open-Source Solver Use

HiGHS through SciPy is a common default when available:

python
from scipy.optimize import milp, LinearConstraint, Bounds

result = milp(
    c=c,
    integrality=integrality,
    bounds=Bounds(lb, ub),
    constraints=constraints,
    options={"time_limit": 600.0, "mip_rel_gap": 0.01, "disp": False},
)

if result.x is None:
    raise RuntimeError(f"No incumbent: status={result.status}, message={result.message}")

Capture status, objective, incumbent values, and any reliable gap/bound. A time-limit status can be useful if a feasible incumbent exists; a failure with no incumbent is not a solution.

Extraction And Validation

After solving:

  • check binary variables are close to 0/1 before rounding;
  • convert internal units/conventions to report units;
  • recompute summaries from arrays;
  • recompute objective from input data and extracted decisions;
  • run validation that reads only input data plus extracted/report arrays;
  • write "pass" self-checks only after validation passes.

Debugging Infeasibility

First suspect the model encoding. Common causes:

  • mixing total output with output above minimum;
  • applying startup/shutdown limits to the wrong quantity;
  • using the wrong t or t-1 index;
  • over-constraining initial minimum up/down obligations;
  • enforcing post-horizon obligations when the prompt excludes them;
  • treating cost curves as feasibility constraints;
  • choosing bad Big-M values;
  • requiring segment/tier variables when the trigger did not occur.

Debug in stages: check shapes, relax one family at a time, add diagnostic slack variables, print largest violations, and compare local validation with final requirements.

Repair LPs And Heuristics

A fixed-commitment repair LP is useful only if it includes every feasibility family judged in the final report. Do not repair only balance and capacity while omitting transition-dependent ramp, reserve, startup, shutdown, or minimum-duration limits.

Always rerun independent validation after repair.

Reporting Discipline

  • Use deterministic ordering and plain numeric values.
  • Do not include placeholder values.
  • Keep feasibility separate from proof quality/MIP gap.
  • Use null/empty gap when no reliable bound exists, if the schema allows it.
  • Do not trust solver status or self-reported "pass" strings without validation.

Frequently asked questions

What does the Milp Solver Workflow AI skill do?

Use for formulating, solving, debugging, and validating mixed-integer linear optimization models with open-source solvers, including variable indexing, sparse constraints, linearized costs, solver limits, MIP gaps, incumbent extraction, numerical tolerances, and deterministic output reporting.

Why use Milp Solver Workflow on TypingMind?

Because you install it once and use it with any model. Milp Solver Workflow is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Milp Solver Workflow in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/benchflow-ai/skillsbench/tree/main/tasks/energy-unit-commitment/environment/skills/milp-solver-workflow. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Milp Solver Workflow?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Milp Solver Workflow?

As many as you like. As long as a model supports skills, you can use Milp Solver Workflow with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Milp Solver Workflow AI skill free?

Yes. It is published on GitHub by benchflow-ai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇