DBA3701 (DSC3214): Introduction to Optimization

AI 应用开发 × 算法面试题:业务场景实战 12 题【TopK、LRU、RRF 融合、相似度、限流算法,含手撕代码与底层答案】 本文聚焦AI应用岗算法面试新趋势,剖析12道融合业务场景的高频题:从海量日志中挖掘慢查询(分治+小顶堆)、亿级去重(布隆过滤器)、向量与关键词融合排序(RRF)、语义缓存设计(带租户隔离与TTL的LRU)到限流策略(令牌桶+滑动窗口),强调“场景复述→算法选型→手撕代码→生产落地”四步答题框架。突出考察点已从纯算法转向工程权衡、业务理解与系统设计能力,如误判容忍度、实时性与内存预算的平衡,助力开发者应对2026年真实技术挑战。 阅读详情

DBA3701 (DSC3214): Introduction to Optimization

Homework 2

Due: Sep 28, 2024

1.  (15 marks) Find all extreme points in the following polyhedra:

(a) F = {(x1, x2, x3, x4) : x1 + x2 + 2/1x3 ≤ 1, x1, x2, x3, x4 ≥ 0};

(b) F = {(x1, x2, x3) : x1 − x2 ≤ 1, x2 − x3 ≤ 1, x3 ≤ 1, x1, x2, x3 ≥ 0};

(c)

2.  (10 marks) Consider the following optimization problem:

max   10x1 + 12x2  + 12x3

s.t.    x1 + 2x2 + 2x3  ≤ 20

2x1 + x2 + 2x3  ≤ 20

2x1 + 2x2 + x3  ≤ 20

x1 , x2 , x3  ≥ 0.

(a) Write down the dual problem.

(b)  Suppose the optimal solution to the primal problem is x1   = x2   =  x3   =  4. Solve the optimal solution to the dual problem using complementary slackness condition.

3.  (15 marks) Portfolio Management Problem: Consider the following portfolio management problem. There are 100 stocks.  The expected return of stock i is ri  per dollar invested (which could be negative) and the total budget is b dollars, where b > 0. Ignoring the risk of the return, the problem of maximizing the total expected return is

where xi  denotes the amount of money invested in stock i.

(a) Write down the dual problem to the above linear programming problem.

(b) What is the optimal solution to the primal and the dual respectively?

(c) Verify the solution you provided in (b) is indeed optimal using the weak duality.

4.  (20 marks) A potter manufacturer can make four different types of dining room service sets:  JJP English, Currier, Primrose, and Bluetail.  Furthermore, Primrose can be made by two different methods. Each set uses clay, enamel, dry room time, and kiln time, and results in a profit shown in Table 1.

Table 1: Profit and resources consumed for each product

E

C

P1

P2

B

Capacity

Clay (lbs)

10

15

10

10

20

130

Enamel (lbs)

1

2

2

1

1

13

Dry room (hours)

3

1

6

6

3

45

Klin (hours)

2

4

2

5

3

23

Profit

51

102

66

66

89

The manufacturer is currently committed to making the same amount of Primrose using method 1 and method 2.  The formulation of the profit maximization problem is given below. The decision variables E,C, P1 , P2 , B are the number of sets of type English, Currier, Primrose Method 1, Primrose Method 2, and Bluetail, respectively. We assume, for the purposes of this problem, that the number of sets of each type can be fractional.

max   51E + 102C + 66P1  + 66P2  + 89B

s.t.    10E + 15C + 10P1  + 10P2  + 20B ≤ 130

E + 2C + 2P1 + P2 + B ≤ 13

3E + C + 6P1  + 6P2 + 3B ≤ 45

2E + 4C + 2P1 + 5P2 + 3B ≤ 23

P1  − P2  = 0

E,C, P1 , P2 , B ≥ 0.

The optimal solution to the primal is given in Table 2 and the optimal solution to the dual together with sensitivity information is given in Table 3. Use the information to answer the questions that follow.

Table 2: The optimal solution to the primal

Optimal Value

Objective Coefficient

E

0

51

C

2

102

P1

0

66

P2

0

66

B

5

89

Table 3:  The optimal solution to the dual and the sensitivity.   The last two columns describe the ranges of b for which the optimal dual solution remains the same

Dual Variable

Const. RHS

Allowable Increase

