This package contains the DBI Agent extensions.
Prerequisites:
- Git 2.15 or higher
- SBT 0.13.16 or higher
- JDK 1.8 or higher
- Internet connection
Steps:
- Open the command prompt (terminal on ubuntu)
- Clone this repository using:
git clone https://github.com/AjroudRami/PFE.git
- Go to the
PFE/extension
directory - Run
sbt package
If the build success, you will find a zip file in the extension directory. Unzip this file in your NetLogo install directory in NetLogo-version/app/extensions
.
This extension adds DBI Agents to NetLogo.
Here is an example of usage. Replace the filename variable by the filename.
to setup
import
formulas
end
to import
set agent dbi:DBIAgent-import "filename"
end
to formulas
let viable dbi:PropositionalFormula-fromAtom dbi:PropositionalAtom "viable"
let fertile dbi:PropositionalFormula-fromAtom dbi:PropositionalAtom "fertile"
let accessible dbi:PropositionalFormula-fromAtom dbi:PropositionalAtom "accessible"
let notOp dbi:Operator "not"
let notViable dbi:PropositionalFormula notOp viable
let notFertile dbi:PropositionalFormula notOp fertile
let notAccessible dbi:PropositionalFormula notOp accessible
dbi:DBIAgent-updateBelief agent dbi:Fact-fromFormula notViable 1
dbi:DBIAgent-updateBelief agent dbi:Fact-fromFormula fertile 0.25
dbi:DBIAgent-updateBelief agent dbi:Fact-fromFormula accessible 0.2
end
to showAgent
show agent
end
to showAgentGoals
foreach (dbi:DBIAgent-goalsAsLogoList agent) [
fact -> foreach ( dbi:Formula-getAtoms dbi:Fact-getFormula fact) [
atom -> show dbi:Atom-getName atom
]
]
end
dbi:DBIStorage-init
dbi:DBIStorage-add
dbi:DBIStorage-remove
dbi:DBIStorage-update
dbi:DBIStorage-get
dbi:DBIAgent
dbi:DBIAgent-import
dbi:DBIAgent-updateBelief
dbi:DBIAgent-export
dbi:DBIAgent-goalsAsLogoList
dbi:DBIAgent-desires
dbi:DBIAgent-believes
dbi:DBIAgent-goalsAsFactSet
dbi:Formula
dbi:Formula-fromAtom
dbi:Formula-fromFact
dbi:Operator
dbi:Operator-toExtensionType
dbi:PropositionalFormula
dbi:PropositionalFormula-fromAtom
dbi:Fact-fromFormula
dbi:Fact-negate
dbi:Fact-getFormula
Description:
Initialize the DBIStorage. Must be called before any other DBIStorage primitive.
Example code:
dbi:DBIStorage-init
Description: Adds a new DBIAgent to the DBIStorage. The agent is identified by the given name.
arguments:
- DBIAgent: the agent to store
- String: a save name
Example code:
dbi:DBIStorage-add agent "name"
Description: Remove an Agent stored in the DBIStorage.
argument:
- String: a save name
Example code:
dbi:DBIStorage-remove "name"
Description: Replace a DBIAgent in the storage.
argument:
- String: A save name
Example code:
dbi:DBIStorage-update agent "name"
Description: Returns the DBIAgent corresponding to the given name. If the agent doesn't exist, it throws an ExtensionException.
argument:
- String: A save name
returns: a DBIAgent
Example code:
dbi:DBIStorage-get "name"
Description: Create an empty DBIAgent.
returns: DBIAgent
Example code:
dbi:DBIAgent
Description: Import a DBIAgent from an apl file. An Exception can occur if the filename is incorrect or if an error occurs during the file reading.
argument:
- String: the path to the filename to import
returns: DBIAgent
Example Code:
dbi:DBIAgent-import "filename"
Description: Performs belief revision according to a new piece of information (a fact) told by a source with given degree of trust.
arguments:
- DBIAgent: the agent to update
- Fact: the new Fact to tell
- TruthDegree: the fact's truth degree
Example code:
dbi:DBIAgent-updateBelief agent fact truthDegree
Description: Export the DBIAgent to a file. An Exception can occur if the file can't be created.
arguments:
- DBIAgent: the agent to export
- String: the path to the filename
Example code:
dbi:DBIAgent-export agent "filename"
Description: This reporter returns the agent's goals as a LogoList. This LogoList is a list of Fact that can be iterated over in NetLogo using a foreach loop.
arguments:
- DBIAgent: the agent to retreive the goals
returns: LogoList of Facts
Example code:
dbi:DBIAgent-goalsAsLogoList agent
Description: This reporter returns the agent's goals as a Factset. This Factset that can't be iterated over in NetLogo. It is mostly used to get a TruthDegree using the dbi:Factset-membership reporter.
arguments:
- DBIAgent: the agent to retreive the goals
returns: Factset: the agent's goals as a Factset
Example code:
dbi:DBIAgent-goalsAsFactSet agent
Description: This primitive returns the agent's desire truth degree for a fact as a number ( [0,1] ).
arguments:
- DBIAgent: the agent
- Fact: the fact to retreive the truth degree
returns: A number between 0 and 1.
Example code:
dbi:DBIAgent-desires agent
Description: This reporter takes an agent and a fact and returns the belief factor of the agent for this fact.
arguments:
- DBIAgent: the agent
- Fact: the fact to retreive the truth degree
returns: A number between 0 and 1.
Example code:
dbi:DBIAgent-believes agent
Description: Create an Atom by it's name.
argument:
- String: the Atom's name
returns: Atom
Example code:
dbi:Atom "name"
Description: This primitive returns the given Atom's name. It can be usefull for handling the decision taken by the DBIAgent in the Netlogo code as the name can stand for a purpose (ex: "buy", "sell", ...)
argument:
- Atom: the atom
returns: String: the Atom's name
Code example
dbi:Atom-getName atom
Description: Create a Formula object.
arguments:
- Operator: an operator of arity n
- LogoList: a list of n Formula
returns: Formula: a logical formula
Example code:
dbi:Formula operator formulaList
Description: Create a Formula object from an Atom. The resulting formula is called atomic and only composed of the atom. This formula does not contain any Operator.
argument:
- Atom: the atom to create a formula from
returns: Formula: a formula
Example code:
dbi:Formula-fromAtom atom
Description: Create a Formula object from a Fact.
argument:
- Fact: a fact
returns: Formula: the created formula
Example code:
dbi:Fact-fromFact fact
Description: Create an Operator. This method takes different types of arguments. The two ways to create an Operator are:
- Create a default Operator (AND, OR, NOT, XOR) by using only one argument, the operator name as a String. Example:
dbi:Operator "not"
- Create a custom Operator by specifying two arguments: a name (String) and its arity (integer). Example:
dbi:Operator "myOp" 2
returns: Operator: The created Operator
Description:
the ExtensionType reporter are primitives used to display informations about the object. It's the toString()
equivalent. It should be used only to display objects using the primitive show
.
argument:
- Operator: an operator object
returns: an ExtensionObject containing an Operator
Example code:
dbi:Operator:toExtensionType
Description: Create a PropositionalFormula object. The number of formulas given in the arguments must match the operator arity
arguments:
- Operator: a root operator
- Formula: one or more formula
returns: PropositionalFormula: a propositional formula
Example code:
dbi:PropositionalFormula andOp formula1 formula2
dbi:PropositionalFormula not formula
Description: Create a PropositionalFormula from an Atom. The returned formula is atomic.
argument:
- Atom: an atom
returns: PropositionalFormula: a propositional formula
Example code:
dbi:PropositionalFormula-fromAtom atom
Description: Create a PropositionalAtom by it's name.
argument:
- String: the atom's name
returns: PropositionalAtom: the created propositional atom
Example code:
dbi:PropositionalAtom "name"
Description: Create a Fact objet from a Formula. Facts can be used to update agent beliefs.
argument:
- Formula: a formula
returns: Fact: a fact
Example code:
dbi:Fact-fromFormula formula
Description: Returns the given fact's negatation.
argument:
- Fact: the fact to negate
returns: Fact: the fact's negation
Example code:
dbi:Fact-negate fact
Description: Returns the Fact's formula. Usefull to extract DBIAgent's goals.
argument:
- Fact: a fact
returns: Formula: the fact's formula
Example code:
dbi:Fact-getFormula fact
Description: Returns the Fact's TruthDegree.
argument:
- Factset: a fact set
- Fact: the fact to retreive the truth degree
returns: TruthDegree: the fact's truth degree
Example code:
dbi:Factset-membership
Description: Reporter used to retreive a truth degree as a number between 0 and 1.
argument:
- TruthDegree: the truth degree to convert
returns: Number between 0 and 1
Example code:
dbi:TruthDegree-doubleValue
Description: Util function used in the NetLogo simulation to remove duplicate patches (same id) in a LogoList of Patches
argument:
- LogoList of Patches
returns: LogoList of Patches
Example code:
dbi:Utils-removeDuplicates logoList