User:Wgibaut/sandbox

MECA (Multipurpose Enhanced Cognitive Architecture) is a cognitive architecture, originally created by Ricardo Gudwin and his research group at Unicamp and is currently improved and maintained by the same research group.

MECA is designed to integrate many lessons acquired from other cognitive architectures. Among these lessons, the use of codelets (just like in LIDA) as the building blocks of processing, and a mechanism inspired on Global Workspace Theory to implement a machine consciousness cognitive capability (similarly but not exactly equals to the one in LIDA), the requirement to have both explicit and implicit knowledge representations (just like in  CLARION), considering rule-based processing (just like in SOAR ) as an explicit processing modality, together with a dynamic subsumption-like processing as an implicit processing modality, with the potential to include also neural networks like  HTM within some of its modules. It gets inspiration from hybrid cognitive architectures, like SAL (Synthesis of ACT-R and Leabra), which combined both a rule-based architecture ACT-R with a neural network one (Leabra) in order to compose a more powerful architecture, and mostly a strong inspiration on dual process theory, which recently is being explored under the context of cognitive architectures. It also relied on important theories regarding knowledge representation, including Grounded Cognition, Conceptual Spaces and Computational Semiotics, extending some recent work indicating the relevance of extended kinds of representation beyond the traditional symbolic rule-based processing and multi-layered backpropagation neural networks.

Dual Process Theory
The name Dual Process Theory relates to a convergent set of theories in Cognitive Psychology about modeling higher cognition within largely disconnected literature in cognitive and social psychology. All these theories have in common the distinction between cognitive processes that are fast, automatic and unconscious, and those that are slow, deliberative and conscious. A number of authors have suggested that there may be two architecturally (and evolutionarily) distinct cognitive systems underlying these dual-process accounts. According to Dual Process Theory, the mind can be described by the interaction of two different systems, named System 1 and System 2, which assume two functionally distinct roles, which integrate to each other, in order to account for the different facets of the mind phenomena. The exact characteristics of System 1 and System 2 varies depending on the theory proposers.

System 1 is generally described as a form of universal cognition shared between humans and animals. It is not actually just a single system, but a set of sub-systems operating with some kind of autonomy. System 1 includes instinctive behaviors that might be innately programmed and also automatic learned behaviors evolved during the system interaction with its environment. System 1 processes are rapid, parallel and automatic in nature: only their final product is posted in consciousness.

System 2 is believed to have evolved much more recently and is considered by many to be uniquely human. System 2 thinking is slow and sequential in nature, and makes use of the central working memory system, intensively studied in psychology. Despite its limited capacity and slower speed of operation, System 2 permits some kinds of abstract hypothetical thinking that cannot be achieved by System 1, as e.g. decision-making using past experiences to abstract new behaviors and the construction of mental models or simulations of future possibilities, in order to predict future events and behave accordingly to reach desirable situations or prescribed goals. Despite their intrinsic autonomy, System 1 and System 2 interact with each other in order to build the overall system behavior.

Subsumption architecture
The Subsumption Architecture is a generic name for a family of computational architectures used in intelligent control (particularly in robotics), developed by Rodney Brooks in the 90s, which gave rise to the whole Behavior-based Robotics research field. In the Subsumption Architecture, once a behavior is in a higher level, it will always have priority in setting up its behavior. Even though this is desirable in some situations, it is always possible to envision situations in which this priority should be reversed, at least in special occasions. This is not possible in classical Subsumption Architecture. To deal with this difficulty, some authors proposed a Dynamic Subsumption scheme, in which there is no fixed dominant input in a suppression node, but this dominance can be changed dynamically in time, according to specific situations.

Grounded Cognition
One important theoretic background regarding the issue of knowledge representation is the theory on Grounded Cognition, provided by Barsalou.

Most classic artificial intelligence (AI) studies relied on the concept of symbol, using symbolic logic as a background. Propositions, predicates, rules, features lists, frames or semantic networks are typical examples of such structures, most of them defined by an external expert. One of the main criticisms to classic AI was this requirement for a “human in the loop”, either acquiring and setting up knowledge, or interpreting the system results. It is not possible to say that these systems (using classic AI) really “understand” the meaning of symbols they use. Barsalou draws our attention to the fact that these symbols are amodal and arbitrary. Their internal structures bear no correspondence with the perceptual states that produced them and therefore they are linked arbitrarily. Thus, amodal symbols always require additional representational structures to express meaning.

Fortunately, Computational Intelligence (CI) came for the rescue, with its many algorithms for classification, categorization, clustering and grouping, based on partial or vague information, and suitable to provide cumulative layers of perception in terms of abstractions of input signals. E.g., neural networks (or fuzzy systems) can be directly connected to sensors and actuators (i.e. connected to the “real world”), and so provide this link to reality which was missing in classic AI. But now we are on the opposite side of the problem. Where are the symbols within a neural network or a genetic algorithm? Are they symbols for the system, or are they symbols for the system designer?

