• Keine Ergebnisse gefunden

Foundations of Artificial Intelligence

N/A
N/A
Protected

Academic year: 2022

Aktie "Foundations of Artificial Intelligence"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Foundations of Artificial Intelligence

M. Helmert S. Eriksson Spring Term 2021

University of Basel Computer Science

Exercise Sheet 6

Due: April 14, 2021

Exercise 6.1(1+0.5+0.5 marks)

In thePartitionproblem we are given a set of natural numbersNand try to partition them into two setsA1 andA2 such that the sum of the numbers in A1 is as close as possible to the sum of the numbers inA2.

(a) FormalizePartitionas a combinatorial optimization problem.

(b) Is your formulation a pure search problem, a pure optimization problem, or a combined search and optimization problem?

(c) Define a suitable neighboring function for hill climbing.

Exercise 6.2(2.5+0.5 marks)

The task in this exercise is to write a software program. We expect you to implement your code on your own, without using existing code (such as examples you find online). If you encounter technical problems or have difficulties understanding the task, please let us know.

The archivehill-climbing.tar.gzcontains an incomplete implementation of hill climbing search for the 8 queens problem that was presented in the lecture.

(a) Implement hill climbing in the function protected SearchResult search() in the file HillClimbing.java. The implemented heuristic counts how many pairs of queens are threatening each other, which means we are considering a minimization variant here and you need to adapt the function presented on Slide 21 of Chapter 20 (print version) accord- ingly. Break ties among neighbors with minimal heuristic value uniformly at random. Note that protected SearchResult search() returns a SearchResult object, which contains information if hill climbing found a solution and on the number of steps.

(b) Test your implementation by verifying the statements on Slide 24 of Chapter 20 (print version), which state that hill climbing with a random initialization finds a solution in around 14% of the cases using around 4 steps on average. You can compile and run your code with javac HillClimbing.java followed by the commandjava HillClimbing 8queens.

Report the percentage of successful runs and the average number of steps.

Exercise 6.3(1.5+0.5bonus marks)

This is a bonus exercise which builds upon your solution from Exercise 6.2. Bonus marks count normally but are not considered for the sum of total achievable marks.

(a) Copy your hill climbing implementation into a new fileHillClimbingWithStagnation.java.

Adapt the implementation such that steps without improvement (stagnation) are allowed as described on Slide 8 of Chapter 21 (print version).

Hint: Since the 8 queens problem is a pure search problem, you can terminate as soon as a solution is found.

(b) Verify that approximately 96% of the runs with a bound of 100 steps yield a solution, and that if a solution is found, it took around 22 steps on average. What is the percentage of successful runs and the average number of steps in case of success for your solution?

(2)

Submission rules:

• Create a single PDF file (ending .pdf) for all non-programming exercises. If you want to submit handwritten parts, include their scans in the single PDF. Put the names of all group members on top of the first page. Use page numbers or put your names on each page. Make sure your PDF has size A4 (fits the page size if printed on A4).

• For programming exercises, create only those Java textfiles (ending .java) required by the exercise. Put your names in a comment on top of each file. Make sure your code compiles and test it!

• For the submission, you can either upload the single PDF or prepare a ZIP file (ending .zip, .tar.gz or .tgz; not .rar or anything else) containing the single PDF and the Java textfile(s) and nothing else. Please do not use directories within the ZIP, i.e., zip the files directly.

Referenzen

ÄHNLICHE DOKUMENTE

Provide a worst-case runtime estimate of the algorithm based on cutset conditioning if your cutset from the first part of this exercise is used (i.e., compute an upper bound for

Perfom DPLL on the clause set {{A, ¬B}, {¬A, B}, {B, ¬D}, {C}, {¬C, ¬B, ¬D}, {C, D}}, always picking the variable occuring in the highest number of clauses and always considering

In cases where the precondition choice function is not deterministic, choose the precondition in alphabetical order.. Exercise 11.3

– one line for each table position: maximum number of blocks in the tower at this table position, followed by the IDs of the blocks in the initial state, starting from the surface

Successor nodes are generated by applying the following actions in order, ignoring the ones that are inapplicable in a given state: transport 2 missionaries, transport 1

(c) Test your implementation by verifying the statements on Slide 23 of Chapter 20 (print version), which state that hill climbing with a random initialization finds a solution

Provide a worst-case runtime estimate of the algorithm based on cutset conditioning if your cutset from the first part of this exercise is used (i.e., compute an upper bound for

The domain description (variables and actions) is given in the file bridges-once-domain.pddl, and the problem description (objects, initial state and goal description) is given in