Day3.整数规划之混合整数线性规划问题详解

语法

x = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub)

参数详解

f - 系数向量

intcon- 整数约束组成的向量,就说收到约束的整数个数

A-线性不等式约束矩阵

b-线性不等式约束向量

A * x ≤ b

Aeq - 线性等式约束矩阵

beq - 线性等式约束向量

Aeq * x = beq

lb - 下界

ub - 上界

lb ≤ x ≤ ub

案例一

 由题可以理解为:z = 8x1 + x2;受到关于x1和x2的限制

目标函数

f  = [8;1];%确定目标函数系统

编写目标函数向量和由整数变量组成的向量

intcon = 2;%理解为两个受到x受到整数限制

将所有的不等式转化为A*x ≤b的形式,然后编写代码

A = [-1 -2; -4 -1; 2 1];%构造不等式左边系数矩阵
b = [14; -33;20];%构造不等式右边矩阵

调用intlinprog

x = intlinprog(f,intcon,A,b)

matlab上运行

>> f = [8,1];
>> intcon = 2;
>> A = [-1 -2; -4 -1; 2 1];
>> b = [14 -33 20];
>> x = intlinprog(f,intcon,A,b)
LP:                Optimal objective value is 59.000000.                                            


Optimal solution found.

Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal
value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are
integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).


x =

    6.5000
    7.0000

案例二

 matlab运行

>> f = [-3 -2 -1];
intcon = 3;
A = [1 1 1];
b = [7];
Aeq = [4 2 1];
beq = [12];
lb = [0 0 0];
ub = [inf inf 1];
[x fval] = intlinprog(f,intcon, A ,b,Aeq ,beq,lb,ub)
LP:                Optimal objective value is -12.000000.                                           


Optimal solution found.

Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal
value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are
integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).


x =

         0
    5.5000
    1.0000


fval =

   -12

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值