To address this issue, the Perceptual Symbol System theory proposed by Barsalou assumes that the meaning of symbols occurs by the re-enactment of experiences aroused during the acquisition of concepts from the real world.

Barsalou explains that this comprises a new category of symbols, which he calls perceptual symbols. In the human mind, perceptual symbols might be associated to dynamic neuronal patterns, in structures he names simulators. Differently from amodal symbols, perceptual symbols are analogical and modal, because they are directly represented by the perceptual states which produce them. Consequently, a representational system based on both kinds of symbols, supports both perception and cognition, without the requirement of a human expert to ground them.

Conceptual spaces
A second theory which is also related to knowledge representation is the theory of Conceptual Spaces from Gärdenfors. This semantic theory considers that the mind organizes in- formation involved in perception, attention, categorization and memory, using geometric and topological properties, in order to derive the notion of conceptual spaces.

Conceptual spaces are metric spaces providing a robust mechanism for learning and representing the meaning of different classes of words (e.g. categories of objects). According to Gärdenfors, an unified theory of meaning about different word classes can be developed when conceptual spaces are used to provide linguistic grounding.

According to Gärdenfors, concepts are mathematical structures which fully represent the meaning of words. The most common kind of concepts are object categories, but there might be concepts associated to qualities, actions, events and possibly to all categories of words and special combinations of words as well. Concepts are defined with the help of conceptual spaces, and conceptual spaces are constructed out of quality dimensions. The primary role of these dimensions is to represent various “qualities” of objects in different domains.

Also according to Gärdenfors, the use of conceptual spaces provides a different approach when compared to symbolic AI. In symbolic AI, the assignment of semantics to symbols requires an external interpretation. In the current approach, the semantics is implicit in the definition of conceptual spaces. Therefore, the use of conceptual spaces might be a possible aid for the solution of the symbol grounding problem.

Architecture
The conception of MECA inherits a lot of insights coming from different sources. Most of them were previously presented in Section ‘Foundational background’. First of all, MECA is an instance of the Dual Process Theory. This means that MECA is split into two major sub-systems, System 1 and System 2.

An overview of the architecture
An overview of the MECA Cognitive Architecture can be seen in Fig. 1. The architecture is specified following the CST Reference Architecture. The whole architecture is split into two major sub-systems, as indicated in Fig. 1: System 1 and System 2. These two sub-systems ex- change some information, such that they interact with each other in order to generate its overall behavior. The architecture is designed as a network connecting 4 kinds of elements: codelets, memory objects, containers (a special kind of memory object) and memories. System 1 is comprised by three different memories: Sensory Memory, Perception Memory and Motor Memory. There are many subsystems accessing those memories, which are indicated by codelets of different kinds:
 * Sensory Subsystem: Sensory Codelets.
 * Motor and Behavior System: Behavioral Codelets and Motor Codelets.
 * System 1 Motivational Subsystem: Motivational Codelets, Mood Codelets, Emotional Codelets.
 * Perceptual Subsystem: Perceptual Codelets, Attention Codelets. System 2 comprises basically 5 different memories: Perceptual Buffer, Episodic Buffer, Episodic Memory, Working Memory and Procedural Memory. Also, there are many subsystems accessing those memories, implemented by different kinds of codelets:
 * Episodic Subsystem: Attention Codelets, Episodic Learning Codelet and Episodic Retrieval Codelet.
 * Planning Subsystem: Soar Codelet.
 * System 2 Motivational Subsystem: Goal Codelet and Appraisal Codelet.
 * Consciousness Subsystem: Consciousness Codelet.
 * Expectation Subsystem: Expectation Codelet. All architecture inputs and outputs are performed exclusively by System 1. The inputs to MECA are performed by the Sensory Codelets (on the left of System 1 at the diagram), which are responsible for collecting the sensor data and populating the Sensory Memory. The MECA outputs are performed by the Motor Codelets (on the right of System 1 at the diagram), which basically collect data from the Motor Memory and are responsible for sending this data to the system actuators.

