当前位置:网站首页>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
边栏推荐
- 201403-1
- Find active SQL connections in SQL Server
- Reduce PDF document size (Reprint)
- DRF learning notes (preparation)
- Coding skills - Global exception capture & unified return body & Business exception
- 大数相加
- Snowflake ID (go Implementation)
- DRF learning notes (II): Data deserialization
- DeFi安全之DEX与AMMs
- : 0xc0000005: an access conflict occurs when writing position 0x01458000 - to be solved
猜你喜欢

JSP Foundation

The image displayed online by TP5 is garbled

OpenCV(五)——运动目标识别

Web test learning notes 01

Yys mouse connector

For enterprise operation and maintenance security, use the cloud housekeeper fortress machine!

DRF learning notes (IV): DRF view

201403-1

jupyter 创建虚拟环境并安装pytorch(gpu)

Snowflake ID (go Implementation)
随机推荐
The method of inserting degree in word
字节跳动服务网格基于 Hertz 框架的落地实践
Is low code the future of development? On low code platform
Mazak handwheel maintenance Mazak little giant CNC machine tool handle operator maintenance av-eahs-382-1
C language programming (Third Edition)
Yys mouse connector
Gpt-2 text generation
Snowflake ID (go Implementation)
Web test learning notes 01
Excel extract duplicates
t5 学习
201403-1
Chuanyin holdings disclosed that it was prosecuted by Huawei: a case has been filed, involving an amount of 20million yuan
大数相加
Oracle 常用语句
2021-06-02
Chapter I Marxist philosophy is a scientific world outlook and methodology
Your password does not satisfy the current policy requirements (modify MySQL password policy setting simple password)
Paper_ Book
solidwork装配体导入到Adams中出现多个Part重名和Part丢失的情况处理