swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bank Model mini-TR


From: Manor Askenazi
Subject: Bank Model mini-TR
Date: Mon, 13 Jan 1997 09:33:44 -0700

> Unless he takes the initiative and sends it directly to the list
> .... hint hint, Manor. [grin]
>
> glen

OK, OK!!! ;-)

The thought of anybody reading the actual code of Bank in order 
to understand the underlying model fills me with remorse guilt 
and anxiety :) 

So, I will be writing up a quick mini-TR about the model (with cool 
OMT diagrams of the classes and everything ;) 

With regards to the underlying graph library, I hesitate to document
it because this was truly a quick hack to get some demos working
and now is actually the ideal time to re-write it cleanly, perhaps
according to the design spec attached below. 

In fact if there is a group out there who is interested in doing some
work on this model or the underlying graph library, I would be happy 
to collaborate on a cleaner re-implementation: economic and political 
games on graphs are fun!!!

Regards,

Manor.

--------------------------------------------------------------------
             Re-Design of Graph Library Interface
--------------------------------------------------------------------

// Copyright (C) 1995 The Santa Fe Institute.
// No warranty implied, see LICENSE for terms.

#import <defobj.h>
#import <swarmobject.h>
#import <collections.h>

//------------------------------------------------------------------

extern void initGraphLibrary();

//------------------------------------------------------------------

@protocol DiGraph <SwarmObject, CREATABLE> 

CREATING

// If these two methods are used this means that the user chooses to
// have access to the underlying collections which hold the Nodes and
// Edges. One reason to do this is to enforce an ordering on the Nodes
// or Edges. I would like for this to cause a Switcheroo which would
// enable the appropriate getCollection methods (if the user claims
// the right to interfere with the internals s/he should get access
// to them, but not otherwise)!!!

-setNodeCollection: aCollection ;
-setLinkCollection: aCollection ;

// No Canvas --> No Graphics
// Again, this is a great opportunity to Switcheroo... The graphical
// stuff simply doesn't exist if this isn't set. 

-setCanvas: aCanvas ;

USING

// Will not exist if setCanvas wasn't called.
-getCanvas ;

// Available only if set by user! 
// Roger: How do you represent such 'conditional' methods?

-getNodeCollection ;
-getLinkCollection ;

// Return IMMUTABLE Unsafe Index To The Appropriate Collection
// IMMUTABLE: no way to remove stuff or add stuff through the index...
//
// Q: Does rmb have an IMMUTABLE index?
// Q: Is it possible to specify that a return value is defined 
//    to understand a particular protocol?

-beginNodeCollection: aZone ;
-beginLinkCollection: aZone ;

-createNode ;
-createNodeWithName: (char *) aName ;

-createLinkFrom: thisNode To: thatNode ;

-removeLink: aLink ;
-removeNode: aNode ;

// Graphics
-redistribute ;
-update ;

@end

//------------------------------------------------------------------

@protocol DiGraphNode <SwarmObject, CREATABLE>

CREATING

-setName: (char *) aName ;

-setInCollection: aCollection ;
-setOutCollection: aCollection ;

USING

-(int) inDegree ;
-(int) outDegree ;
// Is this last one superfluous... (degree = inDegree + outDegree)
-(int) degree ;

-(BOOL) linkedTo: aNode ;
-(BOOL) linkedFrom: aNode ;

-getInCollection ;
-getOutCollection ;

// Return IMMUTABLE Unsafe Index To The Appropriate Collection
// Q: Does rmb have an IMMUTABLE index?

-beginInCollection: aZone ;
-beginOutCollection: aZone ;

-makeLinkTo: aNode ;
-makeLinkFrom: aNode ;

-removeLink: aLink ;

//For Speed We Also Have:
-removeInLink:  aLink ;
-removeOutLink: aLink ;

// Rather than return an index which is likely to be unsafe,
// the user gives me a collection to which I add references.
// This allows her/him to to forall etc on the contents without
// crashing (this is always preferable).

-collectNeighboursInto: aCollection ;
-collectSourcesInto:    aCollection ;
-collectTargetsInto:    aCollection ;
-collectLinksToInto:   aNode in: aCollection ;
-collectLinksFromInto: aNode in: aCollection ;

// Low level accessors and callbacks to be used 
// by ambitious graphics hackers... Consequently, 
// they are only hinted at.
//
//   -getNodeItem ;
//   -(int) agreeX: (int) x Y: (int) y ;
//   -updateLinks ;
//   -update ;

@end

//------------------------------------------------------------------

@protocol DiGraphLink <SwarmObject, CREATABLE>

USING

-getSource ;
-getTarget ;

// Low level accessors and callbacks to be used 
// by ambitious graphics hackers... Consequently, 
// they are only hinted at.
//
//   -getLinkItem ;
//   -update ;

@end

//------------------------------------------------------------------

extern id <Symbol> RectangleNode, OvalNode ; 

//------------------------------------------------------------------

@class DiGraph ;
@class DiGraphNode ;
@class DiGraphLink ;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]