Agent Oriented Programming code sample - agent

I'm currently studying Agent Oriented Programming,
And I'm having trouble about finding sample code in any language that is written to demonstrate the idea in real programming modele.
Can any one provide a link where a simple code is written to demonstrate the ideas of AOP?

Firstly, let's try to have a common understanding of what is AOP. From "Agent-oriented programming" paper written by Yoav Shoham (1993) we have:
Agent-oriented programming (AOP), can be viewed as a specialization of
object-oriented programming. The state of an agent consists of
components such as beliefs, decisions, capabilities, and obligations;
for this reason the state of an agent is called its mental state. The
mental state of agents is described formally in an extension of
standard epistemic logics: beside temporalizing the knowledge and
belief operators, AOP introduces operators for obligation, decision,
and capability. Agents are controlled by agent programs, which include
primitives for communicating with other agents. In the spirit of
speech act theory, each communication primitive is of a certain type:
informing, requesting, offering, and so on.
A good implementation of this concept is Jason, which is richly explained in the book "Programming Multi-Agent Systems in AgentSpeak using Jason" written by Rafael H. Bordini, Jomi Fred Hübner and Michael Wooldridge (2007).
An application to see how would be an AOP could be this small app:
https://github.com/cleberjamaral/beersponsor
In this simple app there are 3 agents, a robot, an owner (of the robot) and a sponsor. The idea is that the owner want to drink beer and a robot brings all the beer he wants. But after some deliveries the refrigerator run out of beers, so, a Java IDE is launched and the user can click to sponsoring beer to this lazy guy.
To run it you can download Jason and run JEdit (Java -jar JEdit.jar), which is a programming IDE for Jason.
https://sourceforge.net/projects/jason/
You can have more details about this simple implementation here: http://jasonagents.blogspot.com.br/2015/09/exemplo-de-integracao-com-interface.html

Related

design patterns for telecom software hard multithreading problems

In Martin Fowler's book Patterns of Enterprise Application Architecture he writes on page 2: "In some ways enterprise applications are much easier than telecoms software -- we don't have very hard multithreading problems ...".
Is anybody aware of a summary of those "very hard multithreading problems" and solutions, in the form of design patterns, like the famous GoF Design Patterns book?
There is the POSA book. But those books might be too general and fundamental. More domain focused examples would be what this question is after.
Check out Joe Armstrong's thesis from 2003:
Making reliable distributed systems in the presence of software errors.
Armstrong designed the software for a high-speed network switching device during his time at Ericsson. It was implemented in Erlang, which was specifically designed to provide highly reliable and highly concurrent applications.
In his thesis, he presents the underlying design decisions for the Erlang language itself and the OTP (Open Telecom Platform) library. He also makes some suggestions about how to design application modules for such applications -- this part comes closest to your 'design pattern', although not in the detail you're accustomed to after reading GoF's Design Patterns.
It's not a recipe book, but he nevertheless draws a few interesting conclusions about how applications should be designed.
Actors
The actor model an architectural pattern where a system is made up of a set of loosely-coupled actors that interact through message passing.
An actor is a computational entity that, in response to a message it receives, can concurrently:
send a finite number of messages to other actors;
create a finite number of new actors;
designate the behavior to be used for the next message it receives.
One of the properties of such a system is that failure propagation is reduced, and as a consequence individual actors become more robust.
The programming language Erlang was specifically designed for telephony switches and supports the actor model.
State Machines
A pattern that is common in real-time & embedded software engineering are state machines. State machines can be implemented on top of actors, but also provide a mechanism to represent complex states and associated behavior.
Finite state machines (FSM) are a possibility, but they quickly start to get large and difficult to maintain because of State Explosion. A more expressive formalism that solves this problem are Hierarchical State Machines (HSM) as originally developed by David Harel.
A more recent implementation of the same semantics that fits object-oriented design is the UML State Machine, see Section 15 of the UML specification. This defines a model for state machines complete with their execution semantics.

Which language or tools to learn for natural language processing?

