失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 运筹学到底是啥玩意?

运筹学到底是啥玩意?

时间:2022-02-21 06:07:43

相关推荐

运筹学到底是啥玩意?

哈喽,各位大佬好,我是小明哥,初次实际遇到这个概念是在某次面试中,面试官说他们需要运筹学的相关人员来解决家居布置的问题(到达最优,但我不知道怎么才算最优,不知道label,所以有点懵逼),当时我对陌生的东西很畏惧(其实这是个本能反应),当时说,我不会,结果挂了。

any question could be solved in qq group868373192

看了下百度百科,运筹学就有这种问题,总体分为:线性/非线性规划,动态规划,这是规划里面的,还有库存论(销量预测,例如便利店),图论(七桥问题路线最短),排队论(客服接待顾客问题),博弈论(对策论,田忌赛马问题)等等吧,这些都是我们见过的吧,只是没有给它定名,对不上号而已。

那么对于上述家居布置问题应该算啥问题呢?应该属于组合最优化的问题,组合最优化包括哪些方法呢?如下,我们很熟悉,

聚类,KNN,决策树,回归,随机森林,SVM等等

当然运筹学也有库,惊喜吧,意外吧,你遇到的都是别人研究过的领域,你并不需要披荆斩棘开辟新的道路,照葫芦画瓢就行了。谷歌开源了OR-tools,来吧,直接调库吧,大家都是这样做的。

当然还有经典的问题,选址问题,充电桩,快递柜,银行,连锁店,商场。

1,P中位(中值)问题

p个服务点,要求距离与需求量乘积之和最小,比如,商场应该建立在离人多的地方,毕竟人少的地方去的人少,而且多数人过去不方便。

2,P中心问题

p个服务点,任意需求点到服务点最大距离最小。

3,覆盖问题,包括最大覆盖问题和集覆盖问题

最大覆盖问题是研究在服务点数目和服务半径已知的时,如何设立 P 个服务点使得可接受服务的需求量最大的问题。目标函数是服务站可以覆盖的期望需求量最大 。

集覆盖问题,服务站个数最小和备用覆盖的顾客最大的双目标集覆盖问题。

OR工具解题思路:

Import the linear solver wrapper,declare the LP solver,define the variables,define the constraints,define the objective,call the LP solver; anddisplay the solution

例题如下:

最大化3x+4y使其满足要求。

from ortools.linear_solver import pywraplpdef LinearProgrammingExample():"""Linear programming sample."""# Instantiate a Glop solver, naming it LinearExample.solver = pywraplp.Solver.CreateSolver('GLOP')if not solver:return# Create the two variables and let them take on any non-negative value.x = solver.NumVar(0, solver.infinity(), 'x')y = solver.NumVar(0, solver.infinity(), 'y')print('Number of variables =', solver.NumVariables())# Constraint 0: x + 2y <= 14.solver.Add(x + 2 * y <= 14.0)# Constraint 1: 3x - y >= 0.solver.Add(3 * x - y >= 0.0)# Constraint 2: x - y <= 2.solver.Add(x - y <= 2.0)print('Number of constraints =', solver.NumConstraints())# Objective function: 3x + 4y.solver.Maximize(3 * x + 4 * y)# Solve the system.status = solver.Solve()if status == pywraplp.Solver.OPTIMAL:print('Solution:')print('Objective value =', solver.Objective().Value())print('x =', x.solution_value())print('y =', y.solution_value())else:print('The problem does not have an optimal solution.')print('\nAdvanced usage:')print('Problem solved in %f milliseconds' % solver.wall_time())print('Problem solved in %d iterations' % solver.iterations())LinearProgrammingExample()

愿我们终有重逢之时,而你还记得我们曾经讨论的话题。

如果觉得《运筹学到底是啥玩意?》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。