English 中文(简体)
书写 C#中0-1千分卡的安集算法
原标题:Writing Simulated Annealing algorithm for 0-1 knapsack in C#

正在学习模拟的家用算法,并有几个问题,即我如何修改计算法,以解决0-1千卡的问题。

我发现《刑事诉讼法》中的这一伟大法典:

http://www.codeproject.com/KB/recipes/simulatedAnnealingTSP.aspx

我确信,我知道现在如何工作(除了整个博尔兹曼条件之外,就我所说的是黑魔,尽管我了解当地的最佳选择,而且显然确实如此)。 我愿重新设计,以解决0-1千纳普什问题。 基本上,我把5 000个物体中的1个放在10个袋里,需要优化用于最不发达的空间。 分配给解决办法的实际“分数”是比较复杂的,但与算法无关。

这似乎十分容易。 这意味着安妮塔(Anneal)的职能基本相同。 d 我必须履行GetNextArrangement()的职能,以满足我的需求。 在“TSM”问题上,他只是穿过两条任意的节点(即,他每轮一次变化很小)。

就我的问题而言,在第一个隔.中,我抽取10个随机物体,看左侧。 接下来,我是否仅举10个新随机物体? 或者,我最好只夸大少数物体,如其中一半或甚至其中之一? 或者,与气温相比,我蒸发的物体数量是否应当相对? 这对我来说似乎有帮助,我很想知道,有人是否就最佳办法提出一些建议(尽管我可以说,如果我有守则工作的话,会随处改进)。

感谢!

迈克

最佳回答

随着模拟的anne,你希望使邻国尽可能接近能源。 如果邻国的能源大大提高,那么如果没有极高的气温,它就将永远不会跳跃到它们身上。 另一方面,如果你能够带着利用低能源国家的温和,那么就利用它们。

对图普来说,这意味着冲撞邻近城市。 对于你的问题,我建议采用以下有条件的邻国甄选算法:

  1. If there are objects that fit in the empty space, then it always puts the biggest one in.
  2. If no objects fit in the empty space, then pick an object to swap out -- but prefer to swap objects of similar sizes.

也就是说,物体的大小差异很可能相反。 你们可能想在这里使用像选择摩托特这样的东西,其面积就象(1/(大小2)^2)。

问题回答




相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...