当前位置:网站首页>Supplement - example of integer programming
Supplement - example of integer programming
2022-07-27 16:31:00 【Exist ~ ~】
1. Will be nonlinear 0-1 The problem becomes linear 0-1 problem
- Example 1

First do variable replacement , hold y=x(1)x(2), Has the following relation :
x(1) + x(2) - 1 ≤ y ≤ x(1)
x(1) + x(2) - 1 ≤ y ≤ x(2)
So there is linearity 0-1 Planned as :
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 or 1, j = 1:3
y = 0 or 1
2. Assignment problem
- Example 2
One fleet has 8 Vehicles this 8 Cars are stored in different places , Captain wants Send one of them 5 Cars arrive at 5 Different construction sites to transport goods . Each car is stored The cost of transferring to the loading place is listed in the table 2 5, Ask which one to choose 5 Car transfer Where to ship the goods , In order to minimize the total cost of transferring each vehicle from the location to the loading location ?
remember c(i)(j) It means the first one j Car No. 1 is transferred to the loading place i The cost . introduce 0-1 Variable :
x(i)(j) = 1 It means the first one j Car No. 1 is transferred to the loading place i , conversely x(i)(j) = 0 It means the first one j Car No. 1 was not transferred to the loading place i.
establish 0-1 Integer programming model :
% Put two-dimensional decision variables Xij(i=1:5,j=1:8) Become a one-dimensional decision variable 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 That's ok 40 Zero matrix of columns
intcon=1:40; % One dimensional decision variables k The value of
for j=1:8 % Opposite operation
a(j,(j-1)*5+1:j*5) = 1;
end
b=ones(8,1); % 8 That's ok 1 Column is 1 matrix
Aeq=zeros(5,40);
for i=1:5 % Column operation
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 It's output 5 That's ok 8 Column matrices
Output is
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
The minimum total cost is y = 87
边栏推荐
- Chat skills
- Time series - use tsfresh for classification tasks
- OpenCV(四)——图像特征与目标检测
- Addition of large numbers
- Leetcode234 question - simple method to judge palindrome linked list
- Crmeb Pro v1.4 makes the user experience more brilliant!
- Draw circuit diagram according to Verilog code
- DRF learning notes (II): Data deserialization
- Coding technique - Global log switch
- SolidWorks Simulation曲线图属性设定
猜你喜欢
随机推荐
excel skill
字节跳动服务网格基于 Hertz 框架的落地实践
Two methods of generating excel table with PHP
DRF learning notes (I): Data Serialization
Web test learning notes 01
The new JMeter function assistant is not under the options menu - in the toolbar
OpenCV(二)——图像基本处理
Implementation of ByteDance service grid based on Hertz framework
TP5 query empty two cases
Nacos
Test novice learning classic (with ideas)
Mazak handwheel maintenance Mazak little giant CNC machine tool handle operator maintenance av-eahs-382-1
Chuanyin holdings disclosed that it was prosecuted by Huawei: a case has been filed, involving an amount of 20million yuan
firefox旧版本
知网、万方数据库免费下载论文------比连接学校内网速度快数倍不止(有的学校万方数据库不支持下载)
Redis简介与使用
Collection! 0 basic open source data visualization platform flyfish large screen development guide
C语言逆序输出字符串
Const summary
ADAMS中转动整个模型









