Skip to content
EricRothstein edited this page Aug 26, 2016 · 1 revision

A Tutorial Introduction to ICEF

This tutorial explains the Forum.icef example found in the ~/specifications/icef folder. For this tutorial, we assume you to be familiar with the basic concepts of Abstract State Machines (ASMs) and Abstract State Interaction Machines (ASIMs). If you have not read the README, please do so before continuing.

About This Tutorial

We want to implement a very simple forum, where participants can send messages, either confidentially to another participant or broadcast them to all participants. Initially, we have 4 entities: Alice, Bob, the Moderator and the Forum.

Alice and Bob are the initial participants; Alice will broadcast everything she says, and Bob will only talk to Alice.

The Forum is the entity that simulates the environment. The Forum reports the participants to the Moderator so that the latter can make decisions. The Forum will, with a 1% probability, introduce a new participant each round. We explain below how participants behave.

The Moderator is an entity that decides who is to speak next. Participants that want to speak will be acknowledged by the Moderator, and the Moderator will decide one among them who is to speak next.

Detailed Behaviour of Participants

Participants follow a series of rules in order to be able to send messages in the forum. First, let's have a look at the attributes of Participants. Each participant has the following attributes:

  • A name, of type String
  • An ammount of energy, of type Integer
  • A level of tiredness, of type Integer
  • A counter, to count its opinions
  • A Boolean that states whether it is the active speaker or not
  • A Boolean that states whether it wants to talk or not.

During each round, each participant will do a series of operations in parallel:

  • The participant checks whether they got permission to speak, and if so, they update their knowledge on their status of being the active speaker
  • The participant checks whether it received any message(s), and if so, will acknowledge them
  • The participant chooses a level of energy 'e', and if 'e' is smaller than the participant's energy, the participant feels the need to talk. In this way, participants with more energy are more likely to want to talk.
  • If the participant wants to talk and it is the active speaker, then it will express its opinion by sending a message. The opinion counter increases and it loses some energy. Also, it knows that it no longer is the active speaker.
  • If the participant does not want to talk, it will regain some energy.
  • If the energy of a participant goes below its tiredness, it will leave the forum.

Participants in the forum have no internal agents, so we simply use a no-op policy (i.e., skip).

Alice and Bob are special participants, in the sense that they never leave the forum, no matter how tired they are. Alice and Bob also behave differently; Alice broadcasts her opinions and Bob sends his opinions only to Alice.

Detailed Behaviour of the the Forum

The Forum is the entity in charge of broadcasting messages and introducing new participants into the forum. The Forum starts with two participants (Alice and Bob), and will introduce a new participant every round with a probability of 1%. The Forum also reports each round to the Moderator the current participants, so that the Moderator can perform scheduling.

Detailed Behaviour of the the Moderator

Whenever no participant is talking, and there are some participants that want to talk, the Moderator selects among those participants that want to talk and gives them permission.

##The Forum.icef File The Forum.icef file illustrates how ICEF specifications should be written. It's a JSON file that determines the roles of the different ASIMs, which are independently described in the *.casim files.

"id" : "Forum",

"schedulers" : [
		{				 
			"file" : "../casim/Moderator.casim",
			"start" : true
		}
],

"asims" : [

	  {
			"file" : "../casim/Alice.casim",
			"start" : true
		},
	   {
			"file" : "../casim/Bob.casim",
			"start" : true
		},
		{
			"file" : "../casim/Forum.casim",
			"start" : true
		}
]

We recommend to have a look at the Alice.casim, Bob.casim and Forum.casim files in the folder ~/specifications/casim to get a closer look at how the behaviour specified in the previous sections is implemented. These files contain several comments to explain important language constructs, and hints to avoid possible problems while deploying ASIMs with ICEF.

##Exercise: Try to introduce authentication of messages by using the function "getMessageSender" so that Alice only acknowledges messages with subject "Permission" when sent by the moderator. (Hint: The address of the moderator is the string "the Moderator@the Moderator"). Also, make Bob send to Alice a message with subject "Permission" when his energy level is below 50.