DIT410/TIN174, Artificial Intelligence
Peter Ljunglöf
25 April, 2017
A very common evaluation function is to use a weighted sum of features: \[ Eval(s) = w_1 f_1(s) + w_2 f_2(s) + \cdots + w_n f_n(s) = \sum_{i=1}^{n} w_i f_i(s) \]
A naive weighted sum of features will not see the difference between these two states.
Chess:
Checkers/Othello/Reversi:
Go:
Imperfect information games
e.g., card games, where the opponent’s initial cards are unknown
typically we can calculate a probability for each possible deal
seems just like having one big dice roll at the beginning of the game
main idea: compute the minimax value of each action in each deal,
then choose the action with highest expected value over all deals
where \(P(a)\) is the probability that action a occurs.
Variables: | WA, NT, Q, NSW, V, SA, T |
Domains: | \(D_i\) = {red, green, blue} |
Constraints: | SA≠WA, SA≠NT, SA≠Q, SA≠NSW, SA≠V, WA≠NT, NT≠Q, Q≠NSW, NSW≠V |
Constraint graph: | Every variable is a node, every binary constraint is an arc. |
Variables: | F, T, U, W, R, O, \(X_1, X_2, X_3\) |
Domains: | \(D_i\) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} |
Constraints: | Alldiff(F,T,U,W,R,O), O+O=R+10·\(X_1\), etc. |
Constraint graph: | This is not a binary CSP! The graph is a constraint hypergraph. |
The general-purpose algorithm gives rise to several questions:
Heuristics for selecting the next unassigned variable:
Minimum remaining values (MRV):
\(\Longrightarrow\) choose the variable with the fewest legal values
Degree heuristic (if there are several MRV variables):
\(\Longrightarrow\) choose the variable with most constraints on remaining variables
Heuristics for ordering the values of a selected variable:
remove | \(D_A\) | \(D_B\) | \(D_C\) | add | queue |
---|---|---|---|---|---|
1234 | 1234 | 1234 | A<B, B<C, C>B, B>A | ||
A<B | 123 | 1234 | 1234 | B<C, C>B, B>A | |
B<C | 123 | 123 | 1234 | A<B | C>B, B>A, A<B |
C>B | 123 | 123 | 234 | B>A, A<B | |
B>A | 123 | 23 | 234 | C>B | A<B, C>B |
A<B | 12 | 23 | 234 | C>B | |
C>B | 12 | 23 | 34 | \(\emptyset\) | |
What if some domains have more than one element after AC?
We can resort to backtracking search:
Do we need to restart AC from scratch?
There are several kinds of consistency properties and algorithms:
Node consistency: single variable, unary constraints (straightforward)
Arc consistency: pairs of variables, binary constraints (AC-3 algorithm)
Path consistency: triples of variables, binary constraints (PC-2 algorithm)
\(k\)-consistency: \(k\) variables, \(k\)-ary constraints (algorithms exponential in \(k\))
Consistency for global constraints:
Do you remember this example?
To choose a variable to change and a new value for it:
All local search techniques from section 4.1 can be applied to CSPs, e.g.:
Suppose that each subproblem has \(c\) variables out of \(n\) total.
The cost of the worst-case solution
is \(n/c\cdot d^{c}\), which is linear in \(n\).