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
输入参数
优化问题或方程问题,指定为 OptimizationProblem 对象或 EquationProblem 对象。使用 optimproblem 创建优化问题;使用 eqnproblem 创建方程问题。
警告
基于问题的方法不支持在目标函数、非线性等式和非线性不等式中使用复数值。如果某函数计算具有复数值,即使是作为中间值,最终结果也可能不正确。
示例: prob = optimproblem; prob.Objective = obj; prob.Constraints.cons1 = cons1;
示例: prob = eqnproblem; prob.Equations = eqs;
提示
showproblem等效于调用以下所有各项:showexpr(prob.Objective)对
prob.Constraints中的每个约束调用showconstr对
prob中的所有变量调用showbounds
对于有许多边界或约束的问题,使用
writeproblem生成包含目标、约束和边界信息的文本文件。
版本历史记录
在 R2017b 中推出MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)