






























Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!































social, environmental, and natural sciences, can drive computational sustainability in ways that
would not be possible in a smaller or less interdisciplinary setting.
An agent is anything that can be viewed as perceiving its environment through sensors and acting upon
that environment through actuators. The agent function maps percept histories to actions [ 𝑓 ∶ 𝒫
∗
The agent program runs on the physical architecture to produce 𝑓.
Vacuum-cleaner example.
An agent should strive to "do the right thing", based on what it can perceive and the actions it can perform.
The right action is the one that will cause the agent to be most successful. Performance measure: an
objective criterion for success of an agent's behavior. For each possible percept sequence, the rational
agent should select an action that is expected to maximize its performance measure:
Rationality is distinct from omniscience (all-knowing with infinite knowledge). Agents can perform actions
in order to modify future percepts so as to obtain useful information (information gathering, exploration).
An agent is autonomous if its behavior is determined by its own experience (with ability to learn and
adapt). Ideally: equip an agent with some prior knowledge and the ability to learn.
Task environments: the “problems” for which artificial agents are “solutions”. A task environment is
specified by PEAS (Performance measure, Environment, Actuators, Sensors). Must first specify the setting
for intelligent agent design. Example: taxi. Agent: an automated taxi driver.
Fully observable if agent sensors give it access to the complete state of the environment at each
point in time. Partially observable because of noisy, inaccurate sensors. If there are no sensors, the
environment is unobservable.
Deterministic if the next state of the environment is completely determined by the current state
and the action executed by the agent. Strategic if the environment is deterministic except for the
actions of other agents. Stochastic if there is uncertainty on the next state and it is expressed with
probabilities. Non-deterministic if there is uncertainty on the next state but no probabilities are
available. Uncertain if not fully observable and non-deterministic.
Episodic if the agent's experience is divided into atomic "episodes”. Each episode consists of the
agent perceiving and performing a single action. The choice of action in each episode depends only
on the episode itself. Sequential if a current decision may affect future decisions.
Static if the environment is unchanged while an agent is deliberating. No need to keep looking at
the world while deliberating the next action nor worrying about time. Dynamic if continuously
The Table-Driven-Agent program is invoked for each new percept, retains the complete percept sequence
in memory and returns an action each time.
→ Drawbacks: invoked for each new percept, huge table (chess: 10150 entries), takes a long time to build
the table, even with learning need a long time to learn the table entries, who knows how to build it?!
Four basic types of agents in order of increasing generality:
evident in the current percept.
Agent programs consist of various components. The components can represent the environment in three
ways:
i. Atomic representation :
a. Each state of the world is indivisible. It has no internal structure.
ii. Factored representation :
a. Each state contains a fixed set of variables (or attributes).
b. Each variable can have a value.
c. Two different factored states can share some variables.
iii. Structured representation :
a. Each state contains objects (with variables with values) and relations with other objects.
A more expressive representation can capture at least as concisely everything a less expressive one can
capture, plus some more.
Multi agent system is a collection of multiple intelligent agents which interact. Ideally, we would like
intelligent agents to be able to communicate and interact with other agents, so we build societies of
artificial agents by taking inspiration from groups of humans (economics, game theory, and social choice).
Computational social choice: an interdisciplinary field at the interface of artificial intelligence, economics,
voting theory, game theory and social choice. We will see one problem in this area, the matching problems,
that are a mathematical abstraction of two-sided markets.
Matching problems under preferences have been studied widely in mathematics, computer science and
economics. Matching problems with preferences occur in widespread applications (school-leavers to
universities, junior doctors to hospitals, children to schools).
The common thread is that individuals have preferences over the possible outcomes and the task is to find
a matching of the participants that is in some sense optimal with respect to these preferences.
List of topics:
allocation, job markets, and school choice).
project allocation, assigning papers to reviewers, and school choice).
Two sets of agents. Agents of one set express preferences over agents of the other set. The goal is to
choose a matching among the agents of the two sets based on their preferences. Matching: set of pairs
1
2
, where 𝐴
1
comes from the first set and 𝐴
2
comes from the second set.
o Same number of men and women.
o All men totally order all women, and vice versa.
o Greg: Amy>Bertha>Clare.
o Harry: Bertha>Amy>Clare.
o Ian: Amy>Bertha>Clare.
o Amy: Harry>Greg>Ian.
o Bertha: Greg>Harry>Ian.
o Clare: Greg>Harry>Ian.
Find a stable marriage. Marriage is a one-to-one correspondence between men and women. Stable
marriage is a marriage with no pair
not married to each other that would prefer to be
together. Blocking pair is a pair (𝑚, 𝑤), where 𝑚 is a man and 𝑤 is a woman such that the marriage
contains
and
, but 𝑚 prefers 𝑤 to 𝑤’, and 𝑤 prefers 𝑚 to 𝑚’.
o strongly stable marriage may not exist → 𝑂
4
algorithm for deciding existence.
o weakly stable marriage always exists:
▪ just break ties arbitrarily.
▪ run GS, resulting marriage is weakly stable! → polynomial complexity.
Incomplete preferences:
o 𝑚 and 𝑤 are unmatched and do not find each other unacceptable.
o 𝑚, 𝑤 both prefer each other to current partners.
o one of the two is matched but acceptable to the other and prefers the other who is
unmatched.
Weakly stable marriages may have different sizes. Unlike with just ties where they are all complete or with
just incompleteness where the cardinality is fixed.
Finding weakly stable marriage of maximal cardinality is NP-hard even if only men declare ties, ties are of
most of length two and the whole list is a tie.
GS is strategy proof (that is, non-manipulable) for men. Assuming male optimal algorithm no man can do
better than the male optimal solution. However, women can profit from lying (that is, women can obtain a
better partner by expressing different preferences from the true ones)
Manipulation by women
Result of running GS on true preferences Result of running GS on manipulated preferences
→ GS can be manipulated. Every stable marriage procedure (that is, every procedure that returns a stable
marriage) can be manipulated if preference lists can be incomplete. Proof:
Consider:
1
1
2
1
2
1
2
2
1
2
1
2
Two stable marriages:
1
1
2
2
1
2
2
1
Amy lies
Suppose we get male optimal solution → {(𝑚
1
1
2
2
If woman 𝑤 1
lies and says 𝑚
1
is unacceptable then we must get {(𝑚
1
2
2
1
)} as this is the only
stable marriage. Any procedure that returns a stable matching can be manipulated if preference lists can be
incomplete. Other cases can be manipulated in a similar way.
o e.g., sum of distances, number of actions executed, etc.
o 𝑐(𝑥, 𝑎, 𝑦) is the step cost, for going from state 𝑥 to state 𝑦 by performing action 𝑎.
o Assumed to be ≥ 0.
o We assume path costs to be additive: sum of step costs.
Solution : sequence of actions (path) leading from the initial state to a goal state.
Optimal solution : a solution with minimal path-cost.
Problem state space = (initial state, actions, transition model).
State space = the set of all states reachable from the initial state by any sequence of actions.
The state space can be depicted as a directed graph:
Romania example
Vacuum world example
The 8-puzzle example
After defining problems, we need to solve them. A solution is a sequence of actions (path) leading from the
initial state to a goal state.
Search algorithms consider possible sequences of actions. Possible sequences of actions starting from initial
state form a search tree, where the root corresponds to the initial state, the nodes to the states and the
branches to the actions. The same state can appear multiple times! Outgoing edges from a node represent
all possible actions available in the state represented by the node.
Leaf node: a node with no children in the tree.
Frontier: the set of all leaf nodes available for expansion at any given point.
function 𝑇𝑅𝐸𝐸 − 𝑆𝐸𝐴𝑅𝐶𝐻
returns a solution, or failure
initialize the frontier using the initial state of problem
loop do
if the frontier is empty then return failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then return the corresponding solution
expand the chosen node, adding the resulting nodes to the frontier
A redundant path exists whenever there is more than one way to get from one state to another. A loopy
path is a special case of a redundant path.
To avoid exploring redundant paths 𝑇𝑅𝐸𝐸 − 𝑆𝐸𝐴𝑅𝐶𝐻 algorithm is augmented with explored set that
remembers every expanded node.
function 𝐺𝑅𝐴𝑃𝐻 − 𝑆𝐸𝐴𝑅𝐶𝐻
returns a solution, or failure
initialize the frontier using the initial state of problem
initialize the explored set to be empty
loop do
if the frontier is empty then return failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then return the corresponding solution
add the node to the explored set
expand the chosen node, adding the resulting nodes to the frontier
only if not in the frontier or explored set
Search algorithms require a data structure to keep track of the search tree. For each node 𝑛 of the tree, we
have a structure with:
node, as indicated by the parent pointers.
A state corresponds to a configuration of the world, a node is a data structure used to represent the search
tree.
A frontier needs to be stored in such a way that the search algorithm can easily choose the next node to
expand, so the appropriate data structure for this is a queue.
Operations on a queue:
Queues are characterized by the order in which they store the inserted nodes. Three common variants:
i. FIFO queue, which pops the oldest element of the queue.
ii. LIFO queue, which pops the newest element of the queue.
iii. Priority queue, which pops the element of the queue with the highest priority according to
some ordering function.
A search strategy is defined by picking the order of node expansion. Strategies are evaluated along the
following dimensions:
Properties:
A heuristic ℎ is admissible if for every node 𝑛, ℎ(𝑛) ≤ ℎ
∗
(𝑛) where ℎ
∗
(𝑛) is the true cost from 𝑛 to goal.
An admissible heuristic never overestimates the cost to reach the goal.
Theorem : If ℎ is admissible, A* using 𝑇𝑅𝐸𝐸 − 𝑆𝐸𝐴𝑅𝐶𝐻 is optimal.
A heuristic ℎ is consistent if for every node 𝑛, for every successor 𝑛′ of 𝑛 generated by an action 𝑎 , ℎ(𝑛) ≤
′
) + ℎ(𝑛’) → instance of triangular inequality. Consistency → admissibility.
Theorem : If ℎ is consistent A* using 𝐺𝑅𝐴𝑃𝐻 − 𝑆𝐸𝐴𝑅𝐶𝐻 is optimal.
Given two heuristics ℎ 1
and ℎ
2
, if ℎ
2
1
(𝑛) for all node 𝑛 (both admissible) then ℎ
2
dominates ℎ
1
2
is better than ℎ
1
for search, so ℎ
1
will expand all the nodes ℎ
2
expands and possibly more.
A problem with fewer restrictions on actions is called a relaxed problem. A superset of actions is available
from each state → the graph of the relaxed problem is a supergraph of the original.
Any optimal solution of the original problem is also a solution of the relaxed problem, and the cost of an
optimal solution of the relaxed problem may be the same or lower than the cost of an optimal solution of
the original problem.
→ The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem.
Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem.
In many optimization problems the path from the start node to the goal is irrelevant and the goal state
itself is the solution. A state space is the set of "complete" configurations that satisfy constraints. In such
cases, we can use local search algorithms keeping a single "current" state and trying to improve it.
n - queens example
Local search algorithms explore the state-space landscape.
A landscape has:
The aim is to find:
Assume the elevation corresponds to the objective function, Hill-climbing search modifies the current state
to try to improve it.
function 𝐻𝐼𝐿𝐿 − 𝐶𝐿𝐼𝑀𝐵𝐼𝑁𝐺(𝑝𝑟𝑜𝑏𝑙𝑒𝑚) returns a state that is a local maximum
current ← 𝑀𝐴𝐾𝐸 − 𝑁𝑂𝐷𝐸
loop do
neighbor ← a highest-valued successor of current
if neighbor.VALUE ≤ current.VALUE then return current.STATE
current ← neighbor
The algorithm picks a neighbor with the highest value. Usually chooses at random among neighbors with
maximum value and terminates when it reaches a “peak” where no neighbor has a higher value.
Hill climbing often gets stuck for the following reasons:
maximum.
o flat local maximum , from which no progress is possible.
o shoulder , from which progress is possible.
Hill climbing variants:
solution very quickly.
Hill-climbing algorithm that never makes “downhill” moves toward states with lower value is incomplete
because it can get stuck on a local maximum.
Purely random walk : moving to a successor chosen uniformly at random from the set of successors is
complete but extremely inefficient.
Idea → combine hill climbing with a random walk that yields both efficiency and completeness.
In standard search problems, the states are atomic (“black box” with no internal structure), evaluated by
domain-specific heuristics and tested to see whether they are goal states.
In CSPs there is a factored representation for each state:
𝑖
with values from domain 𝐷
𝑖
CSP allows useful general-purpose algorithms to solve complex problems with more power than standard
search algorithms and with general-purpose heuristics rather than problem-specific heuristics.
The main idea of algorithms for solving CSPs is to eliminate large portions of the search space all at once by
identifying variable/value combinations that violate the constraints.
Components:
1
2
𝑛
1
2
𝑛
o Each domain 𝐷
𝑖
consists of a set of allowable values for variable 𝑋
𝑖
o In many cases the domain is assumed to be the same for all variables.
𝑖
𝑖
𝑖
o 𝑠𝑐𝑜𝑝𝑒
𝑖
: subset of 𝑋, the variables that are constrained by 𝑐
𝑖
o 𝑟𝑒𝑙
𝑖
: is a relation and tells us which simultaneous assignments of values to variables in
𝑖
are allowed.
𝑖
𝑖
𝑗
𝑗
o Consistent: it does not violate any constraints.
o Complete: every variable is assigned.
o Partial: only some of the variables are assigned.
Map-Coloring example
In a constraint graph, nodes are the variables and arcs show the constraints.
We formulate a problem as a CSP because it is a natural representation for many problems. We already
have a CSP-solving system → it is often easier to solve a problem using it than to design a custom solution
using another search technique.
CSP solvers are faster than state-space searchers because the CSP solver can quickly eliminate large parts of
the search space by constraint propagation.
Varieties of CSPs:
o Finite domains: 𝑛 variables, domain size 𝑑.
o Infinite domains: integers, strings, etc.
o e.g., job scheduling, variables are start/end days for each job.
o Constraints: StartJob 1
o Common in the real-world problems, studied in the field of operations research.
The simplest kind of CSP involves variables with discrete finite domains.
Varieties of constraints:
Any CSP can be converted into a CSP with only binary constraints.
Cryptarithmetic example
3 - SAT example
4 - Queens problem
Some real-world CSPs: assignment problems (e.g., who teaches what class), timetabling problems (e.g.,
which class is offered when and where?), transportation scheduling, factory scheduling and many real-
world problems involve real-valued variables.
Standard search formulation: let's start with the straightforward approach, then improve it:
assignment → fail if no legal assignments.
This is the same for all CSPs. Every solution appears at depth 𝑛 with 𝑛 variables → use depth-first search.
We could use depth-first search, but for a CSP with 𝑛 variables of domain size 𝑑 we have that the branching
factor (maximum number of successors of a node) 𝑏 is:
i. at 1
𝑠𝑡
level: 𝑛𝑑 because any of 𝑑 values can be assigned to any of 𝑛 variables.
ii. at 2
𝑛𝑑
level: (𝑛 − 1 )𝑑.
iii. ...
iv. at 𝑛
𝑡ℎ
level: 𝑑.
We generate a tree with 𝑛! ∙ 𝑑
𝑛
leaves, even if only 𝑑
𝑛
possible complete assignments.
In CSPs, variable assignments are commutative. Thus, we need only consider a single variable at each level
in the search tree → 𝑏 = 𝑑, so the number of leaves is 𝑑
𝑛
Backtracking search = Depth-first search for CSPs with single-variable assignments.
→ A depth-first search that chooses values for SEARCH one variable at a time and backtracks when a
variable has no legal values left to assign.
function 𝐵𝐴𝐶𝐾𝑇𝑅𝐴𝐶𝐾𝐼𝑁𝐺 − 𝑆𝐸𝐴𝑅𝐶𝐻(𝑐𝑠𝑝) returns a solution, or failure
return 𝐵𝐴𝐶𝐾𝑇𝑅𝐴𝐶𝐾( { }, 𝑐𝑠𝑝 )
function 𝐵𝐴𝐶𝐾𝑇𝑅𝐴𝐶𝐾(𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡, 𝑐𝑠𝑝) returns a solution, or failure
if assignment is complete then return assignment
var ← 𝑆𝐸𝐿𝐸𝐶𝑇 − 𝑈𝑁𝐴𝑆𝑆𝐼𝐺𝑁𝐸𝐷 − 𝑉𝐴𝑅𝐼𝐴𝐵𝐿𝐸(𝑐𝑠𝑝)
for each value in 𝑂𝑅𝐷𝐸𝑅 − 𝐷𝑂𝑀𝐴𝐼𝑁 − 𝑉𝐴𝐿𝑈𝐸𝑆(𝑣𝑎𝑟, 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡, 𝑐𝑠𝑝) do