implement the Local Beam Search algorithm to solve the n-queens problem. The following will be the outline of your implementation:   Your program should start with k random initial states.   At each step, generate all successors of the current k states and select the best k successors to move forward with. The successors will be chosen based on heuristic values (number of attacking pairs).   If any of these k states has zero attacking pairs, the algorithm should stop and print the solution.   If local minima are reached, the algorithm will stop and print the board configuration. Your program will print the final board configuration, the number of attacking pairs in the board, and the total time required to reach the final state. Note, in the n-queens problem, corresponds to a column, and the value at each index represents the row position of the queen in that column. each queen can only move vertically within its own column. The state of the board is represented by a one-dimensional array where each index The initial random state will have one queen in each row. As such, to calculate the number of attacks/conflicts, you need to check the rows and diagonals. Execute your program with n = 8, 12, 16, and 20. For each of this n, use these values of k: 1, 3, 5, and 7. For each of these combinations of k and n, execute your program several times starting with a different initial random state Now, answer the following questions. You should use graphs and/or tables to explain and justify your answers. 1) 2) 3) 4) How does varying the value of k affect the ability of the program to find solutions (zero attacking pairs) for different values of n? Using the results of your experiment, explain what are the limitations and/or benefits of simple hill- climbing and local beam search? What trend do you observe in the runtime for different values of k for a fixed value of n? Comment on the trade-off between the ability of finding solutions vs speed as you increase the value of k. What trend do you observe in the runtime for different values of n for a fixed value of k? Do you think the local beam search algorithm will work for very large value of n? Justify your answer

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
icon
Related questions
Question

implement the Local Beam Search algorithm to solve the n-queens problem. The following will be the outline of your implementation:

  •   Your program should start with k random initial states.

  •   At each step, generate all successors of the current k states and select the best k successors to move

    forward with. The successors will be chosen based on heuristic values (number of attacking pairs).

  •   If any of these k states has zero attacking pairs, the algorithm should stop and print the solution.

  •   If local minima are reached, the algorithm will stop and print the board configuration.

    Your program will print the final board configuration, the number of attacking pairs in the board, and the total time required to reach the final state. Note, in the n-queens problem,

corresponds to a column, and the value at each index represents the row position of the queen in that column.

each queen can only move vertically

within its own column. The state of the board is represented by a one-dimensional array where each index

The initial random state will have one queen in each row. As such, to calculate the number of attacks/conflicts,

you need to check the rows and diagonals.

Execute your program with n = 8, 12, 16, and 20. For each of this n, use these values of k: 1, 3, 5, and 7. For

each of these combinations of k and n, execute your program several times starting with a different initial

random state

Now, answer the following questions. You should use graphs and/or tables to explain and justify your answers.

1) 2) 3) 4)

How does varying the value of k affect the ability of the program to find solutions (zero attacking pairs)

for different values of n?

Using the results of your experiment, explain what are the limitations and/or benefits of simple hill-

climbing and local beam search?

What trend do you observe in the runtime for different values of k for a fixed value of n? Comment on

the trade-off between the ability of finding solutions vs speed as you increase the value of k.

What trend do you observe in the runtime for different values of n for a fixed value of k? Do you think

the local beam search algorithm will work for very large value of n? Justify your answer

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Single source shortest path
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning