An Agent and Its Threads

26
communication thread core thread Spawn N negotiation threads ... negotiation threads active inactive Initialize An Agent and Its Threads execution thread

description

An Agent and Its Threads. Initialize. Spawn N negotiation threads. inactive. active. communication thread. negotiation threads. execution thread. core thread. Communication Thread. Get message via socket. Message?. no. yes. Parse message. Message queue. - PowerPoint PPT Presentation

Transcript of An Agent and Its Threads

Page 1: An Agent and Its Threads

com

mun

icat

ion

thre

ad

core

thre

ad

Spawn Nnegotiation

threads

...

nego

tiat

ion

thre

ads

active

inactive

Initialize

An Agent and Its Threads

exec

utio

n th

read

Page 2: An Agent and Its Threads

Communication Thread

Get message via socket

Parse message

Message?

yes

no

Add tomessage

queue...

Message queue Accesses by other threadsof the agent

Page 3: An Agent and Its Threads

Execution Thread

Setup andReset

yes

no

Get first jobFrom queue

...Job queue

Accesses by core threadof the agent

job’s startTime<currentTime?Sleep

ApplyExecutionheuristics

Abandon?

Execute

no

yes

RemoveJob

Executed?

Wait for data to be uploaded

yes

Remove job

ApplyPersistenceheuristics

no

Commited?

Sleep

no

yes

from job queue

from job queue

Page 4: An Agent and Its Threads

Execution Thread: Execution Heuristics

Time ConflictIf the job is not a tracking task and the expected stop time is later than the start of the next job plus a predefined relax_time, then Abandon = true.

Negotiation ConflictIf the job is not a tracking task and the agent iscurrently initiating a tracking coalition, thenAbandon = true.

Look-Ahead ConflictIf the job is not a tracking task and the agent has atracking task already planned for the near future,then Abandon = true.

Page 5: An Agent and Its Threads

Execution Thread: Persistence Heuristics

Persistent CommitmentIf the job is a tracking task and tracking is stillviable, then Committed = true.

Page 6: An Agent and Its Threads

Execution Thread: Execution Behavior

SD1, SD2, SD3

Task type?

Searchand Detect

TargetDetected?

CalibrateSensor

TargetDetected?

C1, C2, C3

Do nothing SuccessI

MeasureInitial Target

TargetDetected?

M1, M2, M3

Track

TargetDisappeared

orTerminatedas planned

T1, T2, T3

Executed= true

Executed= true

Executed= true

Executed= true

Executed= true

Jobconfirmed?

yes

Executed= false

no

Page 7: An Agent and Its Threads

Core Thread

Setup

Check Messages

Check Tasks

Check Execution

Check Coalition

Page 8: An Agent and Its Threads

Core Thread: Setup

SetupProfile

Managerinitializes the agent’s statusand configures its neighbors

CommManager

sets up comm. channel with Radsim, createsa socket, allocates msg. queue, sets msg. observer,and activates receiver

TaskManager

ThinkManager

NegotiationManager

spawns all negotiation threads and links data toeach thread; CLIPS processes are forked and pre-defined templates and rules are loaded

RTSSManager

sets up data stream access for Real-Time Scheduling Service (RTSS) interface and registersthreads and agent process IDs

CBRManager

loads two case bases, for initiating and responding cases of negotiation

RadarManager

initializes the sensor that the agent controls,measures background noise for each sector, turns on the radar observer, adds all neighboringsensors to its radar model

has a lesser role now because the radar tasksare managed by the Execution Manager

ExecutionManager

sets up the execution thread and executes tasksoff the job queue

CoalitionManager initializes the coalition vector

Page 9: An Agent and Its Threads

Core Thread: Check Messages

Accessmessage

queue

msg. forprof?

Parsemessage

messagetype

yes

Check messagescompleted

no

A negotiation request

Check messagescompleted

ActiveNegotiation?

Discardmessage

no yes

An acknowledgment

Respondto request

Respondto ack

Page 10: An Agent and Its Threads

Core Thread: Check Messages: Respond to Ack

Ack type?

Confirm tracking

task

Confirm

completed

Discardtracking

task

Discard

acknowledgment

...Job queue

Page 11: An Agent and Its Threads

Core Thread: Check Messages: Respond to Request

CPU?

FeasibilityStudy

Feasible& neg. idle?

yes

no

request

no

already doing?

Agreeto request

yes

no

Declineto negotiate

Modifyrequest?

yes

yesno

ModifyRequest

Retrieve best casevia CBR

Upload data

Activatenegotiation

threads

threadactivated? completedno yes

Page 12: An Agent and Its Threads

Core Thread: Check Tasks (Negotiation Tasks Only)

Status?

Initiating &success

Negotiation task

CheckTasks

Completed

Download &UpdateData

StoreCase

UpdateCoalition

RemoveTask

Download &UpdateData

StoreCase

UpdateCoalition

RemoveTask

ClearNegotiation

Thread

Download &UpdateData

StoreCase

TransitionTask

Download &UpdateData

StoreCase

RemoveTask

Initiating &failure

Responding &success

Responding &failure

...Task queue