The sensory subsystem
From a cognitive modeling perspective, the Sensory Memory is the raw storage of information coming from visual, auditory, olfactory, tactile and other sensory modalities in a time window which generally spans over something as 50–500 ms (Baddeley, 1997). This memory usually comprises uninterpreted data which is used in the first steps of perception. In human beings, at least two kinds of sensory memory were identified, the Iconic Memory, storing visual pattern stimulus and the Echoic Memory, storing auditory stimulus, but there might be also other memories for other senses as well, not so widely investigated. In MECA, this memory stores Memory Objects carrying direct representations of system sensors. These Memory Objects can be simple numbers or very complex data structures, representing both scalar sensors or n-dimensional images, according to the information provided by the sensor. It might also store temporal sequences of sensor data, which can be used by Perceptual Codelets to create more elaborate percepts. More elaborated or derived representations from direct sensory capture are not stored here, but at the Perceptual Memory. The Memory Objects stored in the Sensory Memory are updated by Sensory Codelets.

Usually, Sensory Codelets are application specifics, and the MECA software implementation just provides basic template classes to be reused while building an application using MECA.

The behavioral and motor subsystem
The Behavioral and Motor Subsystem is the core of System 1. The Motor Memory is a direct representation of the system’s actuators. Memory Objects in the Motor Memory are usually actuator values, which will be used as parameters by Motor Codelets in order to actuate at the environment. But the Motor Memory, in MECA has a special kind of implementation. Instead of using simple Memory Objects, MECA uses a special kind of Memory Object which is called a Container. The Container Memory Object is responsible for implementing an important element in the Dynamic Subsumption mechanism used in MECA. The system needs to decide which actuator parameters it will accept in order to send to the real actuators. This is all performed internally within the Container. All the Memory Objects in a Container are of the same type, and hold the same parameters. The only differences among them are that they were generated by a different behavior codelet.

Motor codelets then simply pick up the result Memory Object from the Motor Memory and reacts directly at the environment. This can be done by simply capturing actuator values and feeding actuators, or by some special protocol interacting with external software or hardware.

The System 1 Motivational Subsystem
Motivational behavior in cognitive architectures is derived from studies on human motivation coming from psychology, like those from Maslow. Examples of sophisticated models which served as inspiration to our Motivational Subsystem are those from Sun. A motivated behavior do not depend on just the present input, but depends also on a future state the system is aimed to reach. In other words, the behavior is not simply a reaction to some input, but is a behavior which is oriented towards a future state. It depends both on current input and on this desired future it is meant to achieve. This is what Peirce calls a thirdness in Semiotics theory. The philosopher Aristotle, in his Theory of Causality, used to call it a final cause. Many authors call this kind of behavior a goal-directed behavior. It is important to notice that a goal-directed behavior is fundamentally different from a reactive or a random behavior. During very much time, final cause and related concepts (e.g. the concepts of purpose or teleology) were viewed with skepticism in science. Modern cybernetics clearly explained though, the mechanism behind goal-directed behavior: feedback loops (Rosenblueth, Wiener, & Bigelow).

According to Hull’s theory of behavior, when a motor action is a prerequisite to optimum probability of survival of either an individual or a species, a state of need is said to exist. This need is said to motivate or drive the associated motor action. So, Hull defines a Drive as being an intervening variable used to characterize a need. Drives are used as a measurement of a desirable future state which a creature must reach, in order to survive. In a biological creature, a drive might be related to the many needs a biologic being is supposed to have: need for food, for water, for air, the need to avoid injury, to maintain an optimal temperature, the need to rest, to sleep, to mate, etc. In an artificial agent, drives are associated to the desirable behaviors we want the agent to manifest. They have to do with the desirable future state the agent should move itself into. In a very abstract understanding, a drive is a measurement of the agent’s success in achieving its designed purpose. A behavior which is performed in order to satisfy a drive is said to be a motivational (or motivated) behavior.

In MECA, Motivational Behavior is split among System 1 and System 2. System 1 Motivational Behavior is related to long-term or perennial needs for the agent the cognitive architecture is controlling (e.g. to optimize energy costs, to maintain energy balance, etc.). They are usually related to default system behavior which is expected from the agent. System 2 Motivational Behavior is related to time-specific needs, that once satisfied results in the dismission of the need (e.g. to reach a particular state, to achieve a specific goal). They are usually related to an exceptional situation which is under consideration. Needs on System 1 are encoded as Drives. Needs on System 2 are encoded as Goals. The standard dataflow for the System 1 Motivational Subsystem starts from Sensory Memory Objects flowing through Motivational Codelets to generate Drives which are stored in the Perceptual Memory. These Drives are then used by Motivational Behavioral Codelets in order to contribute with behaviors to be selected in the Dynamical Subsumption scheme.

