|
|
Decision
From VLE
Development of knowledge base
The knowledge can be manipulated with predicate functions, output functions and on the activity state changes. To define a knowledge base of agent, the C++ syntax is:
#include <vle/extension/Decision.hpp>
namespace vmd = vle::extension::decision;
class Agent : public vmd::Agent
{
public:
Agent(const vle::devs::DynamicsInit& mdl,
const vle::devs::InitEventList& evts)
: vmd::Agent(mdl, evts)
{
addFacts(this) +=
F("fact 1", &Agent::update),
F("fact 2", &Agent::update);
addPredicates(this) +=
P("pred 1", &Agent::isAlwaysTrue),
P("pred 2", &Agent::isAlwaysTrue),
P("pred 3", &Agent::isAlwaysTrue),
P("pred 4", &Agent::isAlwaysTrue);
addOutputFunctions(this) +=
O("output function 1", &Agent::out),
O("output function 2", &Agent::out);
addAcknowledgeFunctions(this) +=
A("ack function 1", &Agent::ack),
A("ack function 2", &Agent::ack);
}
virtual ~Agent() {}
void update(const value::Value&)
{
/* modification of object state */
}
bool isAlwaysTrue() const
{
/* return true or false in function of object state */
}
void ack(const std::string&, const Activity&)
{
/* reaction of change of activity state */
}
void out(const std::string&, const Activity&,
vle::devs::ExternalEventList&)
{
/* creation of a customized message for a connected model to the activity */
}
};
Definition language of activities plan
# the character `#' is the comment symbol. All characters after symbol are ignored.
rules {
rule {
id = "identifiant" ;
predicates = "", "", "", "" ;
}
... # rule list.
}
activities {
activity {
id = "identifiant" ;
rules = "", "", "", "" ; # optional, name of rule
temporal { # optional, by default start = -infinity and finish = infinity.
start = 1; # 1
finish = 7; # 2
minstart = 2; # 3
maxstart = 3; # 4
minfinish = 5; # 5
maxfinish = 6; # 6
# a configuration : (1, 2) ou (1, 5, 6), ouo (2, 3, 4) ou (3, 4, 5, 6).
# a real or -infinity ou infinity
}
ack = ""; # optional (link with C++ code).
output = ""; # optional (link with C++ code).
}
... # activity list
}
precedences {
precedence {
type = SS | FF | FS; # start start, finish finish ou finish to start.
first = "activity source";
second = "activity destination";
mintimelag = 0; # a positive real or equal to 0 or infinity.
maxtimelag = infinity; # a positive real or infinity.
}
... # precedence constraint list.
}
|