Professional Documents
Culture Documents
Week # 10 Lecture # 19 & 20 General Problem Solver: Learning Objectives
Week # 10 Lecture # 19 & 20 General Problem Solver: Learning Objectives
Week # 10 Lecture # 19 & 20 General Problem Solver: Learning Objectives
https://youtu.be/EkJUHSzI_Aw
3 Dr Umair Abdullah GPS Moving Block Example
https://youtu.be/cTjo9jSToJQ
https://youtu.be/ran8kLIPWzM
https://youtu.be/tgM9BU6PnCQ
5 Dr Umair Abdullah GPS in class videos (2019) https://youtu.be/9FGxOsWXmhE
https://youtu.be/92eyE4Mf9Uc
https://youtu.be/DCqiGghEkDw
Learning Objectives
1. Solution of assignment # 6
2. General Problem Solver Introduction
3. Arranging Block example in GPS
4. Drive son to school example
5. GPS Code overview
PRE-REQUISITS
SOLUTION:
TRACING
Introduction
Given this description of a theory of problem solving, how should we go about writing a
program? The main idea is to solve a problem using a process called means-ends analysis,
where the problem is stated in terms of what we want to achieve at the end. In Newell and
Simon’s example, the problem is to get the kid to school, but in general we would like the
program to be able to solve a broad class of problems. We can solve a problem if we can find
some way to eliminate “the difference between what I have (current state) and what I want
(goal state).” For example, if what I have is a child at home and what I want is a child as
school, then driving may be a solution, because we know that driving leads to a change in
location. We should be aware that using means-ends analysis is a choice: it is also possible to
start from the current situation and search forward to the goal, or to employ a mixture of
different search strategies.
We can represent the current state of the world —“what I have”— or the goal state –
“what I want” – as sets of conditions. Common Python doesn’t have a data type for sets,
but it does have lists, which can be used to implement sets. Each condition can be
represented by a symbol. Thus, a typical goal might be the list of two conditions (rich
famous) and a typical current state might be (unknown poor).
We need a list of allowable operators. This list well be constant over the course of a
problem, or even a series of problems, but we want to be able to change it and tackle a
new problem domain.
A complete problem is described to GPS in terms of a starting state, a goal state, and a set
of known operators. Thus, GPS will be a function of three arguments. For example, a
sample call might be:
(GPS ` (unknown poor) ‘ (rich famous) list-of-ops)
In other words, starting from the state of being poor and unknown, achieve the
state of being rich and famous, using any combination of the known operators. GPS
should return a true value only if it solves the problem and it should print a record of the
actions taken. The simplest approach is to go through the conditions in the goal state one
at a time and try to achieve each one. If they can all be achieved, then the problem is
solved.
A single goal condition can be achieved in two ways. If it is already in the current state,
the goal is trivially achieved with no effort. Otherwise, we have to find some appropriate
operator and try to apply it.
An operator is appropriate if one of the effects of the operator is to add the goal in
question to the current state; in other words, if the goal is in the operator’s add-list.
We can apply an operator if we can achieve all the preconditions. But this is easy, because we
just defined the notion of achieving a goal in the previous paragraph. Once the preconditions
have been achieved, applying an operator’s add-list and delete-list. Since our program is just a
simulation – it won’t be actually driving a car or dialing a telephone – we must be content
simply to print out the action, rather than taking any real action.
A C
B A
C B
block_ops = [
{"action":"Move block C on table",
"preconds":["Block C on A", "C-free"],
"add":["Block C on table", "A-free"],
"delete":["Block C on A"]},
{"action":"Move block A on table",
"preconds":["Block A on B","A-free"],
"add":["Block A on table", "B-free"],
"delete":["Block A on B"]},
{"action":"Move block B on C",
"preconds":["Block B on table", "B-free", "C-free"],
"add":["Block B on C"],
"delete":["Block B on table","C-free"]},
{"action":"Move block A on B",
"preconds":["Block A on table", "A-free","B-free"],
"add":["Block A on B"],
"delete":["Block A on table", "B-free"]}
]
sch_ops = [ {
"action": "drive son to school",
"preconds": ["son at home", "car works"],
"add": ["son at school"],
"delete": ["son at home"]
},
{ "action": "shop installs battery",
"preconds": ["car needs battery", "shop knows problem", "shop
has money"],
"add": ["car works"],
"delete": []
},
{ "action": "tell shop problem",
"preconds": ["in communication with shop"],
"add": ["shop knows problem"],
"delete": []
},
{ "action": "telephone shop",
"preconds": ["know phone number"],
"add": ["in communication with shop"],
"delete": []
},
{ "action": "look up number",
"preconds": ["have phone book"],
"add": ["know phone number"],
"delete": []
},
{ "action": "give shop money",
"preconds": ["have money"],
"add": ["shop has money"],
"delete": ["have money"]
}
]