C# 有序组合算法
我正在尝试开发 ac# 应用程序,该应用程序将在限制和成本范围内生成所有可能排列的列表。例如,我有 80 个职位的列表。每项工作都有一个值 (1-5)(通常为 3),每个工程师的工作量都有一个限制,通常值为 20。
目前,我已经开始生成所有可能组合的列表(n n 是作业总数,k 是 2)。
! / (k! * (nk)!其中 并生成所有可能的作业组合列表(从起始作业开始),最多为 20 个,然后根据重量总和排序,重量最低的路线将获胜并分配给工程师。不知道如何解决这个问题 - 哪种数据结构最好?
通常有大约 6-8 名工程师(取决于工作量),我计划一次为每个工程师分配一个路线 - 一旦一条路线分配给另一个工程师工程师,这些工作将从列表中删除,并选择一个新的开始工作并生成一组新的组合,这听起来是一种可以接受的方法吗?
欢迎任何帮助。
I'm trying to develop a c# application that will generate a list of all possible permutations, within a limit, and cost. For example, I have a list of 80 jobs. Each job has a value (1-5) (typically 3) and each engineer has a limit of how much they can do, typically a value of 20.
At the moment I've started by producing a list of all possible combinations (n! / (k! * (n-k)! where n is the total number of jobs and k is 2). The link between each job should be weighted with the distance between each job.
From here I would like to pick an initial start job and produce a list of all possible combinations of jobs (from the start job) up to the limit of 20 and then ordered on the sum of the weight. The lowest weight route would win and be allocated to the engineer. My problem is that I don't know how to approach this - what data structure would be best?
Typically there are approx 6-8 engineers (depending on workload), I had planned on routing each engineer one at a time - once a route had been allocated to another engineer, those jobs would be removed from the list and a new start job selected with a new set of combinations generated. Does this sound like an acceptable approach?
Any assistance would be welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有有效的算法来解决这个问题。我会使用遗传算法(不一定找到最佳解决方案,但找到可接受的解决方案)。
There is no efficient algorithm to solve this problem. I would use a genetic algorithm (does not necessarily find the optimal solution but finds an acceptable solution).
你可以看看微软求解器基金会:
http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx
另外,如果您喜欢 Linq to Anything,请查看 Bart de Smet 的 Linq to Z3 :)
http://channel9.msdn.com/Shows /Going+Deep/Bart-De-Smet-LINQ-to-Z3
You could look at Microsoft Solver Foundation:
http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx
Also, look at Bart de Smet's Linq to Z3 if you are into Linq to Anything :)
http://channel9.msdn.com/Shows/Going+Deep/Bart-De-Smet-LINQ-to-Z3
我会尝试模拟退火,这是一种通过根据系统能量随机测试配置来找到全局最优值的算法。
http://en.wikipedia.org/wiki/Simulated_annealing
查看文章中的伪代码。
I would try simulated annealing, an algorithm to find a global optimum by testing configurations randomly according to the energy of the system.
http://en.wikipedia.org/wiki/Simulated_annealing
Check the article for the pseudocode.