当前位置:网站首页>Week 13 summary blog (week 15 of the school calendar) dynamic planning summary
Week 13 summary blog (week 15 of the school calendar) dynamic planning summary
2022-06-21 17:21:00 【Mt. Qomolangma】
One :01 knapsack
This is the basic knapsack problem , Characteristic is : There is only one item of each kind , Take , Or not .
use F[i,v] Before presentation i Put one item into a container with a capacity of v The maximum value that you can get from your backpack . Before i The capacity of items is v The schemes in the backpack can be divided into two categories : Don't select the second i And select the i Pieces of , Thus the state transition equation can be obtained :
F[i,v]=max{F[i-1,v], F[i-1,v-C[i]]+W[i]}
F[0, 0..V] = 0
for i = 1 to N
for v = C[i] to V
F[i,v] = max{F[i-1, v], F[i-1, v-C[i]] + W[i]}
The time and space complexity are O(N*V), Among them, the time complexity can no longer be optimized Changed , But the space complexity can be optimized to O(V)
F[0..V] = 0
for i = 1 to N
for v = V to C[i]
F[v] = max{F[v], F[v-C[i]] + W[i]}
v Perform the decreasing cycle guarantee calculation F[i,v] when , F[i-1,v-C[i]] No first i Items selected into , from And make sure you only choose one item
Two : Complete knapsack problem
This question is very similar to 01 knapsack problem , The difference is that each item can take 0 Pieces of 、 take 1 Pieces of 、 take 2 Pieces of ……, Until ⌊V /C[i]⌋ Pieces, etc .
If you still follow the solution 01 The idea of backpacking , Make F[i,v] Before presentation i Put items into a container The quantity is v The maximum weight of the backpack , It is still possible to follow paragraph i Write the following state transition equation for the strategy of selecting or not selecting items :
F[i,v]=max{f[i-1,v-kC[i]]+kW[i]|0<=kC[I]<v}
But the implementation complexity of this method is relatively high .
F[0..V] = 0
for i = 1 to N
for v = C[i] to V
F[v] = max(F(v), F[v-C[i]] + W[i])
3、 ... and : Multiple backpack
(1) Binary optimization
(2) Monotonic queue optimization
I feel it is very difficult to see the dynamic planning problem , puff . Plus, I've been busy doing other things this week , A big mistake , I don't learn much by myself , Feeling of poverty . Next week we will find more time to learn algorithms .
边栏推荐
- Move Protocol Beta测试版稳定,临时决定奖池规模再扩大
- Unittest框架
- Ares阿瑞斯i质押LP挖矿众筹模式dapp智能合约定制
- [mathematical modeling] Matlab Application Practice Series (95) - application cases of time series prediction (with matlab code)
- 第13周总结博客(校历第15周)动态规划总结
- 力扣解法汇总1108-IP 地址无效化
- gp中的decode函数实现
- 一体化伺服电机与施耐德PLC TM241CEC24T在Canopen协议下的应用
- Unittest framework
- 期货农产品开户怎么开?手续费是多少?
猜你喜欢
随机推荐
叩富网可以开期货账户吗?安全吗?
接口自动化加解密
7 tips for writing effective help documents
海外new things | 软件开发商「Dynaboard」种子轮融资660万美元,开发低代码平台连接设计、产品和开发人员
Previous installation records
自然科学的根本任务
很多软件公司,其实都是“笑话”
Test log of unittest framework
Comparison of UDP and TCP
【mysql学习笔记19】多表查询
Set up your own website (11)
The Google play academy team PK competition officially begins!
[learn FPGA programming from scratch -38]: Advanced - syntax - functions and tasks
建立自己的网站(11)
三色标记清除法
tinymce.init()浏览器兼容问题
Vector data download for mainland and global epidemic data, based on geo JSON to SHP
模板:P6114 【模板】Lyndon 分解&Runs(字符串)
Detailed explanation of Fisher information quantity detection countermeasure sample code
uni-app框架学习笔记









