From: <nfa...@is...> - 2011-12-27 00:12:26
|
Hi, I have the exact same problem asked in this question: http://old.nabble.com/Programatically-creating-displays-and-data-sets-td28692044.html#a28695775 There are answers with some directions, and I have tried to implement a solution based on those answers. To better understanding of how this process might work, I created a custom ModelInitializer, with the following code: public class PPModelInitializer implements ModelInitializer { @Override public void initialize(Scenario scen, RunEnvironmentBuilder builder) { System.out.println("Model initializer workz!"); DefaultDataGathererDescriptor<Object> dgDesc = new DefaultDataGathererDescriptor<Object>("PPDataGather"); dgDesc.addPrimaryAggregateMapping("testColumn", new PPMapping<Object>()); scen.addMasterControllerAction( new DefaultDataGathererDescriptorAction<Object>(dgDesc) ); } } The mapping class has the following code: class PPMapping<T> extends CountMapping<T> { @Override public Double getColumnValue(Iterable<T> valueSource) { // Return constant value just for testing return 3.0; } } When I run the model, I get a "PPDataGather" in the User Specified Actions of the scenario tree. I click on "PPDataGather", and a menu appears (equal to the Data Sets menu). From here on, it gets a bit messy, with some exceptions thrown (most notably, a null pointer exception on line 173 of DataMappingsStep class. I don't think this Data Sets-like menu makes much sense here; it would make more sense a custom menu where the user could specify the name of the dynamic attributes to gather data from, or at the very least, one could configure the custom data gathering on the model initializer (loading data-gathering configuration from a text file or something). Then, in the GUI, one could create charts and file outputters based on these new data sources. I'm having some trouble understanding how to do this, mainly because the classes of interest (DefaultDataGathererDescriptor, etc), lack proper comments. Having said this, I would really appreciate some kind of more detailed instructions on how to achieve these goals. As a suggestion, maybe this could be a feature in the next version of Repast Symphony (i.e. the possibility of gathering data from runtime-defined attributes)? Thanks in advance, Nuno ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |