solvers
説明
は、autosolver
= solvers(prob
)prob
に対する既定のソルバーを返します。ここで、prob
は OptimizationProblem
オブジェクトまたは EquationProblem
オブジェクトです。prob
を解くには、既定のソルバーを呼び出す solve
を呼び出します。
また、[
は autosolver
,validsolvers
] = solvers(prob
)prob
に対する有効なソルバーのリストを返します。
例
既定のソルバーと有効なソルバーの特定
Rosenbrock 関数を目的関数として使用して最適化問題を作成します (制約付き非線形問題の解法、問題ベースを参照してください)。
x = optimvar("x",LowerBound=-3,UpperBound=3); y = optimvar("y",LowerBound = 0,UpperBound=9); obj = 100*(y - x^2)^2 + (1 - x)^2; prob = optimproblem(Objective=obj);
問題に対する既定のソルバーと有効なソルバーを求めます。
[autosolver,validsolvers] = solvers(prob)
autosolver = "lsqnonlin"
validsolvers = 1x10 string
"lsqnonlin" "lsqcurvefit" "fmincon" "ga" "patternsearch" "surrogateopt" "particleswarm" "simulannealbnd" "gamultiobj" "paretosearch"
既定のソルバーを使用して、問題を解きます。
x0.x = -2.1; x0.y = 2.2; [sol,fval] = solve(prob,x0)
Solving problem using lsqnonlin. Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
sol = struct with fields:
x: 1.0000
y: 1.0000
fval = 4.9503e-16
既定の lsqnonlin
の代わりに fmincon
を使用して、問題を解きます。
[sol,fval] = solve(prob,x0,Solver="fmincon")
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
sol = struct with fields:
x: 1.0000
y: 1.0000
fval = 1.9355e-13
入力引数
prob
— 最適化問題または方程式問題
OptimizationProblem
オブジェクト | EquationProblem
オブジェクト
最適化問題または方程式問題。OptimizationProblem
オブジェクトまたは EquationProblem
オブジェクトとして指定します。最適化問題は optimproblem
を使用して作成し、方程式問題は eqnproblem
を使用して作成します。
警告
問題ベースのアプローチでは、目的関数、非線形等式、または非線形不等式における複素数値をサポートしていません。関数の計算に複素数値が含まれていると、それが中間値としてであっても、最終結果が不正確になる場合があります。
例: prob = optimproblem; prob.Objective = obj; prob.Constraints.cons1 = cons1;
例: prob = eqnproblem; prob.Equations = eqs;
出力引数
autosolver
— prob
に対する既定のソルバー
string
prob
に対する既定のソルバー。string として返されます。既定のソルバーは、Solver
名前と値の引数を渡さずに solve
または prob2struct
を呼び出すと、これらの関数によって使用されます。
validsolvers
— prob
に対する有効なソルバー
string ベクトル
prob
に対する有効なソルバー。string ベクトルとして返されます。solve
または prob2struct
の呼び出しで Solver
名前と値の引数を指定すると、prob
に対する有効なソルバーのいずれかを使用できます。
有効なソルバーのリストは、ツールボックスのライセンスによって異なります。たとえば、Global Optimization Toolbox ライセンスをお持ちの場合は、有効なソルバーのリストに遺伝的アルゴリズム ソルバーの ga
が含まれています。
バージョン履歴
R2022b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)