11
@ Pergamon CONTRIBUTEDARTICLE OpenSim: A Flexible PII: S0893-6080(96)00121-9 NeuralNehvorks, Vol. 10,No.4, pp. 693-703, 1997 CJ1997ElsevierScience. Ltd. All rightsreserved Printedin OreatBritain 0893-6080/97$1700+.00 DistributedNeural Network Simulator with AutomaticInteractive Graphics JEAN-FRANQOISLEBERANDANDREAS.lAROSCH Communication Technology Laboratory, Swiss Federal Institute of Technology (ETH) (Received3March1995; accepted 10 November 1996) AbWract-An object-orientedsimulatorcalledOpenSimispresentedthatachievesahighdegreeofjlexibilitybyrelying ona smallsetofbuildingblocks.Thestatevariablesandalgorithmsputinthisframeworkcaneasilybeaccessedthrough a commandshell.T7zisallowsoneto distn’butea large-scalesimulationoverseveralworkstationsandto generatethe interactive graphics automatically. OpenSim opens new possibilities for cooperation among Neural Network researchers.O 1997ElsevierScienceLtd. Keywords-NeuralNetworks, Object-oriented simulation, Distributed objectcomputing. 1. INTRODUCTION Thestate-of-the-artofArtificialNeuralNetworks(ANN) is characterizedon one hand by many modelsand para- digms,andon theotherbymanypotentialapplicationsin various fields such as acoustics, vision, robotics and finance(Matthews& Leber, 1989). In order to design a judicious combinationof algo- rithmsfor a given application,researchersmust investi- gate multipleANN models. 1.1. The need for simulations Why simulationsandnota theoreticalanalysis?Because theANNscomprisehighlynonlinemcomponentsthatare attherootofthedesiredcombinatorial anddecisionmaking capabilities.Unfortunately,these nonlinearitiesare still very difficultto handlemathematically. Consequently, a largenumberof simulationshasto be performed. 1.2. The need for an open simulationconcept By “open”, we mean two things:flexibleand transpar- ent. A researcherneeds afiexible simulatorto be easily able to incorporatechangesto the algorithms— either Acknowledgements: The support of the Institute for Signat and Information Processing (1S1)and the Institute for Electronics (ME)of the ETH Ziirich, Switzerland, is gratefully acknowledged. Requests for reprints should be sent to IKT, ETH Zerrtrum, 8092 Zurich, Switzerland; Fax: +41 1 632 12 09; ernail: opcnsim@nari. ee.ethz.ch. for customizing an existing solution, for combining several solutionsor for developinga new solution.To simplifythe developmenteffort, a simulatorshouldbe transparent, which includes a modular architectureas wellas well-defined,intuitiveinterfaces. How open are the presently availablepublic-domain and commercialNeuralNetwork simulators?Generally speaking, these simulators are often optimized under some constraints for a particular model, application, didactical aim or special-purposehardware. Most of them are restrictedto a stand-aloneoperation(one pro- gramcan hardlyinterfacewith another).Theyhave to be re-written to be ported to anotherplatform or window system.Althoughit is easy to adapt parameterssuch as the learningrate or the number of neurons,it is rarely easy,if at allpossible,to modifythe algorithmsor to add new functionality(Leber, 1992). Under these circumstances,it is not surprisingthat almost every laboratory develops its own simulation environment. The disadvantages are two-fold: (i) a gross inefficiency, and (ii) a stronglyimpeded coopera- tion among researchers in the Neural Network community. Considerhowa researchertypicallyproceedsto turna new idea into a workingsimulation.He copies as much of the availablesourcecodeas canbe reused.Experience provesthatovertimemodificationswillbe madeto some of the copiesbut not to all, inevitablyproducingincon- sistenciesacross a quickly increasing number of pro- grams. A simulation concept is needed to keep the entropyas low as possible. 693 .———

OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

Embed Size (px)

Citation preview

Page 1: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

@Pergamon

CONTRIBUTEDARTICLE

OpenSim:A Flexible

PII: S0893-6080(96)00121-9

NeuralNehvorks,Vol. 10,No.4, pp. 693-703, 1997CJ1997ElsevierScience.Ltd.All rightsreserved

Printedin OreatBritain0893-6080/97$1700+.00

DistributedNeural Network Simulatorwith AutomaticInteractiveGraphics

JEAN-FRANQOISLEBERANDANDREAS.lAROSCH

Communication Technology Laboratory, Swiss Federal Institute of Technology (ETH)

(Received3March1995;accepted10 November1996)

AbWract-Anobject-orientedsimulatorcalledOpenSimispresentedthatachievesa highdegreeofjlexibilityby relyingona smallsetofbuildingblocks.Thestatevariablesandalgorithmsputinthisframeworkcaneasilybeaccessedthrougha commandshell. T7zisallowsone to distn’butea large-scalesimulationover severalworkstationsand to generatetheinteractive graphics automatically. OpenSim opens new possibilities for cooperation among Neural Networkresearchers.O 1997ElsevierScienceLtd.

Keywords-NeuralNetworks,Object-orientedsimulation,Distributedobjectcomputing.

1. INTRODUCTION

The state-of-the-artof ArtificialNeuralNetworks(ANN)is characterizedon one hand by many modelsand para-digms,andon theotherby manypotentialapplicationsinvarious fields such as acoustics, vision, robotics andfinance(Matthews& Leber, 1989).

In order to design a judicious combinationof algo-rithmsfor a givenapplication,researchersmust investi-gate multipleANN models.

1.1.The need for simulations

Whysimulationsand not a theoreticalanalysis?BecausetheANNscomprisehighlynonlinemcomponentsthatareattherootofthedesiredcombinatorialanddecisionmakingcapabilities.Unfortunately,these nonlinearitiesare stillvery difficultto handlemathematically.Consequently,alargenumberof simulationshasto be performed.

1.2. The need for an open simulationconcept

