ComputerKnowledgeand Technology 电脑知识与技术第10卷第10期 (2014年4月) 计算机工程应用技术本栏目责任编辑:梁 书 基于动态规划的商品装载问题及JAVA实现顾桓瑜 (大连交通大学 软件学院,辽宁 大连116052) 摘要:如何装载商品使经济利益最大化是物流配载装箱问题中划分出的子问题。该子问题被抽象为0-1背包问题,根据动态规划算法建立数学模型,分析其优点,并用JAVA语言得以实现。最后给出测试实例,得出动态规划法具有高效性的特点,该算法可以广泛使用于物流领域。关键词:动态规划;装载问题;JAVA语言 中图分类号:TP31 文献标识码:A 文章编号:1009-3044(2014)10-2401-03 Implementing Dynamic Programming Problem of Loading Goods in JAVA Language GU Huan-yu (College of Software, Dalian Jiaotong University, Dalian 116052, China) Abstract: How to load goods to get maximum economic benefits by manufacturers is a sub-problem divided from logistics dis⁃tribution.In this paper,the sub-problem is abstracted a 0-1 knapsack problem.We create a mathematical model based on dynamic programming algorithm,and analyze the advantages of the algorithm.Then we use JAVA language to solve the problem.After set⁃ting some test datum, the final results show that the dynamic programming method has efficiency,and can be applied widely. Key words: Dynamic programming; Loading problems; JAVA language 随着经济的不断发展,各厂商在满足客户需求的条件下,利用物流技术,从备货、装箱、配送、存储等物流配载技术网中寻求省 时省力的方法,使得资源使用效率得到提高,同时降低了厂商的成本[1]。问题提出:某厂商每周向校园超市运输一次商品,在小型货车容量不变且不能超载的约束下,如何装载商品,使产生的经济效益最大化?该问题是厂家所关心的,也是本文的关注点。运用动态规划方法解决此问题,能够较好地控制企业的人力资源成本和运输成本,从而提高商业的竞争力。 1 动态规划算法简介 动态规划(dynamicprogramming)[2]产生于20世纪50年代,由美国数学家R.E.Bellman等人提出。动态规划的思想是把一个问题 划分为具有相关性的若干子问题来解决,并将各个子问题求解答案和求解方法进行保存。如果在之后的处理过程中还需要用到已解决的子问题,则直接调用答案,从而避免重复的计算,节省了时间。 在解决实际问题中,我们需要动态规划出适当的约束条件和递推关系,并在各单阶段中寻找互相联系的因素,依次将每一阶段所得的最优结果进行存储。