当前位置:网站首页>补充—整数规划例题
补充—整数规划例题
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
边栏推荐
- The image displayed online by TP5 is garbled
- 2.2 JMeter基本元件
- DRF learning notes (preparation)
- DRF learning notes (V): viewset
- Nacos
- 第31回---第52回
- Common problems of mobile terminal H5
- C channel simply implements the publishing and subscription of message queue
- Addition of large numbers
- SolidWorks Simulation曲线图属性设定
猜你喜欢

ADAMS中转动整个模型

DRF learning notes (IV): DRF view

The whereor method of TP5 has many conditions

training on multiple GPUs pytorch

Test novice learning classic (with ideas)

Content ambiguity occurs when using transform:translate()

Text capture picture (Wallpaper of Nezha's demon child coming to the world)

MySQL index

Reduce PDF document size (Reprint)

CCF-201312-1
随机推荐
Multiline text overflow dotting
Excel提取重复项
Flowable process custom attribute
MySQL index
Some queries of TP5
201403-1
Nacos
gpt-2 文本生成
Google Chrome reversecaptcha ad blocking
测试新手学习宝典(有思路有想法)
mysql设置密码时报错 Your password does not satisfy the current policy requirements(修改·mysql密码策略设置简单密码)
Crmeb Pro v1.4 makes the user experience more brilliant!
Axure 安装图标字体元件库
Common problems of mobile terminal H5
Pointer summary
第21回---第30回
Pychart imports the existing local installation package
Pychart import existing project
DEX and AMMS of DFI security
How PHP changes a two-dimensional array into a one-dimensional array