第五章 匈牙利法与最佳指派问题
- 格式:ppt
- 大小:798.00 KB
- 文档页数:49
摘要在企业、公司的运营与管理中,管理者总是希望把人员最佳分派以发挥其最大工作效率,从而降低成本、提高效益。
然而,如果没有科学的方法是很难实现优化管理的,由此我们引入了指派问题。
指派问题多是求项目的工时最少,而很多情况下人们并不关心项目总工时的多少,而只关心项目能否在最短的时间内完成,即历时最少的指派问题。
这类问题研究的是n个人执行n项任务,执行每项任务的人数以及总的指派人项数均有限制,要求最优指派。
在运筹学中求解整数规划的指派问题通常是通过匈牙利算法来求解,但指派问题也可以归结为一个0-1整数规划问题,本文先对指派问题进行陈述,引出对实际问题的求解。
在指派问题的背景、描述中充分理解该问题,先运用匈牙利算法实现指派问题,然后再建立一个0-1整数规划模型,并运用matlab和lingo编译程序对问题进行编译,运用软件解决模型问题,最终实现指派问题在实际问题中的运用。
通过运用匈牙利算法和0-1整数规划同时对指派问题求解,我们发现用0-1整数规划的方法来求解可以更简单,也更方便程序的阅读和理解。
与此同时,我们还对0-1整数规划问题由整数数据深入研究到小数数据。
最后通过实例来说明运用matlab,lingo编译程序来解决整数规划问题的简便和有效性。
关键词:指派问题;匈牙利算法;0-1整数规划;matlab模型;lingo模型AbstractIn business, the company's operations and management, managers always want the best distribution of the staff to maximize their efficiency, reduce costs and improve efficiency. However, if there is no scientific method is difficult to achieve optimal management, which we introduced the assignment problem. Multi-assignment problem is to get the project working hours at least, and in many cases people do not care about how much the total project work, but only care about whether the project can be completed within the shortest possible time, that lasted for at least the assignment problem. Such problems is the n individual execution of tasks n, the number of people to perform each task and assign the total number of items are restricted to two people, requiring the optimal assignment. Integer programming in operations research for solving the assignment problem is usually solved by Hungarian algorithm, but the assignment problem can be reduced to a 0-1 integer programming problem, this paper first to make a statement on the assignment problem, leads to the solution of practical problems. Assignment problem in the background to fully understand the problem description, the first assignment problem using Hungarian algorithm, and then a 0-1 integer programming model and compiler using matlab and the lingo of the problem to be compiled using the software solution model problem Ultimately in the assignment of the application in practical problems. By using the Hungarian algorithm and the 0-1 integer programming to solve assignment problems simultaneously, we found that 0-1 integer programming method to solve a more simple and easier to read and understand the program. At the same time, we also 0-1 integer programming problem in-depth study by the integer data to a decimal data. Finally, an example to illustrate the use of matlab, lingo compiler to solve the integer programming problem is simple and effective.Keywords:assignment problem; Hungarian algorithm; 0-1 integer programming;matlab model; lingo model目录1. 问题陈述 (1)2. 指派问题的背景 (1)3. 指派问题的描述 (1)3.1 指派问题的一般形式 (1)3.2 问题的数学模型一般形式 (2)3.3 目标函数极大化的指派问题 (2)4.指派问题实现 (3)4.1 匈牙利算法 (3)4.1.1 匈牙利算法的理论基础 (3)4.1.2 匈牙利算法的实现步骤 (3)4.1.3 匈牙利算法实现指派问题 (4)4.2 0-1整数规划 (5)4.2.1 模型假设 (6)4.2.2 模型建立 (6)4.2.3 模型求解 (7)5. 问题的深入(0-1整数规划) (10)5.1 模型建立 (10)5.2 模型求解 (11)5.2.1 用matlab求解问题 (11)5.2.2 用lingo求解问题 (12)6. 结论 (14)6.1 总结概论 (14)6.2 具体分工.................................. 错误!未定义书签。
3.2 求解指派问题的匈牙利算法由于指派问题的特殊性,又存在着由匈牙利数学家D.Konig 提出的更为简便的解法—匈牙利算法。
算法主要依据以下事实:如果系数矩阵)(ij c C =一行(或一列)中每一元素都加上或减去同一个数,得到一个新矩阵)(ij b B = ,则以C 或B 为系数矩阵的指派问题具有相同的最优指派。
利用上述性质,可将原系数阵C 变换为含零元素较多的新系数阵B ,而最优解不变。
若能在B 中找出n 个位于不同行不同列的零元素,令解矩阵中相应位置的元素取值为1,其它元素取值为零,则所得该解是以B 为系数阵的指派问题的最优解,从而也是原问题的最优解。
由C 到B 的转换可通过先让矩阵C 的每行元素均减去其所在行的最小元素得矩阵D ,D 的每列元素再减去其所在列的最小元素得以实现。
下面通过一例子来说明该算法。
例7 求解指派问题,其系数矩阵为⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎣⎡=16221917171822241819211722191516C 解 将第一行元素减去此行中的最小元素15,同样,第二行元素减去17,第三行元素减去17,最后一行的元素减去16,得⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎣⎡=06310157124074011B 再将第3列元素各减去1,得⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎣⎡=****20531005711407301B 以2B 为系数矩阵的指派问题有最优指派⎪⎪⎭⎫ ⎝⎛43124321 由等价性,它也是例7的最优指派。
有时问题会稍复杂一些。
例8 求解系数矩阵C 的指派问题⎥⎥⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎢⎢⎣⎡=61071041066141512141217766698979712C 解:先作等价变换如下∨∨∨⎥⎥⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎢⎢⎣⎡→⎥⎥⎥⎥⎥⎥⎦⎤⎢⎢⎢⎢⎢⎢⎣⎡----- 2636040*08957510*00*0032202*056107104106614151214121776669897971246767 容易看出,从变换后的矩阵中只能选出四个位于不同行不同列的零元素,但5=n ,最优指派还无法看出。
指派问题匈牙利算法最大值
匈牙利算法(匈牙利算法,也被称为“插入-删除算法”或“排序算法”)是一种整数排序算法,在指派问题中可以将一个整数数组按照一定规则排序,使得所有指派中最大的元素出现的位置都不相同。
以下是匈牙利算法在解决指派问题的最大值问题的步骤:
1. 将数组分为两个部分,左半部分尽可能地小,右半部分尽可能地大。
2. 从右半部分开始,将一个元素与它的指派对象的最大值进行
比较。
如果两个元素之间的指派关系不符合要求,就将它们交换位置。
3. 接下来,从左边半部分开始,将一个元素与它的指派对象的最大值进行比较。
如果两个元素之间的指派关系不符合要求,就将它们交换位置。
4. 重复步骤2和步骤3,直到左半部分的最大值与右半部分的最大值相等。
5. 在最右半部分找到最大的元素,将它与左半部分的最大值交换。
6. 重复步骤1到步骤5,直到数组中的所有元素都被排序。
匈牙利算法的时间复杂度为O(nlogn),其中n为数组的长度。
在实际应用中,该算法通常用于小规模数据的排序,对于大规模数据的
排序则需要使用更高效的算法。