You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

未指定方法时scipy.optimize.minimize()默认使用的标准方法是什么?

Default Method for scipy.optimize.minimize() When No Method Is Specified

Great question—this is one of those easy-to-overlook details in the docs if you’re not digging into the underlying logic! Let me break down exactly what happens when you omit the method parameter:

When you don’t explicitly set method, minimize() automatically selects a default based on your problem’s structure (like bounds, constraints, or variable count):

  • Unconstrained problems (no bounds or constraints):
    • For problems with 1000 or fewer variables: The default is 'L-BFGS-B' (a memory-efficient quasi-Newton method ideal for medium-scale problems).
    • For problems with more than 1000 variables: It switches to 'SLSQP' (a sequential least squares programming method that handles larger scales effectively).
  • Problems with bounds but no constraints:
    • The default is always 'L-BFGS-B', since this method natively supports variable bounds without extra work.
  • Problems with any constraints (equality or inequality):
    • The default becomes 'SLSQP', as it’s the only built-in method that handles general constraints out of the box.

A quick edge case: For single-variable unconstrained problems, it’ll quietly use 'BFGS' instead of 'L-BFGS-B'—a simpler quasi-Newton method better suited for tiny scales.

If you want to verify this, you can look into the _select_default_method helper function in the scipy.optimize.minimize() source code—it’s where this automatic selection logic lives.


内容的提问来源于stack exchange,提问作者Chisq

火山引擎 最新活动