By “open”, we mean two things:flexibleand transpar-ent. A researcherneeds afiexible simulatorto be easilyable to incorporatechangesto the algorithms— either

Acknowledgements: The support of the Institute for Signat andInformation Processing (1S1)and the Institute for Electronics (ME)ofthe ETH Ziirich, Switzerland, is gratefully acknowledged.

Requests for reprints should be sent to IKT, ETH Zerrtrum, 8092Zurich, Switzerland; Fax: +41 1 632 12 09; ernail: [email protected].

for customizing an existing solution, for combiningseveral solutionsor for developinga new solution.Tosimplifythe developmenteffort, a simulatorshouldbetransparent, which includes a modular architectureaswell as well-defined,intuitiveinterfaces.

How open are the presentlyavailablepublic-domainand commercialNeuralNetwork simulators?Generallyspeaking, these simulatorsare often optimized undersome constraints for a particular model, application,didactical aim or special-purposehardware. Most ofthem are restrictedto a stand-aloneoperation(one pro-gramcan hardlyinterfacewithanother).Theyhaveto bere-written to be ported to anotherplatform or windowsystem.Althoughit is easy to adaptparameterssuch asthe learningrate or the numberof neurons, it is rarelyeasy,if at allpossible,to modifythe algorithmsor to addnew functionality(Leber, 1992).

Under these circumstances,it is not surprisingthatalmost every laboratory develops its own simulationenvironment. The disadvantages are two-fold: (i) agross inefficiency,and (ii) a stronglyimpeded coopera-tion among researchers in the Neural Networkcommunity.

Considerhowa researchertypicallyproceedsto turnanew idea into a workingsimulation.He copies as muchof theavailablesourcecodeascanbe reused.Experienceprovesthatovertimemodificationswillbe madeto someof the copiesbut not to all, inevitablyproducingincon-sistenciesacross a quickly increasingnumber of pro-grams. A simulation concept is needed to keep theentropyas low as possible.

693

.———

Page 2: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

694 J.-F. LeberandA. Jarosch

The problems grow worse when researchers getinvolved in a local or internationalcooperationwherethey must exchange,along with know-howand results,experimentaldata and software.

Unfortunately,the standardizationeffortin the areaofNeuralNetworksimulationis still in its infancy,as it isfor the theory.The variabilityof symbolsacrossthe lit-erature and across the simulatorssignificantlyimpedesthe comparisonof theproperalgorithms.Ideally,a paperpresentinga new algorithmwouldbe accompaniedby apiece of softwarethat the reader couldeasily insertintohis own environment for further investigations.Webelieve that the conceptspresentedin this paper makea significantcontributionin this direction.

1.3. The need for interactivesimulations

Thenonlinearbehaviorof a complexmodelandthelargeamountof dataproducedduringa simulationcan hardlybe interpretedby any means other than graphically.Incontrastto a longlistofnumbers,a plothelpsrecognizeasituationas a whole,separatethe relevantfrom the irre-levant,and analysespecificaspects.

In the areaofNeuralNetworks,plotsareindispensablefor visualizingthe activityof a set of neuronsat a giventime,as wellas itsprogressionin time.Plotsareusefultoverifi convergence,estimateits rate and evaluateself-organizationcapabilitiesof synapticweightvectors.

Besidesprovidingvisualfeedbaek,interactivecompo-nents help the researchercontrol the simulator.Usingmenusand dialogshe can, for instance,easilylowerthetrainingratetogeneratefinercategories,oraddnoisetotheweightsto eseapefroma localminimumtrap.

This paper is organizedas follows:Section 2 intro-duces the building blocks and Section 3 presents anexampleprogram.Section4 dealswith the mechanisms,Section5 with the network support,Section6 with theinteractivegraphics,Section7 with the extensibilityandSection 8 with the Neural Network objects. Section 9concludesthis paper.

2. BUILDINGBLOCKSALLOWONE TO FOCUSON THE ALGORITHMS

An analysisof Neural Network simulatorsfor variousmodels and applicationsshows that they share similarcomponentsand toolswhichmakeup a largepercentageof the sourcecode.

Thesecomponentsand toolscan be split in two cate-gories.Thefirstcategorycomprisessolutionsto theever-presentissuesof data representation,data manipulation,data visualizationand data control.The secondcategoryof components and tools is characterizedby similarstructuraland algorithmicitems:similar,if not identical,neuronmodels;commonfunctionslike dot product,sig-moid,adaptationrules; similarinput,outputand weightlayers.

It is readilyseenthat substantialbenefitscanbe gainedby implementinga small set of general-purposenonin-teractiveandinteractivebuildingblocksandby confiningoneselfto usingthem wheneverpossible.

In OpenSim,a buildingblock(BB)is the basicunitofinteractionwithoneor morestatevariablesand methodsthat it owns. The interactionwith the BBs takes placeeithergraphicallythroughmenusand plots,or textuallythrougha commandshell.

Usingthesebuildingblocksenablesthe researchertofocus on his algorithms instead of “reinventing thewheel”. It also results in a consistent“look and feel”across multipleprogramsfrom multiple programmers.Instead of numerousways to implementsimilar tasks,there is a singleway to representand manipulatedataand a singleway to visualizeand interactwith data.

The noninteractiveBBs of OpenSimare the classes:

1. BOOL(boolean:TRUE or FALSE)2. INT (integernumber)3. ENUM (enumeration,e.g. LIIVLOG); its value is

restrictedto one integerout of a set whosememberscan be registereddynamically

4. FLOAT(floatingpointnumber)5. STRING(“some text”)6. FMAT,IMATetc. (matricesof floats,integersetc.)

Using matrices, one can compactly and efficientlyoperateon variousensemblessuchas a layerof neurons,visualdata (matrixof pixels),acousticaldata (vectorofsamples)or a collectionof syntheticpatterns.OpenSimsupportsmatricesof sevendata types:byte, short, inte-ger, floatingpoint, doubleprecision,complexand text.All matrices have standardmethods such as read andwrite (with index checking), randomize, invert, loadand save.

