Notes‎ > ‎

Playing with a Viable System Agent in SmallTalk

posted 21 Feb 2012, 06:24 by David Sherlock   [ updated 6 Mar 2012, 01:12 ]
Thinking about intelligent agents based on the viable system model I came across a Squeak/Smalltalk implementation by Bruce Carleton. Although I have only just started working through this implementation it has helped me get my head around some of the ideas of the VSM. I haven’t used smalltalk before and found it difficult getting my around smalltalk at the same time as the VSM. Fortunately Bruce was very helpful and sent me some code and pointers. People can be very generous with their time.

Install Pharo
Pharo is a fork of Squeak Smalltalk and very easy to set up. Simply download the image from: http://www.pharo-project.org/home

Get the code
Monticello is Squeaks code versioning/repository system.. Right click and select Monticello Browser and choose +Repository. You want to add this in the box that pops up

MCHttpRepository location: 'http://home.rbcarleton.com/rbc/software/smalltalk/VSA/Monticello/' 
user: '' "
password: '' "

Import
Right click the repository you have added and import all the classes

Play
You are now set up to play with the Viable System Agent. To get started tight click and start a new workspace, then paste the code that was kindly donated by Bruce:

    "Setup test environment"
myVSA := VSA new.

"Test out get methods"
myVSA actuality: 0.
myVSA capability: 2.
myVSA potentiality: 4.
myVSA alertVariance: 0.
"Generate an alert"
myVSA mark: VSAAlert.

"Test message sends"

myVSA myManager createOp: VSA.

"Test the managers report"
myVSA myManager sendManagerReport: VSAManagerReport.
myVSA moveMessages.
msg := myVSA myPlanner inBox.
msg := myVSA myExecutive inBox.

"Test sending a planner message"
msg := VSAPlannerMessage new.
myVSA myPlanner outBox: msg.
myVSA moveMessages.

"Test sending policies"
pol := VSAPolicyMessage new.
myVSA myExecutive outBox: pol.
myVSA moveMessages.

Bruce suggested

'Once you have evaluated the code in a workspace, you should be able to highlight and explore (a right click menu in Pharo) myVSA to see the state of the VSA after the selected methods have run. I hope that gets you started.

Your environment should look like this:



I’m going to play and see what it does. There is some good documentation here: http://home.rbcarleton.com/rbc/software/smalltalk/VSA/.

Thanks Bruce

Comments