heuristics

Heuristic algorithm for load balancing among threads

五迷三道 提交于 2019-12-03 05:18:14
问题 I'm working on a multi-threaded program where I have a number of worker threads performing tasks of unequal length. I want to load-balance the tasks to ensure that they do roughly the same amount of work. For each task T i I have a number c i which provides a good approximation to the amount of work that is required for that task. I'm looking for an efficient (O(N) N = number of tasks or better) algorithm which will give me "roughly" a good load balance given the values of c i . It doesn't

Data Type Recognition/Guessing of CSV data in python

你。 提交于 2019-12-03 05:04:37
问题 My problem is in the context of processing data from large CSV files. I'm looking for the most efficient way to determine (that is, guess) the data type of a column based on the values found in that column. I'm potentially dealing with very messy data. Therefore, the algorithm should be error-tolerant to some extent. Here's an example: arr1 = ['0.83', '-0.26', '-', '0.23', '11.23'] # ==> recognize as float arr2 = ['1', '11', '-1345.67', '0', '22'] # ==> regognize as int arr3 = ['2/7/1985',

Given a document, select a relevant snippet

谁都会走 提交于 2019-12-03 04:34:47
问题 When I ask a question here, the tool tips for the question returned by the auto search given the first little bit of the question, but a decent percentage of them don't give any text that is any more useful for understanding the question than the title. Does anyone have an idea about how to make a filter to trim out useless bits of a question? My first idea is to trim any leading sentences that contain only words in some list (for instance, stop words, plus words from the title, plus words

What is the difference between a heuristic and an algorithm?

大憨熊 提交于 2019-12-03 00:04:18
问题 What is the difference between a heuristic and an algorithm? 回答1: An algorithm is the description of an automated solution to a problem . What the algorithm does is precisely defined. The solution could or could not be the best possible one but you know from the start what kind of result you will get. You implement the algorithm using some programming language to get (a part of) a program . Now, some problems are hard and you may not be able to get an acceptable solution in an acceptable time

Pacman: how do the eyes find their way back to the monster hole?

浪尽此生 提交于 2019-12-03 00:02:10
问题 I found a lot of references to the AI of the ghosts in Pacman, but none of them mentioned how the eyes find their way back to the central ghost hole after a ghost is eaten by Pacman. In my implementation I implemented a simple but awful solution. I just hard coded on every corner which direction should be taken. Are there any better/or the best solution? Maybe a generic one that works with different level designs? 回答1: Actually, I'd say your approach is a pretty awesome solution, with almost

Heuristic algorithm for load balancing among threads

梦想的初衷 提交于 2019-12-02 19:43:07
I'm working on a multi-threaded program where I have a number of worker threads performing tasks of unequal length. I want to load-balance the tasks to ensure that they do roughly the same amount of work. For each task T i I have a number c i which provides a good approximation to the amount of work that is required for that task. I'm looking for an efficient (O(N) N = number of tasks or better) algorithm which will give me "roughly" a good load balance given the values of c i . It doesn't have to be optimal, but I would like to be able to have some theoretical bounds on how bad the resulting

Given a document, select a relevant snippet

前提是你 提交于 2019-12-02 17:45:22
When I ask a question here, the tool tips for the question returned by the auto search given the first little bit of the question, but a decent percentage of them don't give any text that is any more useful for understanding the question than the title. Does anyone have an idea about how to make a filter to trim out useless bits of a question? My first idea is to trim any leading sentences that contain only words in some list (for instance, stop words, plus words from the title, plus words from the SO corpus that have very weak correlation with tags, that is that are equally likely to occur in

What is the difference between a heuristic and an algorithm?

半城伤御伤魂 提交于 2019-12-02 13:50:09
What is the difference between a heuristic and an algorithm? kriss An algorithm is the description of an automated solution to a problem . What the algorithm does is precisely defined. The solution could or could not be the best possible one but you know from the start what kind of result you will get. You implement the algorithm using some programming language to get (a part of) a program . Now, some problems are hard and you may not be able to get an acceptable solution in an acceptable time. In such cases you often can get a not too bad solution much faster, by applying some arbitrary

Pacman: how do the eyes find their way back to the monster hole?

跟風遠走 提交于 2019-12-02 13:48:40
I found a lot of references to the AI of the ghosts in Pacman, but none of them mentioned how the eyes find their way back to the central ghost hole after a ghost is eaten by Pacman. In my implementation I implemented a simple but awful solution. I just hard coded on every corner which direction should be taken. Are there any better/or the best solution? Maybe a generic one that works with different level designs? Kylotan Actually, I'd say your approach is a pretty awesome solution, with almost zero-run time cost compared to any sort of pathfinding. If you need it to generalise to arbitrary

How to optimize math operations on matrix in python

烈酒焚心 提交于 2019-12-01 18:46:45
I am trying to reduce the time of a function that performs a serie of calculations with two matrix. Searching for this, I've heard of numpy, but I really do not know how apply it to my problem. Also, I Think one of the things is making my function slow is having many dots operators (I heard of that in this this page ). The math correspond with a factorization for the Quadratic assignment problem: My code is: delta = 0 for k in xrange(self._tam): if k != r and k != s: delta += self._data.stream_matrix[r][k] \ * (self._data.distance_matrix[sol[s]][sol[k]] - self._data.distance_matrix[sol[r]][sol