




























































































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!





























































































Autonomous Agents And Multiagent Systems
5 trends in information technology:
system everywhere.
example: air conditioning system is connected with the cell phone
intelligence: computing systems are more and more complex →as a consequence:
delegation: from human to computing. example: flight from Rio to Paris, the young pilots
were not able to solve the problems cause the panic situation, and because they mostly
used autopilot →they were not able to take the right decision (turn the flight down) →
delegation from human to computer.
interfaces are better and human can interact with the computer in a very easy way.
Consequences of trends:
many entities that are interconnected, intelligent, human oriented.
Multiagent system:
These systems are called agents → a multi agent system is a system composed by more than
one agent: some agents could be human, but we’ll focus on artificial agents.
How agents can interact together:
● operation: reaching some goal
● voting: agent can interact with each other in order to select some candidate (voting
system).
● They only interact together if they know that there are other agents: the decision to do a
particular action is different if i know/don’t know that there are other agents.
We’re the designer of the multiagent system → have to face 2 different problems:
● agent (local) problems : how to develop the single agent
● society problems: how to develop the interactions between agents
Sometimes we’re not allow to design the single agent, and we’re only allowed to design the
interactions. Example: one kind of interaction is asta. If i’m designing a new ebay I’m design a
multiagents systems, with bidders (offerenti, that can be human or artificial) that interacts
according with the rules of the systems. If I’m designing a new ebay I’ve no control of the agents.
In other cases I can develop only the single agents. example: stock market.
Examples:
● sensor network. A system is composed of several sensors, and they’re able to
communicate with each other.
● web services
In this course we will talk about paradigms, abstractions, etc not about a particular technology.
We’re abstracting from technology to an high level view.
We will assume that agents can exchange messages, but we’re not talk about a particular
protocol used by them to communicate.
We’ll see pseudo code, not about an implementation in a particular programming language.
There are 2 main problems:
● local problem (agent problem)
● social problem (interaction between agents)
Local problem: how to develop a single autonomous agent.
What is an agent? There are many definitions about agents, we will refer to a very general
definition: an agent is a computer system that is able to perform autonomous actions in an
environment in order to satisfy/achieve some goals.
E= { e 0 , e 1 , e 2 , …}. The environment can be in any state in E.
These states are not the actual states of the environment, but are the states that an agent can
distinguish. So an environment could have infinite states, but E contains the state that an agent
can recognize. The point of view is from the agent. (e, s, p=perception of the environment).
Ac={a 0 , a 1 , a 2 , ...}. Set of the actions that the agent can perform in the environment.
a 0 a 1
Run r = possible interactions between agent and environment. e 0 → e 1 → e 2 →
From state e 0 , agent acts the actions a 0 that brings the environment to state e 1.
R = set of all the possible runs of an agent in an environment. All the possible sequences of an
interaction with agent and environment at a fixed length, not infinite sequences.
R = set of terminating (finite) runs. R is partitioned in two sets: R
Ac
E
Ac
= all possible sequences terminating with an actions
E
= all possible sequences terminating with an environment state
How we can describe what we know about the environment? We use a transition function called
state transformer function identified by tau: given R
Ac
the function returns a set of states.
P ( E ) = po werset of set E. P ({ 1 , 2 } ) = { {}, { 1 }, { 2 }, { 1 , 2 } }
τ : R ( E ).
Ac
Thus a state transformer function maps a run (assumed to end with the action of an agent) to a
set of possible environment states (those that could result from performing the action).
There are 2 main properties:
states of the environment depends not only from the last actions/state, but depends of
the whole history of the interaction between agents and environment.
the set of possible states → the environment is not deterministic because the new
states are not determined completely, but we’ve a set of possibilities. In some cases we
can have a transition function that is probabilistic ;; this means that τ : R ( E ) where
Ac
△( E ) = probability distribution of states in E → a single state with an expected value.
Agent function
A g : R c
E
Ac could be a single action, no action, or a probability distribution over a set of actions. The
agent function is called also a policy : Ag: E → Ac
Thus an agent makes a decision about what action to perform based on the history of the
system.
Goal
We don’t say how the agent should do, but what the agent is supposed to do using a
performance measure. A performance measure tells what an agent should do and not how an
agent should do. How to tell an agent what do to:
number.
u : E → ℜ.
So larger is the value of the utility function for a state, the better for the agent to be in that
state. The agent always try to maximize the utility function. Agent would like to be in
states with larger utility functions. According to the application I can define an utility
function. In order to define the utility number, this number should balance the cost and the
opportunity for the agent to be in that state.
We’re defining what is a good state, but not the path to reach these good states.
of interaction between agent and environment, it returns a real number.
u : R → ℜ
All these definitions can be put together by defining what is an optimal agent.
The probability that run r occurs when agent Ag is placed in environment Env :
P ( r | A , Env ) where:
g
● r = run
● En v = ( E , e , τ)= set of states, initial state, transition function.
0
Assume this probability is known.
( r | A , Env )
r ∈ R
g
E x pected utility : EU ( A , nv ) ( r ) ( r | A , Env ) g
r ∈ R
u
g
Sum (over all the runs) of the utility of each run r multiplied by the probability that run r has
occurred.
Given an environment and an utility function, how can we define the optimal agent? The optimal
agent in an environment Env is defined as the one that maximizes the expected utility:
g
[ A ∈ AG ]
g
g
where AG is the set of agents and Ag* is the agent function Ag of optimal agent.
The optimal agent is the agent that behave in the optimal way. It tells what is the optimal agent,
but not how we find this optimal agent.
Obvious relation: the sum of T(s, a, s’), T(s, a, s’’), T(s, a, s’’’) = 1
Why this process is a markov decision process? tau τ was history dependent, so given the all
history of interaction between agent and environment will return the next state. A special case of
this general definition is when the next state depends only on the last state.
Expected utility is not defined on all the runs, but on the current state.
If I start from s and perform action a, I would expect some utility and this expected utility is
calculated in this way: probability of going in s’ multiplied by the utility in s’:
The function of the agent in a markov decision process is called Policy π: given a state, the
policy returns an action = the action that the agent should perform in that state. It says which
action it will perform in that state.
Markov decision process (MDP) is defined by the following three elements:
● initial state of the environment s
1
● transition function T
● reward function r : S → ℜ = is a function that maps state to real number.
MDP are usually represented using graphs:
Nodes = states of MDP S={s 1 ,s 2 ,s 3 ,s 4 }
Initial state = s 1
transition functions = arcs
A={a 1 ,a 2 ,a 3 ,a 4 }: some action can be applied in some states, others not.
a 1 +a 1 +.. = 1 , a 2 +a 2 +.. = 1 , etc
s 3 : a 4 , the probability is for sure 1 , since there are no other possibilities.
reward:
r(s 1 )= 0
r(s 2 )= 0
r(s 3 )= 0
r(s 4 )= 1
Time is discrete, and in every time stamp the agent should perform an action. Every time an
agent reaches a state, it gets the reward that is associated with that state.
Example: agent is in s 3 , it performs action a 4 , it goes in s 2 , it gets the reward 0.
Assume to have a fix policy p , and the agent starts from s 1. Is the sequence of states that it will
visit fixed? no because every action is not a deterministic, but it’s stochastic.
An intelligent agent should follow the optimal policy.
π rg max ( s , a , s ) ( s ) the problem is that I don’t know the utility! I know r, but not u.
= a
u ′
The reward is called immediate reward because it gets the reward as soon as the agent reaches
the state. The utility is more complex : it explains the benefit to be in a state → how good is to
be in that state now? how good is to be in this state in the future? The utility is given by:
● the reward of current state
● the reward that i will get starting from s and following the optimal policy.
If I look only at the immediate reward, being in state s 1 and s 4 is the same because the reward is
zero in both cases. Looking at the utilities, I’m not only looking at the immediate reward, but also
at the reward I’ll get in the future → looking at the future, it’s better to be in s 4 because
from s 4 I could go in s 3 and get the reward = 1.
Let’s assume I know the sequence of states I’ll visit in the future (this is not true, I don’t know the
sequence of state, but let’s assume it)
2
3
γ = discount factor ∈ [ 0 , 1 ]
gamma = 1 is safe only if the MDP has a terminal state in which I can only go an never leave.
Bellman equation:
s r(s)
MDP: markov decision process → determine the optimal policy for the agent
How to determine the utilities? Bellman equation allows us to find out what the utilities are.
According with the bellman equation we could write a system and we could try to solve it. But the
system is not linear (because of the max operator) so we cannot apply easily methods for
solving systems.
Let’s see another way to find out the utilities, it’s an algorithmic way called:
Value Iteration Algorithm.
V ALUE − IT ERAT ION ( T , r , γ, ε)
u = is an array that contains the old values of utilities of the states
u’ = is an array that contains the updated (new) values of utilities
in the for the new values of utilities are calculated/updated.
The initialization is storing u’ values into u: the past old values are the new values.
u’ is calculated according to the old value of utilities u(s’).
example:
s 1 s 2 s 3 s 4
u 0 0 0 0
u’ 0 0 1 0
The algorithm works for every initialization of u (example 0 0 0 0 ).
First iteration of the algorithm.
gamma = 0. 5
2 possibility: a 1 or a 2 :
u’(s 1 ) = 0 + 0. 5 *max { 0. 8 * 0 + 0. 2 * 0 ;; 0. 8 * 0 + 0. 2 * 0 } = 0
u’(s 2 ) = ...
2 possibilities from s 3 : a 3 , a 4
u’(s 3 ) = 1 + 0. 5 *max { 1 * 0 ;; 1 * 0 } = 1
Repeat again:
s 1 s 2 s 3 s 4
u 0 0 1 0
u’ 0 0. 4 1 0. 45
u’(s 1 ) = 0 + 0. 5 *max { 0. 8 * 0 + 0. 2 * 0 ;; 0. 8 * 0 + 0. 2 * 0 } = 0
u’(s 2 ) = 0 + 0. 5 *max { 0. 8 * 1 + 0. 2 * 0 ;; 0. 8 * 0 + 0. 2 * 0 } = 0. 5 * max { 0. 8 , 0 } = 0. 4
delta = 0. 45 = maximum change that I have in this iteration.
Repeat again:
s 1 s 2 s 3 s 4
u 0 0. 4 1 0. 45
u’ 0. 18 0. 44 1. 225 0. 4725
When the process ends? It will end when the condition is satisfied → when delta is small
enough, it’s smaller than something depending of gamma and epsilon.
The difference between the real utilities and the utilities calculated in the algorithms (u’) is at
most epsilon.
Delta cannot be setted, because delta is calculated by the difference between old and new
The main idea is that all the decisions of the agents are based on the concept of belief (b). A
belief is a probability distributions over the possible states. This models the fact that the agent
doesn’t know the real state of the environment because its perception are uncertain.
Possible belief state: < 1 / 2 , 1 / 4 , 1 / 4 , 0 >
s 1 s 2 s 3 s 4
The policy of the agent in POMDP starts from a belief and it gets an action.
The set of beliefs state is infinite, so POMDP is equivalent to a MDP in which the set of state is
the set of belief, the POMDP is very hard to solve.
Multiple agent
Sometimes we don’t need to care too much about other agents.
If we have 2 agents, the actions possible are a set of A= {<a 1 , a 2 > } where a 1 is the action of
agent 1 , and a 2 the action of the agent 2.
So we can consider an action as a composite of actions of the single agents.
Ricapitolando MDP:
1
s ∈ S ′
V alue iteration algorithm
In the previous chapters we generally assumed that the world state is fully observable to the
agents. Here we relax this assumption and examine the case where parts of the states are
hidden to the agents. In such a partially observable world an agent must always reason
about his knowledge, and the knowledge of the others, prior to making decisions.
If the state is partially observable, the agent must first consider carefully what he knows and
what he does not know before choosing an action.
In a multiagent system, a rational agent must also be able to think interactively, that is, to take
into account the knowledge of the other agents in his decision making. In addition, he needs to
consider what the other agents know about him, and also what they know about his knowledge.
The puzzle of the hats
Three agents are sitting around a table, each wearing a hat. A hat can be either red or white, but
suppose that all agents are wearing red hats. Each agent can see the hat of the other two
agents, but she does not know the color of her own hat.
A person who observes all three agents asks them in turn whether they know the color of their
hats. Each agent replies negatively. Then the person announces “at least one of you is wearing a
red hat”, and then asks them again in turn. Agent 1 says No. Agent 2 also says No. But agent 3
says Yes!
S = set of possible states = {RRR,RRW,RWR, RWW, WRR, WRW, WWR, WWW}
We know from the description of the game that the real state is RRR.
Cause the partial observability, the agents don’t know that the real state is RRR.
How can we formalize the fact that the agent doesn’t see everything? We use a function Pi:
Pi = perception function of agent i.
We have 3 agents, so we have P 1 , P 2 , P 3.
Perception function is a function that starting from a possible state of the world, return a set of
states of the world:
P ( s ) where P ( s ) owerset of S
i
1
(R RR ) = {R RR ,W RR }. Starting from RRR agent number 1 think that RRR and WRR are
possible states.
2
( R R R )={ R R R , R W R } Description that the agent 2 cannot see the color of its hat.
1
Perception function = formalize that agents don’t have a complete knowledge of the world.
1
1
true state of the world → RRW, RWW are distinguishable (but RWW is not the true state)
1
t= 2
2
t= 2
3
t= 2
To agent number 2 : do u know the color of your hat? No because i’m uncertain between RRR
and RWR, because agent 2 sees RED for agent 1 and agent 3.
So after this answer, agent 3 can say: if the true state is RRW, agent 2 would say YES, so RRW
cannot be the true state of the world, so I can split RRR, and RRW.
RRW is an example, I’ve to repeat for all the other singleton of agent 2 ...
1
t= 3
2
t= 3
3
t= 3
To agent 3 : do u know the color of your hat? Yes, I know the color of my RED! This could happen
only because agent 3 can distinguish everything, all the state are singleton.
At t= 3 the perception function is such that P 3 (RRR) = {RRR}
And agent 1 and agent 2 still don’t know the color of their hat.
Common knowledge is the key for interactive reasoning.
A model of knowledge
Any subset E of S is called an event. E ⊆ S
Agent i knows E in the true state s if it holds Pi(s) ⊆ E. Cioè Pi(s) è contenuto in E, cioè ogni
elemento di Pi(s) è anche elemento di E.
Example:
at t= 0 : P 1 (RRR) = {RRR,WRR}
does agent 1 know that the color of his hat is red? No because {RRR, WRR} ⊆ E 1 is not true!!!
Non è vero che ogni elemento di P 1 (RRR) è anche elemento di “il colore del cappello
dell’agente 1 è rosso”.
P 3 (RRR) = {RRR} ⊆ E 1 so agent 3 knows that the color of agent 1 is RED
Example:
S = {a,b,c,d}
E = any subset of S → E 1 ={a}, E 2 ={a,b}, E 3 ={b,c,d}, etc
Un agente conosce l’evento E se è in grado di distinguerlo, cioè se la Perception function in uno
stato s è contenuta in E.
Knowledge function Ki : Ki(E) given an event E return a set of states in which agent i knows
event E.
i
i
E 2 event: the color of the hat of third agent is RED → XXR. E 2 = {RR R , RW R , WR R , WW R }
k 3 (E 2 ) = {RRR,RWR,WRR,WWR} = E 2
k 1 (E 2 ) ={RRR, ….} = E 2
Let’s define a new event: E 3 = {RRR, RWR, WRR}
24 / 10 / 11 Esercitazione
There’s a single agent and it is characterized by tuples: (S, A, P, R)
where S is the finite set of states of the world
A = actions available to the agent in each specific state
P = transition probability P, a function with three possible arguments:
● current state
● next state
● action performed
Reward, a sort of utility. It’s a function with argument the state of the agent.
If the probability is 1 we omit the probability.
Cumulative reward = ∑ ( s ) where R is the reward
t = 0
i
This sum goes to infinity so we cannot use it. A discount factor is γ ∈ ( 0 , 1 )
t= 1 :
U ( A ) = R ( A ) + γ ( A , , ( A ) ( s )] // Bellman equation
s ′
P s ′ π
Which is the best policy in A? We’ve only one action so (U(A) and U(B) at the previous step:
U ( A ) = R ( A ) + γ ( A , , ) ( s )] ( A ) P ( A , , ) ( A ) ( A , , ) ( B )]
P s ′ α
U ′ = R + γ
[ A α
U + P B α
U ( B ) = R ( B ) + γ ( B , , ( B ) ( s )]
s ′
P s ′ π
the optimal action in state B between gamma and beta
U ( C ) = R ( C ) + γ ( C , , ( C ) ( s )] −
s ′
P s ′ π
t= 2 :
U ( A ) = R ( A ) + γ ( A , , ( A ) ( s )]
s ′
P s ′ π
What is the optimal action the agent can perform in state A? We’ve only one action, alfa:
R ( A ) + γ 1 / 2 ( A ) / 2 ( B ) 2 / 2 1 / 2 2 / 2 ] 5
U ( B ) = R ( B ) + γ ( B , , ( B ) ( s )]
s ′
P s ′ π
Which is the optimal action in state B? We’ve two action: beta and gamma. The utility obtained
by performing beta = ⅔*U(a)+ ⅓ *U(c)= ⅔ * 12 + ⅓ *( 6 ) = 6
The utility obtained by performing gamma = 1 * 0 = 0
The optimal action is beta.
U ( C ) = R ( C ) + γ ( C , , ( C ) ( s )]
s ′
P s ′ π
The optimal action in state C is between delta and iota.
In the case of delta: 1 * 0 = 0
In the case of iota: ⅔ * 12 + ⅓ * ( 6 ) = 8 2 = 6
So the optimal action is action iota.
Esercizio 2
MDP resolved with exact method.
epsilon is the optimal action for state E
Discount factor = 1. This is not a problem because the state F has no outcoming arcs no
available action!
We want to find the exact solution.
The utility of state F is the reward => utility of F = 100
π ( s )
U(B)= 10 + 1 *utilityOfOptimalAction (but we have only one action), so
For D I’ve 2 actions, k and eta
π( D ) ax { 100 , 1 / 2 6 1 / 2 ( D ) } and U(D) is the variable of the problem
= m
Let’s suppose that the optimal action is k or eta.
Suppose that π( D ) , U ( D ) 0 00 0
= k = − 1 + 1 = 9
Suppose that π( D ) , U ( D ) 0 / 2 6 / 2 ( D ) 6
= η = − 1 + 1
So the optimal action is k