Agent decision making in repast simphony using java uses a lot of memory -
i building model number of autonomous agents. make decisions on object choose within immediate environment or "neighborhood". retrieving objects, add them list, sort list based on preferences, , choose top choice every iteration. decision determines movement.
unfortunately, once population of agents becomes high, program slows down massively.
i use compare method (below), relatively short, uses lot of memory, compare objects. wondering if there other methods guys know of might more computationally efficient?
class objectcomparator implements comparator <tree> { @override public int compare(object object1, object object2) { return new comparetobuilder() .append(object1.gettype(), object2.gettype()) .append(object2.getdbh(), object1.getdbh()) .append(object1.getdistancefrom(), object2.getdistancefrom()) .append(object2.isideal(), tree1.isideal()).tocomparison(); } }
some points may useful (note didn't use repast-simphony
of points may implemented framework):
measure - comparison/sorting bottle-neck? said uses lot of memory - doesn't automatically make program run slower (are there gc overhead issues maybe? experiment vm args). , of course before measuring - warm jvm (so jit can catch normal operating conditions code, etc.). find out what's going on
jvisualvm
.i don't know objects you're passing
append
method, consider case can maybe return faster comparing objects now. try use knowledge of specific domain model.you've said agents "retrieve objects, add them list" , sort. maybe beneficial store sorted list of neighbors , if change maybe (that's guess) there little change in list - it's sorted. use sorting algorithm handles "almost sorted lists" lists , compare results default java sorting algorithm. that, of course, depends on how model of neighbors change. if model won't change (i suppose
type
won't change) sorting issue non-existent.consider using plain java code
comparetobuilder
- if have millions of objects object creation might big overhead (if lies on critical path/bottle-neck).do utilize concurrency? maybe speed if run algorithm in parallel way.
many of other optimizations depends on specific object structure , relations. e.g. have tree
type in generics - maybe tree not ballanced, maybe use avl
, heap
, or change linkedlist
arraylist
, etc. experiment & measure.
i hope little.
Comments
Post a Comment