Allowable Decrease

Clay

1.429

130

153.33

86.25

Enamel

0

13

∞

9

Dry room

0

45

∞

17

Klin

20.143

23

28.60

19.50

Primrose Methods

11.429

0

3.50

0

(a) What is the optimal quantity of each service set, and what is the total profit?

(b)  Give an economic interpretation of the optimal dual variables appearing in the sensitivity report, for each of the five constraints.

(c)  Should the manufacturer buy an additional 20 lbs.  of Clay at $1.1 per pound?

(d)  In the current model, the number of Primrose produced using method 1 was required to be the same as the number of Primrose produced by method 2. Consider a revision of the model in which this constraint is replaced by the constraint P1  − P2   ≥  0.   In the reformulated problem would the amount of Primrose made by method 1 be positive?

5.  (20 marks) Diet Problem: The “diet  problem”  concerns with finding a mix of foods that satisfies requirements on the amount of nutrition.  We consider here the problem of choosing fruits to meet certain nutritional requirements. The nutrition information of five selected fruits is provided in Table 4 along with a minimum required and maximum allowed intake of each type of nutrition in the last two columns. Your goal is to find the cheapest combination of fruits that will meet nutritional requirements.

(a)  Formulate a mathematical model for this problem. Solve the problem using Python and attach your code. Present and interpret the results.

Table 4: Nutrition and price information per 100 grams

Apple Banana Blueberries Durian Tangerine

Min Reqd Max Allowed

Calories

Carbohydrate (g)

Fiber (g)

Vitamin A (IU) Vitamin C (mg)

52 14 2.4 54 4.6

89 23 2.6 64 8.7

57 14 2.4 54 9.7

147 27 3.8 44 19.7

53

13

1.8

681

26.7

500

50

20

2000

75

3000

400

30

3500

150

Price (S$/100g)

0.5 0.3 2.5 10 0.5

(b) Without solving the problem using the software, can you determine how your optimal solution and optimal spending in (a) will change if you are also con- cerned with the total fat intake.  The fat contained in each of the fruit and your nutrition requirement on fat is provided in the table below.  Verify your solution by solving the problem numerically.

Apple Banana Blueberries Durian Tangerine

Min Reqd Max Allowed

Fat (g)

0.2 0.3                  0.3 5                  0.3

0 10

6.  (20 marks) Pricing Problem: Consider a retailer with an initial inventory of 2000 units of a single fashion item.  The retailer needs to sell his inventory over a time horizon of 15 weeks by employing in order the four price levels:  $60 (full price), $54 (90% discount), $48 (80% discount), $36 (60% discount) over time. The estimated average demands under these price levels are summarized in the following table.

Any left over items at the end of the selling season can be sold to outlet for $25 per

Table 5: Estimated demand under each price

Price $60 $54 $48 $36

Demand 125 162.5 217.5 348.8

unit (salvage value). The retailer is required to start with the full price for at least one week and then he is allowed to decrease his prices over time. The retailer seeks to maximize the total revenue during the selling horizon (including salvage value) by determining the timing and magnitude of the markdowns.  Answer the following questions and attach the codes you used to derive the solutions.

(a) Formulate the problem as a linear program and report your solution.  (Hint: Let xi  be the number of weeks that price i,i = 1, 2, 3, 4 is used, and we allow fractional weeks here.)

(b) What is the shadow price associated with the initial inventory level?  Resolve your model by increase the initial inventory level to 2001.  Does your profit increase by the same amount as the shadow price indicated? Explain why.

(c)  Suppose in order to maintain the brand reputation, the retailer is only allowed to discount from week 4.  Will the retailer change his markdown strategy in this case?

(d) In the traditional brick-and-mortar business, menu cost and consumer price impression are the two major reasons behind the very few number of price levels. With the rise of e-commerce and other technologies, it is possible for the retailer to employ more price levels and change the price more frequently. In the above problem, what happens if the retailer employs the following price grids (with a grid of $2) instead of a few discount levels?  For simplicity, the demand estimates at the additional price levels are taken as a linear interpolation of the original demands (see the table below).  What is the improvement in revenue compared to the benchmark?  What is the new markdown policy?  How do you compare with the original policy?

Table 6: Price grids model

Price        $60    $58    $56     $54      $52     $50      $48     $46      $44      $42     $40     $38    $36

