Solve it, don't brute-force it
Reaching for nested loops or itertools to search every combination works for toy sizes and then falls off a cliff. These guides take a classic optimization problem — assignment, knapsack, scheduling, routing, packing, graph problems — show the brute-force version and why it explodes, then model it and hand it to quicopt: a few lines, solved in Python. Every code block is run against the live free tier before it lands here.
Your brute force is too slow →
Nested loops / itertools blowing up? Recognize the optimization problem and pick the model.
Linear programming (LP)
problem class →Resource / budget allocation →
Split a budget across options to maximize return — as an LP, not a grid search.
Transportation problem →
Ship from supplies to demands at minimum cost — as an LP, not a hand-rolled heuristic.
Diet problem →
Meet nutrient requirements at minimum cost — the original LP, in a few lines.
Blending problem →
Mix components to hit a quality spec at minimum cost — as an LP.
Quadratic programming (QP)
problem class →Mixed-integer linear (MILP)
problem class →Assignment problem →
Assign N workers to N tasks at minimum total cost — as a MILP, not O(n!) permutations.
Knapsack problem →
Pick the highest-value items within a weight budget — as a MILP, not 2^n subsets.
Job scheduling (makespan) →
Split jobs across machines to finish as early as possible — as a MILP, not M^n assignments.
Maximum independent set →
The largest set of vertices with no shared edge — as a MILP, proven optimal, not a greedy pass.
Traveling salesman (TSP) →
Shortest tour visiting every city once — as a MILP (MTZ), not (n-1)! permutations.
Bin packing →
Pack items into the fewest bins — as a MILP, proven optimal, not first-fit-decreasing.
Set cover →
Fewest sets that cover every element — as a MILP, proven optimal, not greedy.
Employee shift scheduling →
Cover each day’s staffing demand with the fewest workers — as a MILP.
Graph coloring →
Fewest colors so adjacent vertices differ (chromatic number) — as a MILP.
Facility location →
Which facilities to open + how to serve demand at min cost — as a MILP.
Vehicle routing (VRP) →
Route a capacity-limited fleet from a depot at min distance — as a MILP (CVRP).
Mixed-integer nonlinear (MINLP)
problem class →Nonlinear (NLP)
problem class →QUBO / Ising
problem class →PUBO (higher-order binary)
problem class →Want a guide for your problem class? Tell us what you're optimizing.