Using BBs enhances the transparencyof the code,beeausetheir implementationis isolatedfromthe properalgorithmsand locatedin librariesthat are sharedby allprograms (Fig. 1). OpenSim’slibraries are tested andoptimized.Besidesconsistency,they ensureeasy main-tenance,memoryand disk savings,and quick compila-tion and linkage.

FIGURE1. The bulldlngblookimpiemantatfonis iaotatadfromthe proparalgorithm and Ioeatadin iibrariaethatareaharadbyall progreme.

—-— --

Page 3: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

A FlexibleDistributedNeuralNetworkSimulator 695

ich.MV.M4trixl Wirrkw

FIGURE2. A simplestairfunction.

3. A SIMPLEEXAMPLE,YET AN ALREADYPOWERFULINTERACTION

The followingexamplegivesinsightintowhatis neededfor quicklyimplementingsome algorithmand visualiz-ing it with OpenSim.Since the complexityof the algo-rithm does not matter, OpenSimis best explainednotwithNeuralNetworks,but for instancewith a stairfunc-tion (Fig. 2).

The sourcecode displayedin Fig. 3 consistsof threeparts:the declarationof a class,theimplementationof itsmethods (also called member functions)and the maincontrol.

The declaredclass inheritsfrom BBMANAGER,which

implementsmechanismsfor managinga numberof BBs.In this simpleexample,two BBs are declared:an INTnamed Matrixl–NRows and an FMAT namedMatrixl. The user is able to set and achievethe num-berofrowsof thatmatrixby accessingMatrixl \YZN-Rows — also via the menuitem.The datacomputedbythe algorithmis storedin Matrixl. The user is able toread and modify — and also visualize — its contents byaccessing Matrixl.

In the implementation part, a new group of BBs isdefined using JGROUP (“Group-Name”, “Fore-GroundColor”, “BackGroundCol or”). A menuwill be createdautomaticallyfor each group,containingone menuitem per associatedBB. JINT (s, “Group-Name”, val) instantiates an INT named s, assigns it tothe group “Group-Name” and initializes its value toval. Simihuily, JFMAT (s, “Group-Name”, NROWS,NColumns) instantiates an FMAT and initializes itsnumberof rowsandcolumnsto NROWSand NColumns.The statement LinkNRows (Matrixl, Matrixl\ -–NRows) links the number of rows of Matrixl withthe IN’l’Matrixl–NRows so that they keep consistent.(Such links are very helpful in programs where manymatrices have an equal number of rows and/or columns.)

So much for the building blocks that provide interac-tive access to their state variables. The algorithm itself isimplemented in a class method: Update (int) takes an

#include <IBs.io

class MyViewer:public SEWNGER{public:

S& DIKL~: M3trixl-NROws;EM?IT*M3trixl;midUpcLate(intSt@iidth=5);

}:

SSs-SEG3N(&/ie9.er,BR@N?@R)~(~”,~~~’’,’’Yell@)JUfT(Matrixl–Nmws,‘TcOt”,100)JiWAT(M3trtil,’’Rwt”,1,1)LinkNkm(1.latrixl,Matrixl-NMws);JFC1’(MyViwer::U@ate,’’Rmt’’,”mid

Update(intStepWidth=5)”)BBs-ENl(MyViewer,BEW@&ER)

midMyViewer::@Ate(intStepWidth){%se~();flcatf=o;Matrixl->zeroo;i.ntnRms=Matrixl-NRm5-Xet():for(imti=O;iaROw;i++)(

if(i%StepWidt&O)f=f+O.05;M3trixl-%rite(f,i,O);

}:RekaseBss();

}

intmin(intargc,char*a.rgv[l) {if(!InitIBS(argc,argv))return(0);MyView5r*Viewerl=mwMyViewero;Vieherl->InitSSs(O,‘WV”):return“Mlnkcpo:

}

FIGURE3. A complataaxamplafor quicklyimplarnantlngandvisualizingan algorfthm.

Page 4: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

696 J.-F. bber andA. Jarosch

Ilch.MV: Update

StapWldth: % -100 ~ 100

@!D@@ IMisc ->

kh.MV, Matrlxl-NRows: 100

NColumns: 1

Enabled: TRUE

File Maine: NoName

Path:

Extansion: mat

BelngSaved: TRUE

AlwaysUseSaveAscii: FALSE

IMatrixl -NROWS: 100

Matrixl ->

Updata I

Window iLoad

Save

la

lthJ}L: +1 nctionSaveAscii

Print b: @

Read 1: 1

Write

Zero

I

c tsswlns @EEElRandomize Pt -58.XI -1’JrJ~ ~ l~u~

Norm

Normaltze

AddNoise

FIGURE4. Automaticallygeneratedmemsaanddlaloga.

integer argumentthat determinesthe step width of thestair function. The first statement,ReserveBBs ( ),reserves all BBs that willbe accessed,and the last state-ment, ReleaSeBBS ( ) , releasesthem again(whywillbe explainedlater). Then Matrixl k zeroed, and theINT is read out with Matrixl–NRows ~ Get ( ) .Note that Matrixl is one-dimensional: NColumns =11.

At each step of the subsequentloop,whichmeansforeach row of Matrixl,itis decidedwhetherfmustbeincrementedor not in orderto generatethe stairwith thedesired step width. The value of f at each iterationiswrittenintoMatrixl at row i and column O.

To provide interactive access to a method, a line of thetype JFCT (ClassName: :MethodName,‘ ‘GroupName ‘ , ‘ ‘C++ FunctionDeclara-tion ‘ ) is needed. The indicated method is assignedto the group “GroupName”, and its C++ declarationwill be neededfor creatinga correspondingmenuitem.