I am French, and am a former Certified Network Security Administrator.
I went back to university 3 years ago to achieve a Bachelor's degree in linguistics, and I am now going to enroll in a Masters Degree in Computer Science applied to Linguistics, with the objective of eventually trying to go through a Doctorate (but I'm not there yet :-) ).
The course will focus on speech recognition, automatic language translation, statistical analysis of texts, speech encoding and decoding, and information abstratction from textual sources.
The professors will let us use any computer language we want to use to code the algorithms and programs we will develop during the curriculum.
I used to develop web apps as a side gig for about 3-4 years and I am proficient in Javascript as I wrote software that used node.js at the server end and the browser at the client. I also have some familiarity with postgresql.
My current style of coding (if we can call that a style) is mainly procedural and I use object prototyping as my main way to create/manage objects in my code. I don't have much experience with object oriented language that use the concept of classes to manage the objects. Therefore I am pretty confident my current coding skills are definitely lacking in regards to what is required for me to write efficient code to deal with that stuff.
So my question is this : what would be the best computer language for me to learn in order to be effective in writing algorithms and data structure suited for the above mentionned linguistic areas?
Thanks in advance for your enlightened answers.
Sat Cit Ananda.
Your question is opinion based, so probably off-topic here.
In France, you have a lot of good courses on Ocaml which is developed at INRIA with several good books (notably, both in French, Developpement d'Applications en Ocaml by Chailloux, Manoury, Pagano; and Programmation de Droite à Gauche & vice versa by Manoury). J.Pitrat also wrote Textes, Ordinateurs et Compréhension; his latest book artificial beings: the conscience of a conscious machines will also interest you.
And learning several programming languages, not only one, is always useful (a single programming language is not enough to do Natural Language Processing; you need to learn several programming languages and several programming paradigms - both functional and object paradigms are useful, and also prolog). You could also start reading the SICP while learning Scheme. Learning more about Lisp-like languages thru Queinnec's book Principe d'implementation de Scheme et Lisp - the updated version of Lisp In Small Pieces will also teach you a big lot.
Java might also be useful (because some NLP libraries are available in Java). CommonLisp, C++2011, Haskell ... too.
Also take time to use and master Linux (and its programming) and free software.
In general, natural language processing requires a lot of computer science (and math).
For production NLP systems, Java seems to be the most common choice. It is a nice and safe language for beginner/intermediate programmers that scales well with codebase size, has a simple grammar and a vast standard library, and it is one of the most commonly used languages where software performance isn't the absolute top priority (or where performance can be scaled horizontally/distributed). I believe for example most of the higher layers of IBM Watson are written in Java. You'll also find it as one of the primary teaching languages in CS courses.

Domain specific languages, application generators and software reuse

James Neighbors mentioned DSLs as an approach for software reuse but without explaining why.He just say that DSLs can be a better approach than a library of reusable components. I could not understand the relationship and what benefits can we come up with using DSLs in software reuse ?
Also in When and How to develop DSLs paper by Mernik , he mentioned that DSLs can serve as an input language to application generators, and application generators is one approach of reusing software discussed by Krueger.
Could anybody tell me the relationships or just how would a DSL be an effective approach towards software reuse ? Thanks a lot for your help
James made it very clear why DSLs are a good approach for software reuse (he and I were at UC Irvine together):
They capture the concepts of interest in the problem domain
They use a notation familiar to community that works in that domain
They define the rules of composition of specification/solution components to produce an answer, so that a DSL fragment can be checked for sanity as it is provided
His Draco system implemented all these concepts, accepting DSL descriptions, followed by a DSL instance, which Draco then compiled to low level code by applying implementation knowledge fragments ("refinement rules") to map from a high-level DSL into lower level DSLs/optimizing in the lower level DSL, and then repeating until you finally reach a DSL at low-enough level abstraction to give to a conventional compiler (e.g, to LISP or C or Ada or COBOL or ...).
This is his refine-and-optimize paradigm, that allows a set of DSLs to refine through layers of hierarchy to low level code. Thus, you get composability of layered domains and you can work at a very high level of abstraction.
So you capture problem specification and implementation knowledge, and apply it to get code. Reuse of abstractions, of specifications, of implementation, wow, ... not just reuse of "code" which is where lots of folks still seem stuck, as they were in the early 80s. Code is really hard to reuse.
This is really a very nice paradigm compared to "subroutines-as-components" (the fancy term for this currently is "inner DSL", which misses the domain notation, specification checking, implementation, and compositionality elements).
I think you really ought to read his PhD thesis (accessible here along with a lot of his other papers) carefully. It is a lot more approachable than might expect. It isn't full of arcane math; it is full of concepts and demonstrations of how to engineer his kinds of DSLs.

Agents in Haskell or functional languages?

I'm architecturing a Multi Agent System (MAS) framework to describe Beliefs-Desires-Intents (BDI) agents in Haskell (i.e. agents are concurrent, communicating monadic actions).
I searched on the web throughly but I wasn't able to find any reference on similar works, apart from a technical report of an unfinished work, Specifying and Controlling Agents in Haskell.
Do you know about any existing implementation or research paper dealing with BDI agents that can be defined in Haskell or in any other functional language, please?
My aim is to find possible related works, everything that could manage a system of concurrent intelligent agents written in a functional language. I don't need anything specific, I just want to find out whether my work has something in common with existing approaches.
edit: I managed to find a reference to Clojure, a lisp dialect that supports a form of agent programming very close to the actor model, but it's not meant to directly support BDI agents (one should implement another layer on top of it to get the BDI part done I guess).
To sum up, it doesn't seem like there are proposals for BDI-style communicating agents described by means of functional languages, so together with a friend/colleague of mine we collected info about related work, put together some ideas, and we wrote a short position paper that I will present at the DALT2012 workshop. It's a really preliminary work, so do not expect too much from it, but I think in the future it may evolve in something interesting.
Alessandro Solimando, Riccardo Traverso. Designing and Implementing a Framework for BDI-style Communicating Agents in Haskell. DALT 2012, Workshop notes, pages 108--112.
EDIT:
I later found this project on GitHub, which uses free monads (whatever that means, I don't know about them) to provide a framework for multi-agent systems: https://github.com/fizruk/free-agent.

Platform for creating a visual programming language

I'm interested in creating a visual programming language which can aid non-programmers(like children) to write simple programs, much like Labview or Simulink allows engineers to connect functional blocks together without the knowledge of how they are internally built. Is this called programming by demonstration? What are example applications?
What would be an ideal platform which can allow me to do this(it can be a desktop or a web app)
Check out Google Blockly. Blockly allows a developer to create their own blocks, translations (generators) to virtually any programming language (or even JSON/XML) and includes a graphical interface to allow end users to create their own programs.
Brief summary:
Blockly was influenced by App Inventor, which itself was based off Scratch
App Inventor now uses Blockly (?!)
So does the BBC microbit
Blockly itself runs in a browser (typically) using javascript
Focused on (visual) language developers
language independent blocks and generators
includes a Block Factory - which allows visual programming to create new Blocks (?!) - I didn't find this useful myself...except for understanding
includes generators to map blocks to javascript/python
e.g. These blocks:
Generated this code:
See https://developers.google.com/blockly/about/showcase for more details
Best wishes - Andy
The adventure on which you are about to embark is the design and implementation of a visual programming language. I don't know of any good textbooks in this area, but there are an IEEE conference and refereed journal devoted to this field. Margaret Burnett of Oregon State University, who is a highly regarded authority, has assembled a bibliography on visual programming languages; I suggest you start there.
You might consider writing to Professor Burnett for advice. If you do, I hope you will report the results back here.
There is Scratch written by MIT which is much like what you are looking for.
http://scratch.mit.edu/
A restricted form of programming is dataflow (aka. flow-based) programming, where the application is built from components by connecting their ports. Depending on the platform and purpose, the components are simple (like a path selector) or complex (like an image transformator). There are several dataflow systems (just I've made two), some of them has no visual editor, some of them are just a part of a bigger system, and there're some which don't even mention the approach. (Did you think, that make, MS-Excel and Unix Shell pipes are some kind of this?)
All modern digital synths based on dataflow approach, there's an amazing visual example: http://www.youtube.com/watch?v=0h-RhyopUmc
AFAIK, there's no dataflow system for definitly educational purposes. For more information, you should check this site: http://flowbased.org/start
There is a new open source library out there: TUM.CMS.VPLControl. Get it here. This library may serve as a basis for your purposes.
There is Snap written by UC Berkeley. It is another option to understand VPL.
Pay attention on CoSpaces Edu. It is an online platform that enables the creation of virtual worlds and learning experiences whilst providing a more flexible approach to the learning curriculum.
There is visual coding named "CoBlocks".
Learners can animate and code their creations with "CoBlocks" before exploring and sharing them in mobile VR.
Also It is possible to use JavaScript or TypeScript.
If you want to go ahead with this, the platform that I suggest is the one used to implement Scratch (which already does what you want, IMHO), which is Squeak Smalltalk. The Squeak environment was designed with visual programming explicitly in mind. It's free, and Smalltalk syntax can learned in half an hour. Learning the gigantic class library may take just a little longer.
The blocks editor which was most support and development for microbit is microsoft makecode
Scratch is a horrible language to teach programming (i'm biased, but check out Pipes Visual Programming Language)
What you seem to want to do sounds a lot like Functional Block programming (as in functional block programming language IEC 61499 and other VPLs for mechatronics development). There is already a lot of research into VPLs so you might want to make sure that A) what your are trying to do has an audience and B) what you are trying to do can be done easily.
It sounds a bit negative in tone, but a good place to start to test the plausibility of your idea is by reading Davor Babic's short blog post at http://blog.davor.se/blog/2012/09/09/Visual-programming/
As far as what platform to use - you could use pretty much anything, just make sure it has good graphic libraries (You could use Java with Swing - if you like pain - or Python with TKinter) just depends what you are familiar with. Just keep in mind who you want to eventually launch the language to (if its iOS, then look at using Objective-C, etc.)

Resources