Demand   125   137.5   150   162.5   180.8   199.1   217.5   239.4   261.3   283.2   305.1   327   348.8

C++ 极致工程美学:拆解 Meta Faiss 量化器的 AVX2 向量化与有偏收缩算法 在 Meta 向量检索库 Faiss 的头文件 内部,标量量化器为反量化系数预留了两个并列枚举:无偏(UNBIASED)与有偏(BIASED)。按照经典数理统计教材的直觉惯性,无偏估计一向被奉为无损推断的金科玉律;但在 100 万条 768 维真实特征向量的检索压测中,把缩放模式切到有偏估计后,重构均方误差(MSE)稳定下降 19.60%,P99 长尾失真压低 35.05%,最大极端离群误差更是被削减了 81.46%。向量检索面对的是单次离散几何判决,没有任何大数定律能抹平单次重构方差。本文聚焦 Fais 阅读详情

相关推荐

Tiff、jpg图片怎么样添加地理坐标信息

Tiff、jpg图片怎么样添加地理坐标信息 一般,外业调查只有地图资料,如专题图、或者地形图,如何把这些地图资料的扫描地图带上坐标信息,从而内业实现信息化处理?以上问题,可以解决,但根据不同情况有不同的处理方法。     第一种,上面有经纬度外框,图片是矩形,但是没有地理信息。 通过图框的两个角的坐标确定范围,分别是左上(140°E,30°N);右下(150°W,30°N) 解决方

树木_xzw的博客 2万+

【算法拾光】队列|在每个树⾏中找最⼤值 + 最后⼀块⽯头的重量

本文总结两道经典算法题:一是通过层序遍历(BFS)逐层找最大值,利用队列分层处理,每层维护最大值;二是用大根堆(优先队列)模拟石头碰撞过程,每次取最大两块石头,差值重新入堆,直至剩余一块或无石。前者适用于树的层次遍历,后者适合动态获取最值场景。核心思想:队列用于分层遍历,堆用于高效取极值。

wuqingyigexiaoba的博客 194

Windows平台高效BLE调试工具开发指南

本文为开发者提供了一份在Windows平台上开发高效BLE调试工具的详细指南。文章深入探讨了使用32feet.NET库进行蓝牙低功耗设备扫描、连接、数据通信及进阶功能开发的实战经验,旨在帮助开发者打造功能自定义、性能优化的专属调试利器,显著提升物联网和嵌入式设备的调试效率。

weixin_29201933的博客 260

把 KV Cache 压到 FP4:BitDecoding-FP4 的算法-系统协同设计复盘

长上下文推理卡在KV Cache的显存与带宽上,而现有FP4方案要么精度崩、要么速度废。这篇文章复盘BitDecoding-FP4如何用三个算法补丁加一个系统重构,在B300上把服务吞吐提升2.4–3.0倍,精度几乎不掉。

helloagent的博客 317

新装Win10/Win11后VMware虚拟机连不上网?手把手教你排查‘网络信息不可用’(从服务检查到网段配置)

本文详细介绍了在Windows 10/11系统上安装VMware Workstation后虚拟机无法联网的排查方法。从检查VMware NAT Service、DHCP Service等关键服务状态,到重置虚拟网络编辑器配置,再到内核设备驱动问题解决,手把手教你解决‘网络信息不可用’问题。特别针对VMCI驱动故障提供了实用解决方案,帮助用户快速恢复虚拟机网络连接。

weixin_28736335的博客 773

影刀RPA之成绩批量查询系统

自动化登录账号,读取数据表中内容去填写信息去查询,并判断多个数据不同的页面去不同的读取查询结果内容,如考生各项信息与各科成绩,总分和查询时间,采集出来到指定的数据表格中,等待时间并依次循环运行。主要功能。

2201_75330891的博客 1086

【算法拾光】链表 哈希表|K个一组翻转链表 + 两数之和

K个一组翻转链表需分段反转,借助哑节点与前驱指针维护连接,避免断链;两数之和利用哈希表实现O(1)查找,空间换时间,高效定位目标组合。前者考察链表指针操作,后者聚焦映射关系构建,均为面试高频题。

wuqingyigexiaoba的博客 337

Linux【实战】—— LAMP环境搭建 & 部署网站