Each time the user clicks this menu item, a dialogopens, asking for the arguments to the method (herejust one; top part of Fig. 4). Methodswithoutargumentsare called withoutopeninga dialogfirst.Up to 15 argu-mentsof varioustypesare supported,as well as defaultssuchas the = 5 in “void Update (int StepWidth= 5 ) “. The supportedtypes comprisebool (boolean;generatesa checkbox),int (integer, generates a slider),enum (enumeration; generates a choice sub menu),float (floating point; generates a slider), FMAT* (float

matrix;generatesa text item with its address),char*(string;generatesa text item withoptionalfilebrowser).The dialog box generatedfor a method with differenttypesof argumentsis displayedat the bottomof Fig. 4.

In the main controlpart, InitIBB (argc,argv)initializes the building block environment. Then aMyViewer is created and initialized. The arguments toInitBBs ( ) are the desired parent BB (default: O,meaning:appendit to the root of the hierarchy)and thenameof thisBB,here “m”. MainLoop ( ) takes careof the event handling until the program terminates.

This program is readily compiled and linked. Once it isstarted, a shell prompt appears. The user can now type inany commands.

The command < .W > : Open (100, 500,‘ ‘Root ‘ ) addresses w and calls its built-in methodOpen (x, y, ‘ ‘GroupName ‘ ‘ ) . Immediately amenu is constructed and made to appear at the specifiedcoordinates. Its items correspond one-to-one to the BBsin the indicated group of W. In this example, we obtainthree menu items (middle part of Fig. 4).

The member variables can now be accessed interac-tively: the first menu item shows the current state of theINT Matrixl–NRows. Clicking it makes a sliderappear. When its handle is dragged and released, thefollowing command is sent to the INT: <ich. MRV.Matrixl–NRows > : Set (50 ) . Here50 is the presentlychosenvalueto set the INT to. EachBB has a uniqueaddressenclosedin < . . . > much

Page 5: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

A FlexibleDistributedNeuralNetworkSimulator

FIGURE5, The bulldlngblockaare organizedin a traa-iike

like a file system path name. This allows one to organizethe BBsin a tree-likehierarchy.Here,ich stands for theclient name (we shall see how BBs can easily commu-nicate between processes).To ich is connectedMRV,and to MRV are connected Matrixl–NRows andMatrixl (Fig. 5).

The same effeet can also be obtained without a menuby typing the identical command in the shell. Menus justprovide a quick and convenient means for entering com-mands. The command < ich. MRV.Matrixl–NRows> : Get ( ) returns the current value of that~.

Somethingsimilarhappenswhen the itemMatrixl+ k clickedresp.thecommand < i ch.MV.Matrixl> : Open (x, y, ‘ ‘ Root ‘ ) is entered. TheFMAT,which is itself a BB manager,is “opened”, i.e.its root menu appears(leftpart of Fig. 4).

