当前位置:网站首页>补充—整数规划例题
补充—整数规划例题
2022-07-27 14:46:00 【存在~~】
1.将非线性0-1问题转成线性0-1问题
- 例题1

先做变量替换,把y=x(1)x(2),有如下关系:
x(1) + x(2) - 1 ≤ y ≤ x(1)
x(1) + x(2) - 1 ≤ y ≤ x(2)
从而有线性0-1规划为:
max z = x(1) + y - x(3)
s.t.:
-2x(1) + 3x(2) + x(3) ≤ 3,
x(1) + x(2) - 1 ≤ y ≤ x(1),
x(1) + x(2) - 1 ≤ y ≤ x(2),
x(j) = 0 或 1, j = 1:3
y = 0 或 1
2.指派问题
- 例题2
一车队有8辆车 这8辆车存放在不同的地点,队长要 要派其中5辆到5个不同的工地去运货。各车从存放 处调到装货地点所需费用列于表2 5,问应选用哪5辆车调 到何处去运货,才能使各车从所在地点调到装货地点所需的总费用最少?
记c(i)(j)表示第 j 号车调到装货地点 i 所需的费用。引入0-1变量:
x(i)(j) = 1表示第 j 号车调到装货地点 i ,反之x(i)(j) = 0表示第 j 号车没有被调到装货地点 i。
建立0-1整数规划模型:
% 将二维决策变量Xij(i=1:5,j=1:8)变为一维决策变量yk(k=1:40)
clc,clear
c = [30,25,18,32,27,19,22,26
29,31,19,18,21,20,30,19
28,29,30,19,19,22,23,26
29,30,19,24,25,19,18,21
21,20,18,17,16,14,16,18];
c=c(:);
a=zeros(8,40); % 8行40列的零矩阵
intcon=1:40; % 一维决策变量中k的取值
for j=1:8 % 对行操作
a(j,(j-1)*5+1:j*5) = 1;
end
b=ones(8,1); % 8行1列的为1矩阵
Aeq=zeros(5,40);
for i=1:5 % 对列操作
Aeq(i,i:5:40) = 1;
end
beq=ones(5,1);
lb=zeros(40,1);
ub=ones(40,1);
[x,y] = intlinprog(c,intcon,a,b,Aeq,beq,lb,ub);
x = reshape(x,[5,8]),y % reshape是输出5行8列矩阵
输出为
x =
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 1 0 0
最低总费用为 y = 87
边栏推荐
- Characters generated by JMeter function assistant in jmeter5.3 and later versions cannot be copied when they are grayed out
- Addition of large numbers
- Find active SQL connections in SQL Server
- Time series ARIMA model
- Solve the problem that Flink cannot be closed normally after startup
- Vant UI toast and dialog use
- Common Oracle statements
- firefox旧版本
- 编码技巧——全局异常捕获&统一的返回体&业务异常
- Paper_ Book
猜你喜欢

Mysql5.7 master-slave hot standby settings on CentOS

DRF learning notes (V): viewset

Draw circuit diagram according to Verilog code

Pychart import existing project

The image displayed online by TP5 is garbled

插入word中的图片保持高dpi方法

收藏!0基础开源数据可视化平台FlyFish大屏开发指南

Crmeb Pro v1.4 makes the user experience more brilliant!

: 0xc0000005: an access conflict occurs when writing position 0x01458000 - to be solved

Content ambiguity occurs when using transform:translate()
随机推荐
Personal perception of project optimization
2.2 JMeter基本元件
Flume incrementally collects MySQL data to Kafka
第21回---第30回
Draw circuit diagram according to Verilog code
字节跳动服务网格基于 Hertz 框架的落地实践
centos yum方式安装mysql
google chrome revercecaptcha广告屏蔽
excel skill
What is ti's calculation for successively canceling the agency rights of anfuli / Wenye / Shiping?
SolidWorks simulation curve attribute setting
测试新手学习宝典(有思路有想法)
Common tool classes under JUC package
Notes on implementation and acquisition of flowable custom attributes
MapReduce instance (III): data De duplication
Introduction to JWT
Flowable process custom attribute
TP5 -- query field contains a certain --find of search criteria_ IN_ SET
const小结
C channel simply implements the publishing and subscription of message queue