由LinuxApacheMySQLPHP组成的一个web网络平台。

2201_75935630的博客 4981

排序算法深度笔记(下):非比较类排序的线性突破与工程边界

排序算法时间复杂度额外空间复杂度稳定性是否基于比较选择排序O(N^2)(O(1))不稳定是冒泡排序O(N^2)(O(1))稳定是插入排序O(N^2)(O(1))稳定是归并排序O(N\log N)(O(N))稳定是快速排序O(N\log N)O(log N)不稳定是堆排序O(N\log N)O(1)不稳定是计数排序(O(N + M))O(M))稳定否基数排序O(N)稳定否桶排序平均O(N) / 最坏O(N^2)

2401_87069538的博客 615

手把手教你解决uniapp中esbuild版本冲突问题(Mac版专属指南)

本文是针对Mac平台uniapp开发者的专属指南,详细解析了运行项目时常见的`Cannot start service`错误,即esbuild的Host版本与binary版本不匹配问题。文章从错误根源入手,提供了从快速应急处理到彻底根治的完整解决方案,包括手动替换二进制文件、锁定依赖版本、清理缓存及优化工具链配置,旨在帮助开发者高效解决版本冲突,恢复并稳定开发环境。

i0j1k2l3m的博客 460

RK3399平台开发系列讲解(内核入门篇)1.1、通过sysfs清楚了解设备的系统状况

文章目录1、不敢高声语,恐惊天上人:sysfs目的2、窥一斑而知全豹:sysfs目录介绍3、千丝万缕:sysfs中要素的关系4、数据观星:sysfs中相关结构体 1、不敢高声语,恐惊天上人:sysfs目的 我们想通过sys下面的目录和文件清楚的了解跑Liunx系统的嵌入式设备的系统状况。 2、窥一斑而知全豹:sysfs目录介绍 sysfs把连接在系统上的设备和总线组织成为一个分级的文件,它们可以由用户空间存取,向用户空间导出内核的数据结构以及它们的属性。sysfs的一个目的就是展示设备驱动模型中各组件.

内核笔记 1万+

优选算法:分治-归并排序

交易逆序对的总数

Wangshijie1015的博客 151

【32】C# WinForm入门到精通 ——打开文件OpenFileDialog 【属性、方法、事件、实例、源码】

本文介绍了WinForm开发中OpenFileDialog控件的关键属性及其应用。OpenFileDialog是.NET Framework提供的文件对话框控件,主要用于选择、打开文件操作。文章详细讲解了11个核心属性:AddExtension(自动补全扩展名)、AutoUpgradeEnabled(外观升级)、CheckFileExists/CheckPathExists(文件/路径存在验证)、DefaultExt(默认扩展名)、DereferenceLinks(解析快捷方式)、FileName/File

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 1535

408 算法 06|堆与 Top-K:最小的 10 个数,到底该用数组还是堆

2022(42) 找 100 万个数里最小的 10 个,官方给了"10 元素有序数组"和"大根堆"两种答案。我把两种都实现并数了比较次数:k=10 时两者几乎打平,k=10000 时堆少 111 倍。另附 2021(42) 计数排序的比较次数与稳定性实测。

m0_56226131的博客 451

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

牛客周赛165C题(前后缀性质,递推,排序,枚举)

题目大意:给定长度为 `n` 的数组,选择 `k ∈ [1,n]`,将前 `k` 个元素整体翻转,后面的元素不变。要求操作后的整个数组非递减,统计满足条件的 `k` 的数量。题目链接:https://ac.nowcoder.com/acm/contest/141721/C。时间复杂度:O(nlogn)

2501_94316951的博客 175

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

算法64,字母异位词分组

代码核心思路是:互为字母异位词的字符串,在对其字符进行排序后,一定会得到相同的字符串。因此,可以将排序后的字符串作为哈希表的键(Key)来进行分组。

sheshibenniaodan的博客 219

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

408 算法 04|主元素与三元组最小距离:两种“扫描时做决定“的思路

2013(41) 的主元素用摩尔投票一遍选出候选,但真正的考点是"选完必须验票";2020(41) 的三元组最小距离,三指针每次只挪最小的那个,靠的是 D=2×(max−min) 这个恒等式。两套完整 C 代码加真实输出,附官方评分档位表。

m0_56226131的博客 444

