heuristics

fast heuristic algorithm for n queens (n > 1000)

和自甴很熟 提交于 2019-12-06 07:01:51
问题 I write two program : put together n queens in chess board without any threatening by backtracking algorithm. but that is very heavy for big n . at last you can run that for 100 queens. put together n queens in chess board without any threatening by Hill climbing algorithm. this algorithm better than past solution but it take 2 min for 300 queens and this time increase exponentially! But I didn't have any idea for doing that fast! I want algorithm for doing that faster . I want faster manner

Where are strings more useful than a StringBuilder?

不羁岁月 提交于 2019-12-06 03:17:28
问题 Lot of questions has been already asked about the differences between string and string builder and most of the people suggest that string builder is faster than string. I am curious to know if string builder is too good so why string is there? Moreover, can some body give me an example where string will be more usefull than string builder? 回答1: It's not a case of which is more useful... A String is a String - one or more characters next to eachother. If you want to change a string in someway

Number of simple mutations to change one string to another?

半城伤御伤魂 提交于 2019-12-05 17:46:46
I'm sure you've all heard of the "Word game", where you try to change one word to another by changing one letter at a time, and only going through valid English words. I'm trying to implement an A* Algorithm to solve it (just to flesh out my understanding of A*) and one of the things that is needed is a minimum-distance heuristic. That is, the minimum number of one of these three mutations that can turn an arbitrary string a into another string b: 1) Change one letter for another 2) Add one letter at a spot before or after any letter 3) Remove any letter Examples aabca => abaca: aabca abca

How to search for a person's name in a text? (heuristic)

感情迁移 提交于 2019-12-05 12:19:05
I have a huge list of person's full names that I must search in a huge text . Only part of the name may appear in the text. And it is possible to be misspelled , misstyped or abreviated . The text has no tokens, so I don't know where a person name starts in the text. And I don't if know if the name will appear or not in the text. Example: I have "Barack Hussein Obama" in my list, so I have to check for occurrences of that name in the following texts: ...The candidate Barack Obama was elected the president of the United States... (incomplete) ...The candidate Barack Hussein was elected the

Probability density function from a paper, implemented using C++, not working as intended

杀马特。学长 韩版系。学妹 提交于 2019-12-05 07:19:04
So i'm implementing a heuristic algorithm, and i've come across this function. I have an array of 1 to n (0 to n-1 on C, w/e). I want to choose a number of elements i'll copy to another array. Given a parameter y, (0 < y <= 1), i want to have a distribution of numbers whose average is (y * n). That means that whenever i call this function, it gives me a number, between 0 and n, and the average of these numbers is y*n. According to the author, "l" is a random number: 0 < l < n . On my test code its currently generating 0 <= l <= n. And i had the right code, but i'm messing with this for hours

Why A* is faster if i use 4xManhattan Distances as Heuristic for 15-Puzzle

对着背影说爱祢 提交于 2019-12-05 03:17:47
问题 I have implemented an A* algorithm for solving the 15-puzzle. I made a research for finding some viable or admissible heuristics, looking for a fast solution, and i find that using 4*Manhattan Distance as heuristic always solve any 15-puzzle in less than a second. I tried this and effectively works. I tried to find a answer for that but i cant find it. Any one can explain this? 回答1: 4* manhattan distance is not admissible heuristic, this makes the algorithm behave "closer" to greedy best

Heuristic function for finding the path using A star

会有一股神秘感。 提交于 2019-12-05 02:11:04
问题 I am trying to find a optimal solution for the following problem The numbers denoted inside each node are represented as (x,y) . The adjacent nodes to a node always have a y value that is (current nodes y value +1). There is a cost of 1 for a change in the x value when we go from one node to its adjacent There is no cost for going from node to its adjacent, if there is no change in the value of x . No 2 nodes with the same y value are considered adjacent. The optimal solution is the one with

Can somebody explain in Manhattan dstance for the 8 puzzle in java for me?

天大地大妈咪最大 提交于 2019-12-04 21:33:50
i am writing an A* algorithm which can solve the 8-puzzle in Java, so far i have implemented DFS, BFS, A* using the number of tiles out of place and i just need to implement it using the heuristic for the Manhattan distance. As you are probably aware the Manhattan distance is the sum of each tiles displacement in relation to its current position and its index in the goal state. I have googled around and found these stack over flow topics: Calculating Manhattan Distance Manhattan distance in A* Which returned the following code: int manhattanDistanceSum = 0; for (int x = 0; x < N; x++) // x

Finding minimum cut-sets between bounded subgraphs

佐手、 提交于 2019-12-04 19:15:27
问题 If a game map is partitioned into subgraphs, how to minimize edges between subgraphs? I have a problem, Im trying to make A* searches through a grid based game like pacman or sokoban, but i need to find "enclosures". What do i mean by enclosures? subgraphs with as few cut edges as possible given a maximum size and minimum size for number of vertices for each subgraph that act as a soft constraints. Alternatively you could say i am looking to find bridges between subgraphs, but its generally

Iterative Deepening A Star (IDA*) to solve n-puzzle (sliding puzzle) in Java

蓝咒 提交于 2019-12-04 17:08:25
I've implemented a program able to solve the n-puzzle problem with A*. Since the space of the states is too big I cannot precompile it and I have to calculate the possible states at runtime. In this way A* works fine for a 3-puzzle, but for a 4-puzzle can take too long. Using Manhattan distance adjusted with linear conflicts, if the optimal solution requires around 25 moves is still fast, around 35 takes 10 seconds, for 40 takes 180 seconds. I haven't tried more yet. I think that's because I must keep all visited states, since I'm using functions admissible but (I think) not consistent (i