Professional Documents
Culture Documents
Chapter 3 - Problem Resolution
Chapter 3 - Problem Resolution
Artificial Intelligence
Lecture 3
Karim Bouzoubaa
Introduction
¢ A problem is most often posed in the form of an informal statement, in the
natural language form. Before solving it, it is necessary then, at least for a
resolution by the machine, to carry out a first step of specifying the
problem
¢ Summary:
l No statements: say what (declarative reasoning) and not how
l Bug of K
4L 3L
2L
problem
Its representation
Two cans: can4 and can3, of
respective capacity of 4 and 3 l Possible states (V4, V3) such that
• V4= 0, 1, 2, 3 or 4
liters . None of them is • V3 = 0, 1, 2 or 3
graduated. A pump is available to
fill the cans. How can you get l initial state (0,0)
exactly 2 liters in can4?
l final state (2,n)
9 (V4,V3)→(V4+V3,0) Empty all the water of can4 in can3 If V4+V3≤4 and V3 > 0
10 (V4,V3)→(0,V4+V3) Empty all the water of can3 in can4 If V4+V3≤3 and V4 > 0
0 3 9 (V4,V3)→(V4+V3,0)
3 0 2 (V4,V3)→(V4,3)
3 3 7 (V4,V3)→(4,V3-(4-V4) )
4 2 5 (V4,V3)→(0,V3)
0 2 11 (V4,V3)→(2,0)
2 0 Final state
¢ A control mechanism that selects the rule to trigger among the
applicable rules
l A rule is applicable if its head unifies with the current state
l Many rules may be applicable at a given time
(4,0) (0,3)
2 3 5 8 12 1 4 6 9
(2,X)
Karim Bouzoubaa Artificial Intelligence 10
Prolog Program
¢ A control mechanism selects a rule to trigger among the appliable rules
3 5 8 3 5 8 3 • 8 3 5 8
• 1 6 1 6 • 1 5 6 1 4 6
2 4 7 2 4 7 2 4 7 2 • 7
• 3 8 3 8 •
1 5 6 1 5 6
2 4 7 2 4 7
1 2 3
8 • 4
7 6 5
Karim Bouzoubaa Artificial Intelligence 16
Basic Algorithm
E1
E2 E3 E4
E5 E6
Memory is
E7 E8 E9 managed as a stack
E1
E2 E3 E4
E5 E6 E5 E10
E7 E8 E9
E1
E2 E3 E4
E5 E6
Memory is
E7 E8 E9 managed as a list
¢ Complexity
¢ B : average number of branches en moyenne per node
¢ n : the depth of the tree
Time Space
Depth O(Bn) O(B*n)
¢ Problems
¢ Depth-first: pay attention to endless depth
¢ Breath-first: pay attention to space
6 3 6
2 8 3 2 8 3 2 8 3
1 6 4 1 • 4 1 6 4
• 7 5 7 6 5 7 5 •
0
1 2 3
8 • 4
7 6 5
Karim Bouzoubaa Artificial Intelligence 26
Hill Climbing Variants
¢ Problem with simple Hill climbing
l The algorithm considers only one path
à when the successors are not better than this state, the algorithm stops
¢ Discussion :
l Depth first
l Breadth first
l Hill climbing
l Hill climbing
steep
¢ In general, a local search does not guarantee an optimal solution. Its
attractiveness is above all its ability to find an acceptable solution quickly.
¢ Method
l select the most promising node of all generated nodes
l Perform the expansion of the node using the applicable rules
l Among the successors, if one of them is a solution, stop
l Otherwise, all new nodes are added to all the nodes already
generated
l Again the most promising node becomes the current node
¢ Open contains nodes not yet processed, ie at the boundary of the part of the
graph explored so far.
¢ Closed contains the nodes already processed, ie inside the boundary delimited
by open.
A
A A (3)
(5)
(3)
(5)
(1) B C D
B C D
(4) (6)
E F
A
(5)
A B C D
(5)
(6) (5) (6)
B C D
G H E F
(6) (5) (4) (6)
G H E F (2) (1)
I J
where w is a real number greater than or equal to 0 and less than or equal to 1.
l A* : w = 0.5 (f(n) = g(n) + h(n) ) à Information about nodes and edges
file:///Users/karimbouzoubaa/Data/Courses/AI/demos%20for
%20AI/demos/search/search.html
http://bgrins.github.io/javascript-astar/demo/
https://qiao.github.io/PathFinding.js/visual/
Bellman-‐Ford
Djikstra
informed
search
A*
Itera3ve
deeping
A*
Any3me
Dynamic
A*
Local
search
Hill-‐Climbing
Enforced
Hill-‐Climbing
Hipster-core within
NetBeans
Production rules
private static List<Integer>
applyActionToState(Action action, List<Integer> board) {
switch (action){
// fill can4
case RULE1: successor.set(0, 4); break;
…
}
return successor;
}
Production rules
Control machanism
Step
1:
enumerate
ac3ons
enum Action { RULE1, RULE2, RULE3, RULE4, RULE5, RULE6, RULE7, RULE8,
RULE9, RULE10 }
¢ The more look-ahead is (the deeper in the tree) the better
our evaluation of a position will be
¢ Deep Blue
l 256 specialized chess processors
http://homepage.ufp.pt/jtorres/ensino/ia/alfabeta.html