【MPC 算法】Python 实战:模型预测控制(MPC)算法原理与代码实现

本文介绍模型预测控制(MPC)原理与Python实现。MPC通过滚动优化预测未来状态,结合系统模型、目标函数与约束条件,动态生成最优控制序列。以一阶温度系统为例,使用CVXPY构建凸优化问题,实现加热功率的智能调控。代码包含模型预测、目标函数设计(含温度跟踪与控制平滑惩罚)、输入约束及滚动更新机制。仿真结果表明,MPC能快速稳定温度至目标值60℃,且控制动作平滑合理,体现其在复杂系统中的优越性。

赖德发的博客 67

算法61,判定是否为字符重排

两字符串能互为重排 ⇔。

sheshibenniaodan的博客 226

【前缀和+复合离散化】题解:双色矩形(two)_数据结构_算法优化_预处理_二维前缀和_STL_C++算法竞赛

给定一个 $n \times n$ 的黑白棋盘,初始按 $i+j$ 奇偶染色,经 $k$ 个格子颜色翻转后,求子矩形中黑白格子数差的绝对值最大值。由于 $n$ 可达 $10^9$,但 $k \leq 50$,可离散化关键点。枚举所有由修改点构成的矩形及其四边向外扩展(共 $16$ 种扩展方式),利用二维前缀和快速计算变化量,结合奇偶性判断多出的格子颜色,最终取最大绝对差。时间复杂度为 $O(k^4)$,在 $k \leq 50$ 下可行。

YLCHUP的博客 213

算法62&&63,存在重复元素

判断整数数组中是否有任意元素出现至少两次。:判断数组中是否存在两个。,且索引差值的绝对值。

sheshibenniaodan的博客 105

商业综合体公摊电费分摊算法:512 商户双层权重与尾差实测

公摊电费分摊算法是指把公共回路电量按公示权重拆到每户的规则化计算过程,核心不是权重多精巧,而是每张账单都能被租户手算复现。某珠三角商业综合体 512 户商户实测:固定费与变动费按 4:6 加权,尾差用余数递补压到 0.01 千瓦时精度,24 个月 12288 张账单重算差异为零,月度争议从 31 起降到 2 起。适用边界:商铺与租户已独立装表、公共回路已分项计量的商业综合体适用;末端未装表、靠总表减合计倒推公摊的场景不适用,先把表补齐再谈分摊。

185

考拉兹猜想 - 7

本文通过引入虚数单位重构Collatz猜想的迭代逻辑,指出偶数减半与奇数“乘3加1”的过程在虚数坐标下等价于归结操作。关键在于:乘3加1使奇数跃升至偶数,随后持续减半,而虚数单位代表“无限减1”,实现无限向有限的转化。无论初始值如何,减半始终主导,最终归结为4-2-1循环。该视角消解了正向思维中的速度竞争疑虑,证明归结是必然结果。

杨铸人的博客 92

2026华为OD机试真题 10月14日 新系统 【分组字符串排序】

华为OD机试真题 新系统【分组字符串排序】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【分组字符串排序】多语言题解。

qq_45776114的博客 458

贪心题目:可以到达的最远建筑

为了到达尽可能远的建筑物,在将砖块替换成梯子时,应将高度差最大位置的砖块替换成梯子,此时剩余的砖块数量最多,如果将高度差较小位置的砖块替换成梯子,则剩余的砖块数量较少,能到达的最远建筑物下标不可能更大。开始向后面的建筑物移动,移动过程中维护优先队列存储正高度差,优先队列的队首元素是最大元素,每次遇到正高度差时优先考虑使用砖块,如果砖块数量不够则使用梯子替换最大高度差位置的砖块,直到砖块和梯子都使用完毕时,到达的建筑物即为最远建筑物。如果以最佳方式使用给定的梯子和砖块,返回可以到达的最远建筑物的下标。

stormsunshine的博客 299

强化学习第十一课:完整 Q-Learning 算法

表示有:\[ 5 \]0 1 2 3 40:向左1:向右目标位置:\[ 4 \]

qq_56657939的博客 328
上一篇: DATA1002 / 1902 - Informatics: Data and Computation
下一篇: SYB61 T03 Urban areas and Capital
vx___codinghelp
博客等级 码龄2年 778粉丝 101原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值