Page 13: An Agent and Its Threads

Core Thread: Check Tasks:Update Coalition

If the negotiation is successful, the update involves modifying the coalition informationto reflect the success.

If the negotiation is not successful, the updateremoves the coalition member (the negotiationpartner) from the coalition.

Page 14: An Agent and Its Threads

Core Thread: Check Tasks:Transition Task

CPU?yes

New task

no

ConfigureTracking

Task

ReorganizeThread

Allocation

InsertTask to

Job Queue...

Job queue

Clean upJob Queue

RemoveTask

Page 15: An Agent and Its Threads

Core Thread: Check Execution

A job iscompleted?

no

Execution thread’s current status

yes

CheckExecutionCompleted

Job type?

ClearExecution

Thread

ClearExecution

Thread

FinishMeasure

Init. Target

Clear Execution

Thread

Calibrate SensorOr Search and Detect

MeasureInitial Target

Tracking

Idle

Targetdetected?

HandleTarget

CheckExecutionCompleted

Page 16: An Agent and Its Threads

Core Thread: Handle Target

ConfigureMeasuring

Task

InsertTask to

Job Queue

Handletarget

completed

success?

Clean upJob Queue

yes

...

Job queue

Page 17: An Agent and Its Threads

Core Thread: Finish Measure Initial Target

Updatetarget w/

Radar Manager

Computesensor-sector

list

Determinesample size

Analyzefeasiblepartners

Initiatenegotiations

completed

Targetdetected?

completedno

Clear Execution

Thread

Execution thread’s current status

DownloadTarget

Information

yes

Page 18: An Agent and Its Threads

Core Thread: Initiate Negotiations

Retrievebest casevia CBR

completed

Uploaddata

Sort feasiblepartners(utility)

Neg.thread idle?

Activatenegotiation

thread

threadactivated?

yes

yes

no

no

Createnegotiation

task

Initializecoalition

For allpartners

Updatecoalition

Done

Add task totask queue...

Task queue

Page 19: An Agent and Its Threads

Core Thread: Check Coalition

decided?no

Coalition’s current status

yes

CheckCoalition

Completed

coalitionfulfilled?

Acknowledgeto DiscardCoalition

Acknowledgeto ConfirmCoalition

ConfigureTracking

Task

ConfirmCoalition

no

Send to allagreed coalitionmembers

DiscardCoalition

yes

Insert it toJob Queue

Clean upJob Queue

Confirmthe Task

Send to allagreed coalitionmembers

...

Job queue

Page 20: An Agent and Its Threads

Negotiation Thread

Setupand Reset

Wait to beactivated

Downloaddata

RespondingBehavior

Mode?

Responding to a negotiation request

Initiating a negotiation request

InitiatingBehavior

Updatedata

Wait fordata to be uploaded

Page 21: An Agent and Its Threads

Negotiation Thread: Initiating Behavior

Composefirst initiating

message

Done?

Done = no

SendMessage

Wait forresponse

response?

Parseresponse

React & ComposeMessage

no

yes

yes

noReact &composemessage

Negotiationcompleted

Check Coalition

abort?yes

no

time?expired

still okay

Page 22: An Agent and Its Threads

Negotiation Thread: Initiating Behavior:Check Coalition

If the coalition has gathered enough help forCPU reallocation, then Abort = true.

If the tracking coalition has been satisfied, thenAbort = true.

If the tracking coalition is no longer possible, then Abort = true.

Page 23: An Agent and Its Threads

Negotiation Thread: Initiating Behavior:React & Compose Message

type?

Response message

CheckCoalition

Acceptability

modify time

accept?

Failure

no

UpdateCoalition

Initiate

yesFailure

no goout of timestop

CheckCoalition

Acceptability

accept?

UpdateCoalition

Success

yes

counter

agree ComposeMore Info

more info

no

null?

Info_Null Info

yes no

Page 24: An Agent and Its Threads

Negotiation Thread: Responding Behavior

Composefirst responding

message

Done?

Done = no

SendMessage

Wait forresponse

response?

Parseresponse

React & ComposeMessage

no

yes

yes

noReact &composemessage

Negotiationcompleted

time?expired

still okay

ResetCLIPS

Page 25: An Agent and Its Threads

Negotiation Thread: Responding Behavior:React & Compose Message

type?

Response message

info

yes

abortout of timestop

yes

agree

yes

infonull

CLIPS:Rule-BasedReasoning

Computeevidencesupport

> persuas.thresh?

Agree

More Info

no

CPU?

no

ReactCPU

CPU?

Counter

Stop

no

Failure

Success

Page 26: An Agent and Its Threads

Negotiation Thread: Responding Behavior:React CPU

If the current CPU willing to give up is greater than or equal to the desired CPU (by theinitiator), and the desired CPU is smaller than or equal to the maximum CPU willing to give up, then Agree.

If the current CPU willing to give up is greaterthan the maximum CPU willing to give up, thenCounter with maximum CPU willing to give up.

If time allocated for the negotiation is runningout, then Counter. If the current CPU willing togive up is grater than the maximum CPU willing to give up, Counter with the latter value. Otherwise, Counter with the former.