## 这是一篇关于解决下面几个问题的机器学习代写

**Question 1: Planning (4 marks) **

Modify the simple planner from the week 7 lecture so that it can solve the planning problem in the textbook, Poole and Mackworth Section 6.1. Here, there is a robot that can move around an office building, pickup mail and deliver coffee.

Like the rubbish pickup problem, actions can be representation by a triple:

action(Action, State, NewState)

where the state of the world is represented by a quintuple:

state(RLoc, RHC, SWC, MW, RHM)

- RLoc – Robot Location,
- RHC – Robot Has Coffee,
- SWC – Sam Wants Coffee,
- MW – Mail Waiting,
- RHM – Robot Has Mail

You are required to replace the action specifications by a new set that specify the state transitions for each of the actions:

- mc – move clockwise
- mcc – move counterclockwise
- puc – pickup coffee
- dc – deliver coffee
- pum – pickup mail
- dm – deliver mail.

**Do not alter the planner code, only the ***action*** clauses should be replaced. **

You should only need to write one clause for each action, however, you might need some addition clauses to help with the *mc* and *mcc* actions. Think about how to represent the room layout.

Your program should be able to satisfy queries such as:

?- id_plan(

state(lab, false, true, false, false),

state(_, _, false, _, _),

Plan).

**Plan** = [mc, mc, puc, mc, dc]

which asks the robot to get Sam coffee. Note that the values of the state variables, RHC,SWC, MW, RHM are boolean and we’ve used the constants **true** and **false**, to represent the boolean values. The initial state in this example has the robot in the lab, the robot does not have any coffee, Sam wants coffee, there is no mail waiting and the robot does not have any mail. The goal state is where Sam no longer wants coffee. Note that the anonymous variable, ‘_’, indicates that we don’t care what the other values are.

To test your action specifications, think about how you would ask the robot to pickup mail. What about if Sam want coffee and there was mail waiting?

**Question 2: Inductive Logic Programming (4 marks) **

*Duce* is a program devised by Muggleton [1] to perform learning on a set of propositional clauses. The system includes 6 operators that transform pairs of clauses into a new set of clauses. Your task is to write Prolog programs to implement 2 of the 6 operators. One is given as an example to get you started.

*Your answers should preserve the order of literals in each clause, as given. Any new **literals should be appended to the end of the clause. *

**Inter-construction.** This transformation takes two rules, with *different* heads, such as

x <- [b, c, d, e]

y <- [a, b, d, f]

and replaces them with rules

x <- [c, e, z]

y <- [a, f, z]

z <- [b, d]

i.e. we find the intersection of the bodies of the first two clauses, invent a new predicate symbol, ** z**, and create the clause

**← [**

*z***,**

*b***]. Create two new clauses which are the original clauses rewritten to replace [**

*d***,**

*b***] by**

*d*

*z.*To make processing the rules easier, we represent the body of the clause by a list and we define the operator <- to mean “implied by” or “if’.

A Prolog program to implement inter-construction is given as an example to give you hints about how to write the two operators.

:- op(300, xfx, <-).

inter_construction(C1 <- B1, C2 <- B2, C1 <- Z1B, C2 <- Z2B, C <- B) :-

C1 \= C2,

intersection(B1, B2, B),

B \= [],

gensym(z, C),

subtract(B1, B, B11),

subtract(B2, B, B12),

append(B11, [C], Z1B),

append(B12, [C], Z2B).

First, we define <- as an operator that will allow us to use the notation x <- y. The program uses Prolog built-in predicates to perform set operations on lists and to generate new symbols.

- The first line the program assumes that the first two arguments are given as propositional clauses. The remaining three arguments are the output clauses, as in the example above.

- inter_construction operates on two clauses that gave different heads, i.e. C1 \= C2.
- We then find the interaction of the bodies of the clauses and call it, B.
**gensym**is a builtin predicate that creates a new name from a base name. So**gensym(z, C)**binds**C**to**z1**. Every subsequent call to gensym, with base z, will create names, z2, z3, …. Calling**reset_gensym**will restart the numbering sequence.

**C**is bound to**z1**and**B**is the intersection [b, d].

**Z1B**and**Z2B**, are obtained by subtracting the intersection,**B**, from**B1**and**B2**and appending the single element**[C].**So we can run the program:

?- inter_construction(x <- [b, c, d, e], y <- [a, b, d, f], X, Y, Z).

X = x<-[c, e, z1],

Y = y<-[a, f, z1],

Z = z1<-[b, d].

obtaining the desired result.

You will write programs for the other three operators, defined below. These programs can be created from the built-in predicates used in the **inter-construction** code. So all you have to do is work out how to combine them. The only other builtin predicate you may need is to test if one list is a subset of another with **subset(X, Y)**, where **X** is a subset of **Y**.

You can assume that the inputs will always be valid clauses and the lists will always be non-empty, i.e. with at least one element.

**Question 2.1 (2 marks): **

**Intra-construction.** This transformation takes two rules, with the *same* head, such as

x <- [b, c, d, e]

x <- [a, b, d, f]

and replaces the with rules

x <- [b, d, z]

z <- [c, e]

z <- [a, f]

That is, we merge the two, **x**, clauses, keeping the intersection and adding a new predicate, **z**, that distributes the differences to two new clauses.

?- intra_construction(x <- [b, c, d, e], x <- [a, b, d, f], X, Y, Z).

X = x<-[b, d, z1],

Y = z1<-[c, e],

Z = z1<-[a, f].

The predicate should fail if there is no intersection between the two clauses.

**Question 2.2 (2 marks): **

**Absorption.** This transformation takes two rules, with the *different* heads, such as

x <- [a, b, c, d, e]

y <- [a, b, c]

and replaces the with rules

x <- [d, e, y]

y <- [a, b, c]

Note that the second clause is unchanged. This operator checks to see if the body of one clause is a subset of the other. If it is, the common elements can be removed from the larger clause and the head of the smaller one appended to the larger one.

?- absorption(x <- [a, b, c, d, e], y <- [a, b, c], X, Y).

X = x<-[d, e, y],

Y = y<-[a, b, c].

The predicate should fail if there is the body of the second clause is not a subset of thebody of the first.

**Question 2.3 (2 marks): **

**Truncation.** This is the simplest transformation. It takes two rules that have the same head and simply drops the differences to leave just one rule. For example

x <- [a, b, c, d]

x <- [a, c, j, k]

are replaced by

x <- [a, c]

That is, the body of the new clause is just the intersection of the bodies of the input clauses.

?- truncation(x <- [a, b, c, d], x <- [a, c, j, k], X).

X = x<-[a, c].

The complete Duce algorithm performs a search, looking for combination of these operators that will lead to the greater compression over the database of examples. Here compression is measured by the reduction in the number of symbols in the database.

You don’t have to worry about the search algorithm, just implement the operators, as above.

**References **

- Muggleton, S. (1987). Duce, An oracle based approach to constructive induction.

Proceedings of the International Joint Conference on Artificial Intelligence, 287–292.

**程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB**

本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！

**E-mail:** itcsdx@outlook.com **微信:**itcsdx

如果您使用手机请先保存二维码，微信识别。如果用电脑，直接掏出手机果断扫描。