You are provided with the Java code implementing a solution for the 8-Queen puzzle using a search method called Hill Climbing. Upon execution of the Java code, the user is prompted to enter the value...

1 answer below »
You are provided with the Java code implementing a solution for the 8-Queen puzzle using a search method called Hill Climbing. Upon execution of the Java code, the user is prompted to enter the value of n which is the chess board dimension that can be any natural number except for 2 and 3. The
runSearch()
method of
HillClimbingSearch
is then called to compute a solution and the board solution is printed if/when it is found. Try to execute the code for various values of n and check the time it takes to compute a solution.Hill Climbing search works by randomly selecting a solution to a problem and iteratively improving the solution until it satisfies the desired constraints. In order to find solutions to n-Queen problem faster as n increases, we can run several threads of
HillClimbingSearch
concurrently. Each thread will start from a randomly selected point in the search space and the threads will explore different parts of the search space concurrently until one of them finds a solution. This can considerably improve the time required to find a solution for large values of n (e.g., n > 40).Your task is to modify
Main.java
and
HillClimbingSearch.java
so that you create several threads each running one instance of
HillClimbingSearch. Create a
ThreadGroup
to keep track of all your threads. You stop all the threads as soon as one of them finds a solution. The number of threads you create is optional. You only need to modify Main.java and HillClimbingSearch.java. In the latter, you only need to modify the
runSeach()
method, and there is no need to touch any other methods in that file.Hint:
You might want to take a look at the
ThreadGroup
Javadoc: http://docs.oracle.com/javase/7/docs/api/java/lang/ThreadGroup.htmlTo stop the threads, you can use the interrupt mechanism in Java. You may find the discussion on this webpage helpful in implementing your interrupt mechanism for stopping all the threads as soon as one thread finds a solution: https://stackoverflow.com/questions/31895612/how-to-stop-a-thread-with-thread-interrupt-method.
Answered 146 days AfterNov 14, 2021

Answer To: You are provided with the Java code implementing a solution for the 8-Queen puzzle using a search...

Sathishkumar answered on Apr 10 2022
109 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here