opttoolbox_mip1.m


opttoolbox_mip1.m


这个例子使用Matlab 2017b基于问题建模特性,%需要优化工具箱,来制定和解决以下%狗万app足彩简单的MIP模型,与mip1的模型相同。m % %最大化% x + y + 2 z % %服从% x + 2 y + 3 z <= 4% % x + y >= 1% % x, y, z binary % %m必须在当前%目录中或添加到Matlab路径x = optimvar('x', 'Type','integer','LowerBound',0,'UpperBound',1);y = optimvar('y', 'Type','integer','LowerBound',0,'UpperBound',1);z = optimvar('z', 'Type','integer','LowerBound',0,'UpperBound',1);概率= optimproblem(“ObjectiveSense”、“最大化”);概率。目标= x + y + 2 * z;prob.Constraints。con1 = x + 2 * y + 3 * z <= 4;prob.Constraints。con2 = x + y >= 1; options = optimoptions('intlinprog'); % For Matlab R2017b use the following % sol = solve(prob, options) % Syntax for R2018a and later sol = solve(prob, 'Options', options); end