Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides MATLAB optimization: formulating problems with optimproblem, selecting and tuning solvers via optimoptions, and validating results.
Use this skill ↓77% 95%+18 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 17 of 22 without it.
I want to speed up a mixed-integer linear programming solve in MATLAB using intlinprog by adding 'UseParallel', true to optimoptions. Can you show me the correct code to set this option for intlinprog?
The response explains that UseParallel is not supported for intlinprog.
This test ran on v1. v2 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
The class you assign decides three things: which solver to use, what guarantee you can promise (global vs local), and how you'll verify. Getting this right is the highest-value step in the workflow.
Before formulating with optimproblem, check if a purpose-built tool exists for the user's domain. These tools encode domain structure (constraints, typical objectives, standard forms) that the generic path discards:
Portfolio, PortfolioCVaR, PortfolioMAD (Financial Toolbox)lqr, lqg, mpc (Control System Toolbox / Model Predictive Control Toolbox)sdo.optimize, Response Optimizer (Simulink Design Optimization)Method: search the doc for your domain keyword + "MATLAB" + "optimize" or "toolbox." If a tool exists, confirm it's licensed (ver / license('test', ...)) before committing to it.
| Class | Typical MATLAB solver | Guarantee at success |
|---|---|---|
| Linear program (LP) | linprog | Global optimum (convex) |
| Quadratic program (QP), convex | quadprog | Global optimum |
Quadratic program, nonconvex (indefinite H) | fmincon (NOT quadprog) | Local only |
| Second-order cone program (SOCP) | coneprog | Global optimum (convex) |
| Mixed-integer linear (MILP) | intlinprog | Global to a gap; NP-hard |
| Mixed-integer quadratic/nonlinear (MIQP/MINLP) | ga or surrogateopt with integer constraints | Heuristic (no proof) |
| Linear least squares | lsqlin, \ (mldivide) | Global optimum (convex) |
| Nonlinear least squares | lsqnonlin, lsqcurvefit | Local optimum |
| Smooth nonlinear (NLP) | fmincon, fminunc | Local optimum (global only if convex) |
| Nonsmooth / derivative-free | patternsearch, surrogateopt | Local; no gradients needed |
| Global (heuristic) | GlobalSearch, MultiStart, ga, particleswarm | Attempts global; no proof |
| Multi-objective | paretosearch, gamultiobj | Pareto set (no single optimum) |
| Equation solving | fsolve | A solution (not a minimum) |
Integer + nonlinear: intlinprog is linear-only. For integer variables with a nonlinear/quadratic objective or constraint, confirm ga/surrogateopt (Global Optimization Toolbox) are available, or reformulate to MILP.
eig(H) yourselfquadprog's convex algorithm cannot solve a nonconvex (indefinite-H) QP, but how it fails is not uniform: without bounds it refuses outright (negative exit flag); with finite bounds it may stall and return a positive flag at a non-optimal point (e.g., the saddle at the origin when the true boxed optimum is at a corner). A positive flag is NOT proof the QP was solved.
Robust move: test convexity up front with eig(H) — any negative eigenvalue means nonconvex. Route to fmincon (local) or reformulate.
Next to this one in the catalogue, plus more from the same author.