title: 每日一题【20200723】
excerpt: 第三天建模打卡
tags: [数学建模, 线性规划, intlinprog, 0-1规划]
categories:
- [学习, 数学建模]
index_img: https://picture-store-repository.oss-cn-hangzhou.aliyuncs.com/PicGo/20201129201333.jpg
banner_img: https://picture-store-repository.oss-cn-hangzhou.aliyuncs.com/PicGo/20201129201333.jpg
date: 2020-07-24 11:11:11
comment: true
math: true
0-1 规划问题
用matlab求解下列 0-1 规划问题
$$max \ z=6x_1+2x_2+3x_3+5x_4$$
s.t.
$$3x_1-5x_2+x_3+6x_4\geq4$$
$$2x_1+x_2+x_3-x_4\leq3$$
$$x_1+2x_2+4x_3+5x_4\leq10$$
$$x_i=0或1,i=1,2,3,4$$
matlab代码:
c=[6 2 3 5]
intcon=[1 2 3 4]
a=[-3 5 -1 -6;2 1 1 -1;1 2 4 5]
b=[-4;3;10]
aeq=[]
beq=[]
lb=zeros(4,1)
ub=ones(4,1)
[x,val]=intlinprog(-c,intcon,a,b,aeq,beq,lb,ub)
x,val=-val
</code></pre>
<pre><code class="language-matlab line-numbers">matlab运行结果:
x =
1
0
1
1
val =
14