[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EV50HSEF0EYNAP6S5BTJ3V":3,"skill-same:01M7EV50HSEF0EYNAP6S5BTJ3V":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7EV50HSEF0EYNAP6S5BTJ3V","numerical-optimization",null,"Practical optimization — choosing algorithms, handling constraints, tuning, and diagnosing convergence failures.","TanNhatCMS\u002Fjarvis","TanNhatCMS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F113796420?v=4","01M753MV17KG5CD3152G3WQEQY","KietNT","01M7EKEDYVYQ6PWVJJMZ911VMX",0,"MIT","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-numerical-optimization\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: numerical-optimization\ndescription: Practical optimization — choosing algorithms, handling constraints, tuning, and diagnosing convergence failures.\ncategory: scientific\n---\n\n## Overview\n\nOptimization is everywhere in science: fitting models, designing\nexperiments, training ML, calibrating simulations. This skill covers\nselecting the right algorithm for the problem structure (smooth vs\nnon-smooth, constrained vs free, convex vs non-convex), setting up\nobjectives correctly (scaling, gradients), and diagnosing the failures\nthat waste weeks of compute.\n\n## When to use\n\n- Fitting a model to data (least squares, maximum likelihood)\n- Choosing between gradient-based, derivative-free, and global optimizers\n- Handling constraints: bounds, equalities, inequalities\n- Tuning hyperparameters or calibrating simulation parameters\n- Debugging an optimizer that stalls, diverges, or returns nonsense\n\n## Core concepts\n\n- **Problem taxonomy:** convex (one global minimum — use gradient methods confidently) vs non-convex (many minima — need global search or multi-start); smooth (gradients help) vs non-smooth\u002Fnoisy (derivative-free: Nelder–Mead, CMA-ES, Bayesian optimization).\n- **Gradient methods:** steepest descent (slow), conjugate gradient, (L-)BFGS (quasi-Newton, the default for smooth unconstrained problems), Newton (needs Hessians). Supply analytic or autodiff gradients — finite differences are slower and noisier.\n- **Constrained optimization:** bounds (L-BFGS-B), general constraints (SLSQP, trust-constr, augmented Lagrangian, interior-point). Reformulate when possible: log-transforms turn positivity into unconstrained problems.\n- **Global optimization:** basin-hopping, differential evolution, dual annealing, Bayesian optimization (expensive objectives) — for rugged landscapes; always follow with a local polish.\n- **Scaling:** optimizers assume ~O(1) variables; rescale parameters to similar magnitudes or the Hessian conditioning destroys convergence.\n- **Least squares structure:** separable linear\u002Fnonlinear parameters (variable projection), sparse Jacobians — exploit structure instead of treating everything as a black box.\n\n- **Automatic differentiation:** exact gradients at the cost of a function evaluation (JAX, autograd) — eliminates finite-difference noise entirely; the single biggest upgrade for gradient-based optimization of coded objectives.\n- **Stochastic optimization:** SGD and Adam for noisy\u002Flarge-scale objectives (machine learning) — the noise is a feature (escapes sharp minima); learning-rate schedules and batch sizes are the tuning knobs.\n- **Derivative-free for the truly black box:** Bayesian optimization builds a surrogate (Gaussian process) and explores efficiently — the method of choice when each evaluation costs minutes or dollars.\n\n## Practical workflow\n\n### 1. Formulate well\n\n```python\nfrom scipy.optimize import minimize\n# Scale variables to O(1); supply a gradient; bound what must stay physical\nres = minimize(fun, x0_scaled, jac=grad, method=\"L-BFGS-B\",\n               bounds=bounds, options={\"ftol\": 1e-10, \"maxiter\": 10000})\n```\n\n1. Define the objective precisely: what is minimized, over what variables, subject to what — write it mathematically before coding.\n2. Scale all variables to order unity; log-transform strictly positive parameters.\n3. Provide gradients (analytic or autodiff via JAX\u002Fautograd) — finite-difference gradients fail on noisy objectives.\n\n### 2. Choose the algorithm\n\n| Problem | First choice |\n|---|---|\n| Smooth, unconstrained | L-BFGS (with gradients) |\n| Smooth, bounds | L-BFGS-B |\n| Smooth, general constraints | trust-constr \u002F SLSQP |\n| Non-smooth, low-dim | Nelder–Mead |\n| Noisy\u002Fexpensive, low-dim | Bayesian optimization |\n| Non-convex, global search | Differential evolution → local polish |\n| Least squares | Levenberg–Marquardt \u002F trust-region reflective |\n\n### 3. Multi-start and validate\n\n1. For non-convex problems: multi-start from diverse initial points (Latin hypercube) — the best of many local optima beats one hopeful run.\n2. Check convergence: gradient norm small, constraints satisfied, objective stable across restarts.\n3. Validate the solution: does it make physical sense? Perturb the data slightly — stable solutions survive, overfit ones don't.\n\n### 4. Diagnose failures\n\n1. **Stalls immediately:** scaling (variables differ by 10⁶), bad gradient, or starting at a bound — check and rescale.\n2. **Hits maxiter without converging:** loosen tolerances for noisy objectives, or the landscape is flat — reparameterize.\n3. **Different answers per run:** non-convex landscape or stochastic objective — go global or multi-start; fix random seeds for reproducibility.\n4. **Constraint violations:** penalty weights too small, or the feasible set is empty — check feasibility first.\n\n### 5. Optimize an expensive black-box function\n\n1. Define tight bounds from physical plausibility — Bayesian optimization wastes evaluations exploring absurd regions otherwise.\n2. Choose the surrogate and acquisition function (expected improvement is the default); seed with a space-filling design (Latin hypercube, ~10 points per dimension).\n3. Run in batches where parallel evaluation is possible; stop on a budget (evaluations or time), not on a tolerance — expensive objectives never get tight tolerances.\n\n## Common pitfalls\n\n- **Unscaled variables:** the #1 convergence killer — a parameter in nanometers next to one in gigapascals breaks every quasi-Newton method.\n- **Finite-difference gradients on noisy objectives:** noise gets amplified into garbage search directions — use autodiff or derivative-free methods.\n- **Single start on non-convex problems:** finding a local minimum and declaring victory — multi-start is mandatory.\n- **Over-tight tolerances:** demanding 1e-12 on a noisy experimental objective wastes iterations chasing noise.\n- **Ignoring constraints in the formulation:** optimizing then clipping to bounds gives infeasible \"optima\" — constrain properly.\n- **Black-boxing structured problems:** least-squares and separable problems have specialized solvers 10–100× faster than generic ones.\n- **Optimizing a stochastic objective as if deterministic:** re-evaluating the same point gives different values — use noise-aware methods (replicated evaluations, stochastic kriging) or the optimizer chases noise.\n- **Ignoring integer\u002Fdiscrete variables:** rounding continuous optima to integers can be arbitrarily bad — use mixed-integer methods (or enumerate when the discrete space is small).\n","## Overview\n\nOptimization is everywhere in science: fitting models, designing\nexperiments, training ML, calibrating simulations. This skill covers\nselecting the right algorithm for the problem structure (smooth vs\nnon-smooth, constrained vs free, convex vs non-convex), setting up\nobjectives correctly (scaling, gradients), and diagnosing the failures\nthat waste weeks of compute.\n\n## When to use\n\n- Fitting a model to data (least squares, maximum likelihood)\n- Choosing between gradient-based, derivative-free, and global optimizers\n- Handling constraints: bounds, equalities, inequalities\n- Tuning hyperparameters or calibrating simulation parameters\n- Debugging an optimizer that stalls, diverges, or returns nonsense\n\n## Core concepts\n\n- **Problem taxonomy:** convex (one global minimum — use gradient methods confidently) vs non-convex (many minima — need global search or multi-start); smooth (gradients help) vs non-smooth\u002Fnoisy (derivative-free: Nelder–Mead, CMA-ES, Bayesian optimization).\n- **Gradient methods:** steepest descent (slow), conjugate gradient, (L-)BFGS (quasi-Newton, the default for smooth unconstrained problems), Newton (needs Hessians). Supply analytic or autodiff gradients — finite differences are slower and noisier.\n- **Constrained optimization:** bounds (L-BFGS-B), general constraints (SLSQP, trust-constr, augmented Lagrangian, interior-point). Reformulate when possible: log-transforms turn positivity into unconstrained problems.\n- **Global optimization:** basin-hopping, differential evolution, dual annealing, Bayesian optimization (expensive objectives) — for rugged landscapes; always follow with a local polish.\n- **Scaling:** optimizers assume ~O(1) variables; rescale parameters to similar magnitudes or the Hessian conditioning destroys convergence.\n- **Least squares structure:** separable linear\u002Fnonlinear parameters (variable projection), sparse Jacobians — exploit structure instead of treating everything as a black box.\n\n- **Automatic differentiation:** exact gradients at the cost of a function evaluation (JAX, autograd) — eliminates finite-difference noise entirely; the single biggest upgrade for gradient-based optimization of coded objectives.\n- **Stochastic optimization:** SGD and Adam for noisy\u002Flarge-scale objectives (machine learning) — the noise is a feature (escapes sharp minima); learning-rate schedules and batch sizes are the tuning knobs.\n- **Derivative-free for the truly black box:** Bayesian optimization builds a surrogate (Gaussian process) and explores efficiently — the method of choice when each evaluation costs minutes or dollars.\n\n## Practical workflow\n\n### 1. Formulate well\n\n```python\nfrom scipy.optimize import minimize\n# Scale variables to O(1); supply a gradient; bound what must stay physical\nres = minimize(fun, x0_scaled, jac=grad, method=\"L-BFGS-B\",\n               bounds=bounds, options={\"ftol\": 1e-10, \"maxiter\": 10000})\n```\n\n1. Define the objective precisely: what is minimized, over what variables, subject to what — write it mathematically before coding.\n2. Scale all variables to order unity; log-transform strictly positive parameters.\n3. Provide gradients (analytic or autodiff via JAX\u002Fautograd) — finite-difference gradients fail on noisy objectives.\n\n### 2. Choose the algorithm\n\n| Problem | First choice |\n|---|---|\n| Smooth, unconstrained | L-BFGS (with gradients) |\n| Smooth, bounds | L-BFGS-B |\n| Smooth, general constraints | trust-constr \u002F SLSQP |\n| Non-smooth, low-dim | Nelder–Mead |\n| Noisy\u002Fexpensive, low-dim | Bayesian optimization |\n| Non-convex, global search | Differential evolution → local polish |\n| Least squares | Levenberg–Marquardt \u002F trust-region reflective |\n\n### 3. Multi-start and validate\n\n1. For non-convex problems: multi-start from diverse initial points (Latin hypercube) — the best of many local optima beats one hopeful run.\n2. Check convergence: gradient norm small, constraints satisfied, objective stable across restarts.\n3. Validate the solution: does it make physical sense? Perturb the data slightly — stable solutions survive, overfit ones don't.\n\n### 4. Diagnose failures\n\n1. **Stalls immediately:** scaling (variables differ by 10⁶), bad gradient, or starting at a bound — check and rescale.\n2. **Hits maxiter without converging:** loosen tolerances for noisy objectives, or the landscape is flat — reparameterize.\n3. **Different answers per run:** non-convex landscape or stochastic objective — go global or multi-start; fix random seeds for reproducibility.\n4. **Constraint violations:** penalty weights too small, or the feasible set is empty — check feasibility first.\n\n### 5. Optimize an expensive black-box function\n\n1. Define tight bounds from physical plausibility — Bayesian optimization wastes evaluations exploring absurd regions otherwise.\n2. Choose the surrogate and acquisition function (expected improvement is the default); seed with a space-filling design (Latin hypercube, ~10 points per dimension).\n3. Run in batches where parallel evaluation is possible; stop on a budget (evaluations or time), not on a tolerance — expensive objectives never get tight tolerances.\n\n## Common pitfalls\n\n- **Unscaled variables:** the #1 convergence killer — a parameter in nanometers next to one in gigapascals breaks every quasi-Newton method.\n- **Finite-difference gradients on noisy objectives:** noise gets amplified into garbage search directions — use autodiff or derivative-free methods.\n- **Single start on non-convex problems:** finding a local minimum and declaring victory — multi-start is mandatory.\n- **Over-tight tolerances:** demanding 1e-12 on a noisy experimental objective wastes iterations chasing noise.\n- **Ignoring constraints in the formulation:** optimizing then clipping to bounds gives infeasible \"optima\" — constrain properly.\n- **Black-boxing structured problems:** least-squares and separable problems have specialized solvers 10–100× faster than generic ones.\n- **Optimizing a stochastic objective as if deterministic:** re-evaluating the same point gives different values — use noise-aware methods (replicated evaluations, stochastic kriging) or the optimizer chases noise.\n- **Ignoring integer\u002Fdiscrete variables:** rounding continuous optima to integers can be arbitrarily bad — use mixed-integer methods (or enumerate when the discrete space is small).\n",{"name":5,"category":24,"description":7},"scientific","main","af388a77c2fe5e0b4fd879cca4300a0ffa9a6579","skills\u002Fams-numerical-optimization",1,"https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis","https:\u002F\u002Fgithub.com\u002FTanNhatCMS","https:\u002F\u002Fmrkiet.name.vn","2026-11-07 14:23:08",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add TanNhatCMS\u002Fjarvis --skill numerical-optimization",{"tool":39,"command":40},"bunx","bunx skills add TanNhatCMS\u002Fjarvis --skill numerical-optimization",{"tool":42,"command":43},"pnpm","pnpm dlx skills add TanNhatCMS\u002Fjarvis --skill numerical-optimization","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-numerical-optimization\u002FSKILL.md",true,[],[48,55,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7EWYJR0J8DARY7E59Z6Y9MV","web-scrape","Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open\u002Ffetch fails on JS-heavy pages, or when you need clean markdown\u002Fstructured extraction from a site. Requires FIRECRAWL_API_KEY.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fweb-scrape\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7EWYBN5P6F2AJG3FR24T9BP","design-taste-frontend","tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML\u002FCSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, \"AI-made\", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7EWY8FQFNQ2GB7NZZWGSSDX","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-tdd\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7EWY5SHBFRH1HDHVWM9K7TV","systematic-debugging","Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-debugging\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7EWY3NM0Z0JAKS7HDZ24K66","requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-code-review\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7EWY0WRMWX4M9ZFY0WKC593","brainstorming","You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-brainstorming\u002FSKILL.md",[],[]]