(he of the matrixmenu items,NROWS,interacts withthe number of rows of that matrix and works just likeMatrixl–NRowS. (The two INTs are linked.) Twofurther items load the matrix data from the file andsave it to a file. If one attempts to load matrix datawith different dimensions, NROWS and NColumnsadapt themselves automatically.

Clicking the menu item Window generates the com-mand < ich. MV.Matrixl .Window > : Open(550, 500, 300, 200) that calls its built-in methodOpen (x, y, w, h). Immediately a window of width wand height h is constructed and made to appear at thespecified coordinates. The window displays thematrix data in several styles: a curve if the matrix isone-dimensional; a colored raster or 3-D mesh if it istwo-dimensional, etc.

The plot is itself a BB manager governing variousproperties like colors, axes and styles. Clicking insidethe plot opens a menu for controlling these properties.The plot can be zoomed and a PostScript hardcopy can begenerated.

Each time Update ( ) is calledwith a differentstePwidth,theplotdrawsthenew stairfunction.If thematrixdimensionsare changed for any reason, the plot andmenusare adaptedat once.

Note that all menusandplots are generatedautomati-cally, at the very instantwhen they are requested.Not asingle line must be programmed for it. (Non-defaultgraphic settings can be preset by filling strings with

697

no graphicobject in the sourcecode, the readabilityofthealgorithmsis verygoodandthecompilationveryfast.

4. OPENACCESSTO THE OBJECTS

ByobjectswemeaneitherBBsorBBmanagers(instancesof classesthat inheritfromBB or BBWAGER).

4.1. The commandshell

Each object can be accessed at any time by enteringappropriatecommandsin the shell.

Thecommandshellis a programmableinterpreterwitha scanner,parser and virtualmachine.The parser com-pilesan intermediatecodefor the parsedcommands,andthe virtualmachineexecutesthis code. This separationacceleratestheexecutionof loopsbeeausethe statementsare not re-interpretedat each pass.

The commandscan be typed or read from file. Theinteractivefrontendhas a commandline editorwith his-tory. Whereas each line typed must be self-containedbecauseit is executedas the carriagereturn key is hit,the commandsread from file may representa complexprogramthat extendsover many lines (e.g. a parametervariation study). The language is definedby a simplesyntax.

Onecandeclarevariablesofanyof thefollowingtypesandperformcomputationsusingthe operators =, +, –,*,I,VO;

book BOOLb; b = TRUE; b = FALSE;integer: INT i, i2 ; i = O; i2 = i + 7;float: FLOAT f, f2; f = (3. 1415) / 4. O; f2 =3. 5*f/ (f + 9. o) – 7 .1;string: STRING s; s = ‘ ‘ text ‘;address: ADDRESSa, a2; a = < . Float > ; a2= < . Float2 > ;enum (a variable of enumeration type can assume anyvalue out of a given set of predefine values;Regis terEnum ( ) registers such a pre-definedvalue): ENUMel, e2; < . > : Regis ter–Enum ( ‘ ‘ LIN’ ‘ ) ; < . > : Regi sterEnum( ‘ ‘LOG‘ ‘ ) ; el = LIN; e2 = LOG;wait id: WAITID wid, wid2;

Whereas commands without return value can bedirectly entered as seen in the example, commandswith return value must be preceded by the keywordorder followed by the variable to assign the returnvalue to.<.> : OpenAndSave ( ‘ ‘ simulation.state ‘ ) ;order b = < . > : Load. ( ‘‘s irnulation.state ‘ ) ; / / 4 BOCJL

To execute several commands in parallel, one uses thekeyword order–nowai t followed by a WAITID. Thewait statement waits for all commands to have assigned. . . .. .-, C.J ..-ti..l-, --

Page 6: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

698 J.-F. LeberandA. Jarosch

order–nowait wid2, f = <. Float> :Get();order—nowait wid2, f2 = a2 : Get ( ) ;wait wid2 ;

Besides declaring such built-in variables, onecan alsocreate aBB with a shell command.<. > :New (“FLOAT”, “ROOt”,

‘ ‘Float’‘);< .Float > : SetLabel (’‘label’‘);

Conditionalbranchesusing the keywordsif,elseandwhileandtheoperators !, < , < = , = , ! = ,>=, > ,&&, I I are supported. Inside ablock, localvariables can be declared and used.if ( (b! = FALSE) && (f > = 5.0 ) ) {f = f +1. O; INT j ; j = i – 1; } else {i = 1; }

One can write nestable procedures with optional argu-ments. When an argument type is followed by an amper-sand, the argument is not copied but passed per reference.Inside a procedure, local variables can be declared andused.procedure procl (BOOLb, FLOAT f, INT& i){FLOAT g;g = f*f;if (b&& (g> = 5.0 ) ) {i = i + 1; }

}while (i < 10){

FLOAT f ;order f = < . Float2 > : Get ( ) ;a: Set ( f + O. 1) ;procl (TRUE, f, i ) ;

}Via command shell, OpenSim allows one to save parts

or all of the current data and graphics state of a simula-tion to a file in the form of editable commands. Thesecommands can be interpreted later to restore the savedstate. They can even be loaded into another program aslong as they address existing objects and methods. Thedata of each matrix is stored in a separate ASCII orbinary file that can be loaded in any matrix with matchingdimensions. In contrast to most simulators that save aprogram’s state to a single large file, such a distributedfile system representation provides much flexibility.

4.2. The commandexecutionmechanism

In OpenSim,severalprogramscontainingmany objectsmay run concurrently,and each object may send com-mandsto other (localor remote)objectsat any time.Anoriginatorcommandis definedas a commandthat doesnotresultfromanothercommand.Forexample,whentheuser clicksa BOOLmenu item, an originatorcommandis generatedto toggletheBOOL’Svalue.Eachoriginatorcommandisgivena new “thread id’ whichitpropagatesto all commandsthat it causes. A thread is a chain ofcommandsthat may arbitrarilyspanover the network.

In sucha multi-threadedenvironment,it can occurthatthe execution of two or more commands temporally

FIGURE6. A threadis a chainof commands.Thedispiayadthreadspansoverthreaobjects,poeaibiyioeatedindifferentprograms.

overlapsin the same object. This can produce desiredeffects,but also fatal errors.

If an object is busy running some algorithm andanotherobjectnowtriesto modifythisobject,the resultsare unpredictable.On the otherhand,it is very desirableto be able to stopthe algorithmfrom anotherobject,sayby clickinga “Stop” menu item. Furthermore,in com-plex simulationsit is commonthat objectsget involvedrecursively,i.e. that someobjectcallsa methodof someother object that itself needs to access a variable or amethodof the firstobject(Fig.6).

OpenSimprovidesa securemechanismthat preventsan objectfrombeingaccessedas longas it is operatedonby a commandof anotherthread,howeverwithoutpro-hibitingrecursiveaccesses.Beforeonecan operateon anobject,onemustreserveit, andaftertheoperation(s),onemustreleaseit. Theaccessis grantedonlyif the objectiscurrentlynotreservedor is reservedwiththesamethreadid as that of the attemptedcommand.

Sending a commandis much like droppinga letterin a mailbox.If the addressedobject is located in thesame program, the command is appended to the ownorder/deliveryqueue; otherwise the command is for-warded to the target program. When a program’squeue handler comes to processing a command,three things are ensured: that the specified objectexists, that it can be accessed and that it has regis-tered a method with the same name as contained inthe command.If any of the conditionsfail, the com-mand is rejected with an error notification.Otherwisethe object is reserved and the arguments (if any) areparsed from the command string, converted accordingto the C++ declarationregisteredfor that method andput on the stack. (An argument may be missing if adefault has been registeredfor it.) Finally, the methodis called with the right number of arguments of the

Page 7: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

A FlexibleDistributedNeuralNetworkSimulator 699

right types on the stack, exactly as it would be calledin a C++ program.

When a command returns one or more arguments,we prefer not to talk of a communal, but of an orderassociated with a delivery. The execution of one ormore orders is achievedby creatinga wait id,send-ing each order, registeringeach expected delivery —providing a format string describing the return argu-ments and for each argument a variable to write thereturnedvalue into — and waitingfor all deliveriestohave arrived.

4.3. The data consistencymechanism

Whenthe simulationis distributedoverseveralprocessesandoneprocessfrequentlyneedsto accesssomevariablein anotherprocess,it wouldbe a wasteof networkband-widthto accessthisvariableeach time.The straight-for-wardsolutionis to makea localcopyof thatvariableandsee to it that the copy remains synchronizedwith theoriginalto ensuredata consistency.

In ourBBframework,a simpleandefficientsolutionisto useclones.A cloneBB is a consistent-keepingcopyofan originalBB locatedin the same or anotherprogram.An originalmay have manyclones.By “consistent-kee-pers” we mean both the originaland its clones.

A cloneis dynamicallygeneratedby creatinga BB ofthe same type as the originaland linkingboth. One canget or set variablesof the cloneexactlyas if it were theoriginal.Each changeto the state of the originalor anyclone is automaticallyforwardedto all consistent-kee-pers by means of commands.This transparentmechan-ism minimizesthe networkload,becausea commandisgenerated only when a state variable changes.This iscrucialwhen large matricesmustbe kept consistent.

4.4. The event notificationmechanism

OpenSim’seventnotificationmechanismprovidesa flex-iblemeansfor an objectto react to someevent,e.g. whenits state or the state of a consistent-keeperchanges.Forexampleduringalong loop,it wouldoftenbe convenientto havea menuitemdisplayingthe currentstep.Onecaneasilycausethismenuitemto updateitselfby makingit aclone of the INT that stores the current step and byredrawingthe menuitemaftereach state-changedevent.

One can registerevents with and withoutarguments.If, for instance, a BBs label is changed by a call toSetLabel (), it generates the LABELCHANGEDevent with the new label as argument and propagates itto the consistent-keepers (if any).

There are three types of notifications: (i) some com-mand is sent to someobject; (ii) somemethodof someobject is called from C++; (iii) some shell commandsare executed.

The implementationof the automaticinteractivegra-phics relies heavily on the data consistencyand event

FIGURE7.TheobJeotsesnbsdistributedontovariouswork-stationsandcommuniostasssily.

notificationmechanisms,which are detailed in Leberand Jarosch(1996).

5. OPENACCESSTO THE NETWORK ~

5.1. The communicationbetweenremoteobjects

WithOpenSim,a simulationcan be distributedovermul-tipleprocesses.Commandsto remoteobjectsare therebyexecutedas easilyand safelyas localones(butof coursenot as quickly).This chapterdiscussesthe many advan-tagesthat arise from the open accessto the network.

OpenSim’s “Net Server” program provides object-orientedcommunicationchannelsby implementingthecentral intersection of a star-shaped communicationstructure.At the end of each branch of this star is oneclient process,located in the same workstationor any-whereon the Internet.If necessary,severalindependentstarscanbe operatedsimultaneously.A clientcanconnectto or disconnectfromthenet serverat anytime(Fig.7).

5.2. Parallelcomputing

An open access to the networkallowsone to use avail-able hardware resourceseffectively.Whereas modulescomprisingmenus and plots are best run on the localworkstation,a complexsubroutineis betterexecutedona supercomputer.A significantspeedupcan be achievedfor parallelizablealgorithmsby distributingthem overseveralworkstations,providedthat the necessarycom-municationdoes not becomethe bottleneckof the sys-tem. Synchronizationis doneby waitingfor all parallelcommandsto havebeencompletedbeforecontinuingtheexecution(Fig. 8).

Page 8: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

700 J.-F. LeberandA. Jarosch

PIQ @l@l@

FIGURE8. OpanSimallowaone to use availeblehardwarerasourceeeffectively.

5.3. The dynamicintegrationof functionality

Many advantagesarise from the concept that the localand remote inter-object communicationoperates withASCII addresses, commands and arguments. (Matrixdata are transmittedin binaryform for reasonsof preci-sion and efficiency.)

For example, it is fully transparentfor the user thatremotecommandsare processeddifferently(overUNIXsockets). Also, the readability of the commandssimplifiesdebugging,but much more importantly,thesimulationenvironmentbecomesopen:it can be config-ured dynamically,and new functionalitycan be inte-gratedordine.

That modulescan be integratedat the time they arerequestedsavesmemory.For example,while somealgo-rithm is running, one can visualize the contents of amatrix by startingand connectinga plot moduleto thematrixof interest.(In contrast,a conventionalsimulatoris often a singlelarge program.)The functionalitycon-tained in a newly connected module can instantlybeaccessed from all connectedprogramsby ASCII com-mands,withoutcompilationandlinking(Fig.9).Special-p~se dgofithmic routinesor advancedtypesof visua-lizationcan be integrated,for example,throughan inter-face to MATLABor AVS.

Since a module is comected to the net server as abinary, its programmermay choose the programminglanguageand can protecthis sourcecode. This opens amarketfor commercialmodules.

OpenSim’sdynamicextensibilityfavors an effectivecooperation among researchers, because they canexchange algorithmsby E-mailing the source code, asharedlibraryor a binary.

6. AUTOMATICINTERACTIVEGRAPHICS

6.1. The separationof algorithmsand interactivegraphics

In the sourcecode of most conventionalsimulators,thealgorithms are mixed with the interactive graphics.Unfortunately,the involved event handling tasks aretime-consumingto programand error-prone,even withthe help of a resourceconstructionset.

Clearly, the informationthat needs to be communi-cated between algorithms and interactive graphicsflowsin two ways: forwardfor visualizationand back-wardfor control.Plotsvisualizematrices,menuslet con-trol state variables and call methods. For example,considera BOOL and an associatedcheck box: whenthe BOOL’Svalue is changed, the check box must beinformed to redraw itself according to the new state.Conversely,when the check box is clicked,the BOOLmustbe informedto toggleits state (Fig. 10).

To reducethe softwaredevelopmenteffort,we startedto spliteach moduleinto a simulationkerneland a sepa-rate interactive counterpart. This separation broughtmany advantages,but with respect to the messagestobe passed betweenthe simulationkernel and the inter-active counterpart,a trade-offremained:either a largenumber of specific messages (this required a build-upof a great deal of knowledgeabout the kernel in thecounterpmt),or a few nonspecific messages of the kind

Algorithms Interactive graphiee

BOOL

x)

● cheekboxINT,FLOAT e ● sliderENUM ● sub menuSTRING ● text itemFMATmatrix e , plotmethod ● dialog

Data representation + Datim-sm~;altionand manipulation +

FIGURE9. The ASCIIcommunkatlonenablesthe dynamicintegrationof functionality.

FIGURE10. Tha informationflows forwardand backwerdbetweenthe algorithmsandthe Interactivegraphics.

——— ——.—

Page 9: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

A FlexibleDistributedNeuralNetworkSimulator 701

“update allgraphics” (thiswas inefficient;mostupdatesare superfluous,because typicallyonly a few variableschange their state in responseto an event). Worse, theprogrammerhadto followmanyruleswhenaddingplots,menusand dialogs.

Sowe startedlookingforan automatic wayto generatethe interactive graphics and perform the necessaryupdates.In OpenSim,as a resultof thisquery,interactivecomponents are constructed at the time they arerequested, and memory and CPU time are thus spentonly for the currentlyrequiredcomponents.(In contrast,mostconventionalsimulatorshavea fixedgraphicaluserinterface.)

Thissavestheprogrammermuchworkandtrouble.Heoperates with BBs that have no notion of graphics.Becausethe algorithmsand interactivegraphicsare ide-ally separated,the complexityand error-pronenessareminimized,as well as the developmentand maintenanceefforts. Best of all, exchangingeven interactive algo-rithms is now very easy.

6.2. The interactivebuildingblockserver

A firstimpressionaboutthecapabilitiesof the interactivebuildingblock server (IBBS) was already given in theintroductoryexample.

Each program with interactivegraphicshas its ownIBBS that automaticallygenerates the desired menusand plots for the local buildingblocks. It is, however,ahnost as easy to generatemenus and plots for remotebuildingblocks,locatedin anyclientconnectedto thenetserver.Onecan alsogeneratea fullycustommenuwithasingleshellcoremand,each of whoseitemsmay interactwith any local or remote BB. An item may therebyappear in several menus — the displaysare automati-cally kept consistent.

Relyingon the discusseddata consistencyand event

xgorit ‘$:$j:” IBBS:’/Matrix :

booloint ●fcto ,:

.,4<;,,.,.,wtA: “A~T,,,,interest

z

~ofitij$*;,’2,,.’ IBBS.\-’,$,;,!.,.,,,Ma~x ‘“; Menuboolo ~int ●fct ● .:

.:;;,:,;:,’,,h C: ,,,,“’”,..,’:,“ption

notification mechanisms, the IBBS allows for the genera-tion of as many interactive components as required by theuser at a given time.

To be later able to generate interactive components foran object, say a matrix, the IBBS must first be told toregister its interest for the latter. The corresponding com-mand is internally generated for local objects, but mustbe executed manually for remote objects. The IBBSthenasks the matrix to be appendedto its list of interestedobjects.

At the timetheuserdesiresto interactwiththematrix,he simplysends it an open command.In response,thematrixnotifiesobjectsthathaveregisteredinterestin thisevent, thereforealso the IBBS. The IBBS reacts to thisnotificationby asking the matrix to send an ASCIIdescriptionof itsvariablesandmethods.The IBBSinter-pretsthisstring,createsa newmenu,andfillsit withoneitemforeachmethodandoneitemforeachmanagedBB,for instancea checkbox for a BOOL.

Since the check box inheritsfrom BOOL, the IBBScan linkthe checkboxto the originalBOOLso thatbothkeep consistent:wheneverthe originalis modified,theclonecheckboxisnotifiedandadaptsits look.Wheneverthe check box is clicked,the BOOL’Svalue is toggled;the original is notifiedof the new value and adapts itsstate (Fig. 11).

For generatingplots, OpenSimrelies on the specialbuildingblock STATECMDSthat holds a set of com-mand stringswhichare expectedto containinformationaboutthe desiredtypeof plot, the data to be plotted(theaddressof a matrix)and propertiessuchas colors,axes,etc. For instance,the commandfor associatinga plot’scurve to a matrix looks like: SetVerticalVec–tor (O,‘‘ich.vectorl ‘,‘‘green ‘ , ‘ ‘ 1 /15, f , – 1,1,LINE, NO\YZFILL, NO\ YZDASH,-LIN, O, 0 ) .

When the method Open ( ) of a STATECMDS is

zAlgorithli$$<~;;~’ IBBS

Matrix ,!bool● “int ●fct ● ,1

,,.:,.?:fPart B: .,: ~~•, Otify

FIGURE11.Theautomaticganaretlonof Intaraetivegraphics.

Page 10: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

702 J.-F. LeberandA. Jarosch

FIGURE12.Plotavlsualizamstrlcaa.

called,the IBBScreatesa cloneof it and an emptywin-dow.Then it setsup the windowby executingthe com-mand strings. When one or more plots are open,

d stringimmediatelytakeseffectmodifyingany commanin allplots.Onecaneasilyproduceanimatedsimulationsbecauseeverythingis programmedusingstrings.

Sinceeach plot has its own graphicsettings,it is pos-sible to simultaneouslyobtain different views of thesame matrix data, for examplea 3-D view from severalperspectivesor differentsubsetsof thedata (Fig.12).Alleventsare handledautomatically,and the consistencyisensured.By connectingadditionalIBBSto thenetserver,one can map the samemenuor plot ontoseveralscreensacrosstheInternet.Thissupportsonlineworldwidecoop-eration between investigators,which meets a growingdemand.

7. OPENFOR MODIFICATIONSANDEXTENSIONS

The object-oriented inheritance mechanism simplifiesincremental modifications and extensions to the algo-rithms. To modify some object, one declares a classthat inherits from the original one and programs justthe differences, replacing methods and adding variablesand methods. The code that the new class has in commonwith its parent is not copied, but efficiently shared. (Theadvantages of shared libraries are listed in Section 2.)

Since OpenSim generates the interactive graphicsautomatically, being able to extend the algorithmsimplies being able to extend the interactivegraphics.When, for example, a BOOL is added to some object(BB manager),the correspondingmenu is immediatelyaugmentedby a check box. (In contrast,most conven-tional simulatorshave a rigid graphicaluser interface.)The lack of extensibilityof the interactivegraphicshasbeen recognizedas a majordrawback(Murre,1995).

In the NeuralNetworkcommunity,wherethe primaryconcernis to investigatenew algorithms,researchersarenot satisfiedfor longwith a tool that allowsthemonlyto

adjustthe numberof neuronsor the learningrate. Thesepeoplemustbe able to take algorithmswrittenby othersand quicklyadapt them for their application,as well aseasilyintegratenew algorithms.OpenSimwas designedto satisfytheseneeds.

8. SUPPORTFORNEURALNETWORKOBJECTS

WhenNeuralNetworksimulationsareprogrammedwithOpenSim, the algorithmscan be made to rely eitherdirectly on the presented BBs, or indirectly by usinghigher-level,layer-basedobjects.

8.1. Layer-basedapproach

The concept of using layer objects emerged from theobservationthat ANNsusuallyconsistof multiplehier-archically comected layers. Neuron objects are notrecommendablein those predominantcases where anensembleof identicalunits can be handled more effi-cientlyusingmatrices.

A three-layerPerception,for example, is better notimplementedas an entity,but as three layers of a com-mon type. It is then straight-forwardto simulatea vari-able number of layers. This has been realized usingOpenSim. (Whereas the feed-forward communicationwas easilycascaded,it was less obvioushow to implem-ent the back-propagationalgorithmin a layer-basedform.)

Since real-world applications,such as an acousticalsignalrecognize (Leber, 1992),compriselayersof var-ious types, for instancea filterbank in front of NeuralNetworks,we chose to have all layers share a commonbase. Because the signals are propagatedbetween thelayersby accessingtheir base only, withoutknowledgeof the actual layer types, it is most easy to insert andreplacelayers.Furthermore,a layercancontrolsublayersarranged either serially or in parallel, propagatingthesignalsin a feed-forwardand optionalfeed-backdirec-tion.Thisenablesthesimulationof complexhierarchicalarchitectureswith a high degreeof flexibility.

8.2. Base layer

To serveas a common basis for various types of layers,the base layer (called IO) contains a generally usefulinput–output functionality, featuring an actual inputand output matrix and a collection of input and outputmatrices for storing time functions, sets of patterns orimage sequences. The algorithm is implemented in themethodStep ()of an inheritinglayer.

8.3. Specializedlayers

The task of implementinga particularlayer-basedalgo-rithmreducesto findingthemostsimilarof the availablelayer types, inheriting from it and programmingthe

Page 11: OpenSim: A Flexible Distributed Neural Network Simulator with Automatic Interactive Graphics

A FlexibleDistributedNeuralNetworkSimulator 703

differences. Autogenerated templates for the source filesand a few macros ensure that the programming effortremains small, proportional to the functionality to beadded.

The following scenario gives an idea of the flexibilitythat emerges from such concepts: build an ANN compris-ing several layers, load training data into the matrices,run 10,000 steps, visualize the learned weight organiza-tion and the mapping error, modify the learning rate andrun again, save interesting configurations for laterinvestigations, write a shell program that systematicallytests v~ous configurations, insert a preprocessing layer,append a layer to see whether the generalization abilityimproves, replace one algorithm with another, etc.

OpenSim hasbeenintensivelyusedby the authorsandother researchers to investigateNeural Network algo-rithms comprising the Perception (Back-propagation),ConvolutionalPerception, Hopfield, Kohonen Topol-ogy-preservingFeature Map and Grossberg MaskingField with AdaptiveResonance.These layersall inheritfromthe layerWWthatfeaturesbottom-upweights,top-down weights, lateral-feedback weights, a fittingmeasureand sigmoids.

In the frameworkof an acousticalrecognitionproject,an Audio Interface, Filter Bank and 2-D Filter weredeveloped(Leber, 1992).

In anotherproject,OpenSimgeneratedthe interactivegraphicsfor a series of blocks that synthesizerealisticmobile radio signals and simulate various types ofreceivers.

9. CONCLUSIONS

Arguingthatjiexibility is the primaryrequirementfor aresearcher’ssimulationtool, this paper introducednewobject-orientedtechniquesfor the simulationof NeuralNetworks and other algorithms.OpenSim proves thatflexibledoesnotnecessarilycomewithdij?icultand slow.

By relying on a small set of building blocks, onecan easily program even complex architectures.The

programmablecommand shell providesnetwork-trans-parent access to all variablesand methodsone desiresto interactwith. This allowsone to distributethe algo-rithmic and graphic modules over multiple processes.New functionalitycan be integrated dynamicallyandinterfacedwithexternalcomputingresourcesandspecia-lized visualizationtools.

The interactivegraphicis ideally separatedfrom thealgorithms,becauseeach menuandplot is automaticallygeneratedat the time it is requested.OpenSim’sinterac-tive buildingblock server supportsonlinecooperationacrossthe Intemet.

OpenSimshouldnotbe viewedas a substituteforotherobject-orientedNeural Network simulators. It seemsimprobablethat anyonecould developa simulatorthatwould satisfy all needs across today’s large and stillincreasing spectrum of models and applications.(Forthis reason we did not includeany referenceto a parti-cular simulator.) However, because of its flexibility,OpenSim could well become the preferred basis ofmany simulationtools.

OpenSim5.0 runs under Solaris (by SUN Microsys-tems) and is based on the standards C++ and XWindows.It is portableto other UNIX platforms.Thecompletedocum-entationis available& Jarosch,1996).

REFERENCES

via-WWW(Leber

Leber, J.-F. (1992) The recognitionof acousticalsignalsusingneural networks and an open simulator. Konstanz: Hartung-GomeVerlag.

Leber, J.-F., & Jarosch, A. (1996) OpenSim5.(J(Technical Report IKT-NT 1016), Communication Technology Laboratory. Ziirich: ETH.me PostScript version is available from http:// www.nar-i.ee.etbz.ch/OpenSirn/l.

Matthews, M. B., & Leber, J.-F. (1989). Neural Networks: an overview.Bulletin des Schweiz. ElektrotechnischenVereins (SEV), 15, 1989.

Murre, J. M. (1995) Neorosirmrlators. In M. A. Arbib (Ed.), Thehand-book ojbrain theory andneuralnetworks (p. 634). Cambridge: MJTPress.