showproblem
(非推奨) 最適化問題の表示
説明
例
最適化問題の表示
目的関数と制約を含む最適化問題を作成し、その問題を表示します。
混合整数線形計画法の基礎: 問題ベースの問題を作成します。
steelprob = optimproblem; ingots = optimvar('ingots',4,1,'Type','integer','LowerBound',0,'UpperBound',1); alloys = optimvar('alloys',4,1,'LowerBound',0); weightIngots = [5,3,4,6]; costIngots = weightIngots.*[350,330,310,280]; costAlloys = [500,450,400,100]; cost = costIngots*ingots + costAlloys*alloys; steelprob.Objective = cost; totalweight = weightIngots*ingots + sum(alloys); carbonIngots = [5,4,5,3]/100; carbonAlloys = [8,7,6,3]/100; totalCarbon = (weightIngots.*carbonIngots)*ingots + carbonAlloys*alloys; molybIngots = [3,3,4,4,]/100; molybAlloys = [6,7,8,9]/100; totalMolyb = (weightIngots.*molybIngots)*ingots + molybAlloys*alloys; steelprob.Constraints.conswt = totalweight == 25; steelprob.Constraints.conscarb = totalCarbon == 1.25; steelprob.Constraints.consmolyb = totalMolyb == 1.25;
問題を表示します。
showproblem(steelprob)
OptimizationProblem : Solve for: alloys, ingots where: ingots integer minimize : 1750*ingots(1) + 990*ingots(2) + 1240*ingots(3) + 1680*ingots(4) + 500*alloys(1) + 450*alloys(2) + 400*alloys(3) + 100*alloys(4) subject to conswt: 5*ingots(1) + 3*ingots(2) + 4*ingots(3) + 6*ingots(4) + alloys(1) + alloys(2) + alloys(3) + alloys(4) == 25 subject to conscarb: 0.25*ingots(1) + 0.12*ingots(2) + 0.2*ingots(3) + 0.18*ingots(4) + 0.08*alloys(1) + 0.07*alloys(2) + 0.06*alloys(3) + 0.03*alloys(4) == 1.25 subject to consmolyb: 0.15*ingots(1) + 0.09*ingots(2) + 0.16*ingots(3) + 0.24*ingots(4) + 0.06*alloys(1) + 0.07*alloys(2) + 0.08*alloys(3) + 0.09*alloys(4) == 1.25 variable bounds: 0 <= alloys(1) 0 <= alloys(2) 0 <= alloys(3) 0 <= alloys(4) 0 <= ingots(1) <= 1 0 <= ingots(2) <= 1 0 <= ingots(3) <= 1 0 <= ingots(4) <= 1
入力引数
prob
— 最適化問題または方程式問題
OptimizationProblem
オブジェクト | EquationProblem
オブジェクト
最適化問題または方程式問題。OptimizationProblem
オブジェクトまたは EquationProblem
オブジェクトとして指定します。最適化問題は optimproblem
を使用して作成し、方程式問題は eqnproblem
を使用して作成します。
警告
問題ベースのアプローチでは、目的関数、非線形等式、および非線形不等式における複素数値はサポートされていません。関数の計算に複素数値が含まれていると、それが中間値としてであっても、最終結果が不正確になる場合があります。
例: prob = optimproblem; prob.Objective = obj; prob.Constraints.cons1 = cons1;
例: prob = eqnproblem; prob.Equations = eqs;
ヒント
showproblem
は、次のすべてを呼び出す場合と等価です。showexpr
(prob.Objective
)showconstr
(prob.Constraints
の各制約に対して)showbounds
(prob
のすべての変数に対して)
多くの範囲または制約がある問題の場合は、
writeproblem
を使用して目的関数、制約、および範囲の情報を含むテキスト ファイルを生成します。
バージョン履歴
R2017b で導入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)