But MECA also previews an enhancement in this standard dataflow, which is the incorporation of an emotional mechanism. The concept of emotion, as brought from cognitive psychology and philosophy, was suggested in the literature, as an alternative way of dealing with the problem of behavior generation.In MECA, we will be following Cañamero’s approach to emotions, together with Sun’s proposal to a motivational system. Under this view, emotions work as temporary cognitive distortions on system drives, resulting in a change in priorities, due to the recognition of critical situations. These critical situations will be recognized by Mood Codelets from direct sensor data, but also from situations remembered from episodic memory and possible predicted situations (from System 2) which might be classified as critical. The detection of a critical situation will change the Moods in Perception Memory. These Moods are responsible for, through Emotional Codelets, change the Drives intensity landscape, resulting in a change of priorities in order to better attend the critical situation.

The Perceptual Subsystem
The Perceptual Subsystem is the subsystem responsible for abstracting the information coming from Sensory Memory and building more sophisticated representations for what is going on at the environment. There might be increasing layers of abstraction in this process, under which raw data measurements are transformed in a high level understanding of the environment situation. This process is similar to the many layers of an onion, where high-level abstractions sum up and superpose the lower-levels, using their information and composing more sophisticated representations of the environment change over time. This is the process where sensory measured properties give rise to derived properties, which are then integrated into the recognition of objects, which are then identified as being a part of an ongoing episode, constituting a scene, which sequence form an understanding of the many situations experienced by the agent along the passage of time.

The Perception Subsystem is also responsible for collecting percepts from the Perceptual Memory and sending this information to System 2. This is done by an Attention codelet, which picks the current list of percepts and creates a Current Perception representation at the Working Memory. In MECA Perception Subsystem, an attention codelet is responsible for analyzing the many percepts at the Perceptual Memory and deciding which of them are important enough to be a part of the Current Perception at the Working Memory in System 2. This process is an important part of the consciousness mechanism in System 2, and also important for the Episodic Subsystem, also in System 2.

The Episodic Subsystem
The Episodic Subsystem in MECA has basically two roles:
 * To implement a higher-level kind of perception, and based on sequences of collections of percepts in time (which in MECA terminology are called configurations), detect and represent Episodes describing scenes experienced by the MECA agent.
 * To store and retrieve these episodes in/from Episodic Memory.

The Episodic Memory is a memory used to store facts particularly contextualized in time and space, forming Episodes which refer to information specific to a particular location and time frame. Episodes are representations for scenes detected from environment, using a higher level abstraction of space-time. We can see an episode as a specific representation for a segment of space-time, where some specific set of objects, and their trajectory in their state space is somewhat represented.

Episodic Memory is a neurocognitive mechanism for accessing time delimited contextualized information that naturally makes part of the human process of decision making, usually enhancing the chances of a successful behavior. This assertion is supported by several human psychological researches which indicate that the knowledge of his/her personal history enhances one’s person ability to accomplish several cognitive capabilities in the context of sensing, reasoning and learning.

The expectation subsystem
In 2007, Jeff Hawkins published his book called “On Intelligence”, where he discussed a new understanding on the phenomena of intelligence, based on the capacity of doing small predictions of future states. According to Hawkins, the brain is always performing these small predictions, and these are used to anticipate things which are imminent to happen. This ability might be crucial for doing things like catching a ball coming in our direction or deciding to dodge while a football player comes in our direction and we don’t want to shock with him. According to Hawkins this ability is due to cortical microcircuits which use to happen in the cerebral cortex. His theory gave rise to a whole field of research in neural networks, which he called Hierarchical Temporal Memories (HTM). The Expectation Subsystem in MECA is basically an attempt to include predictive abilities within our cognitive architecture.

Developing a MECA Agent
In order to run a MECA Agent, one should implement his or her own codelets extending the abstract classes referring to each codelet type, as the application requires. Then, these codelets' ids must be passed to an instantiation of the MECAMind class, who ties all of them as show in Fig 1.

There are some tuturials on how to use MECA that can be found here (ref).

Software
MECA is implemented in Java and its library can be found in:
 * Github repository's page and downloaded as a standalone jar file or
 * Jitpack Repository, where it can be added to a maven/gradle project dependencies. The instructions are in the Github's project page.

Applications
Although MECA is a recent Cognitive Architecture (created in 2017) there is some applications using it.

Traffic Signal Control
One of the first major MECA application was an orchestration of multiple cognitive Agents, each acting upon a single traffic signal, in order to make the time of the traffic phases based on how several was the traffic conditions. These experiments were made under different topologies and traffic conditions, where some of them showed almost 50% reduction on cars' mean travel time.

Game AI
MECA was also used to create an artificial mind for a virtual creature in Minecraft using the Malmo Plataform. The experiments used Reinforcement Learning, showed an implementation of Episodic Memory and explored a little on planning and how these cognitive resources affects the performance of the agent.

Robotics
A Robot composed by a MIR100 base and a UR5 was also controlled with a MECA Mind. Besides the robotic focus, this application explored the motivational subsystem with drives changing the behavior of the robot to, for example, avoid harming human beings.