gathering all available information about the state of simulation in every time slot

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

gathering all available information about the state of simulation in every time slot

babak badnava
Hi everyone

I have a question about the available data to the broker on run time.
does any body know a tool that can give me all the available information to the broker in every time slot ?
or I have to make it by my self ? :-)

i saw the log tool example at powertac-tools on github but this is an offline log analyzer i need to analyze the current situation of broker online.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gathering all available information about the state of simulation in every time slot

grampajohn
Administrator
Hello, Babak and all -
babak badnava wrote
I have a question about the available data to the broker on run time. does any body know a tool that can give me all the available information to the broker in every time slot ? or I have to make it by my self ? :-) i saw the log tool example at powertac-tools on github but this is an offline log analyzer i need to analyze the current situation of broker online.
You are correct that the logtool is for offline analysis, and there are elements of the simulation state that are not captured in the state log. We frequently need to make judgement calls about the tradeoff between log size and completeness. The simulation makes distinctions about private vs public information. Private information may be private to a specific broker or to some element of the simulation (such as the wholesale market). Some information is encapsulated as message objects that are then sent to brokers, and some is implicit in the state of the various elements of the simulation environment. For research purposes it should be relatively easy to change the set of messages that are private. Beyond that, it would be necessary to create one or more new message types to communicate internal simulation state. That might not be hard to do, and it might be possible to simply define a message type that communicates the same information to a broker that is currently recorded in the state log. As a simple example, if all you want to do is have your broker see all the private messages of other brokers, it should be enough to make BrokerProxyService.sendMessage() delegate to BrokerProxyService.broadcastMessage(), which would let all brokers see all the messages, or perhaps to modify sendMessage() to send copies to your broker in case the target is some other broker. So I'm reasonably certain that it would be possible, and probably not difficult, to do what you want, but it would require some combination of configuration changes and code modifications to get what you want. Do you have a clear idea about what information you would like your broker to see? Does this help? John
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gathering all available information about the state of simulation in every time slot

babak
Thank you John for your helpful comment.
Actually, I am a teacher assistant and I'm going to use PowerTac environment as one of my test bed.
So before I give my student the homework I need to prepare an interface inorder to they could get the data and analyze them and so on.
I'm looking after some information that is available to brokers in the competition, information like weather forecast, weather report, cache position, broker customer information and .... to make an interface for my student.
My interface should give the users a vector that represent all the available information to a broker during competition in given time slot.
But as I figured out from your comment there is no such tool, So I have to make it by myself
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gathering all available information about the state of simulation in every time slot

grampajohn
Administrator
Dear Babak and all -

Perhaps I misunderstood your question. It's pretty easy to gather all the data received by the browser in each timeslot, without modifying the server at all. All incoming messages are logged (you can see the xml in the trace log) and routed to broker modules in broker-core samplebroker.core.MessageDispatcher.routeMessage(). Not all incoming messages get recorded in the state log; only those marked as @Domain types in the common module are logged.

When a broker logs in to a simulation, it receives a number of messages that tell it about customers and server configuration, as well as the initial weather data, followed by the SimStart message. Each timeslot starts when the broker receives a TimeslotUpdate message, and ends when the broker receives a TimeslotComplete message. You can see the xml message types by inspecting the trace log, and it's generally pretty easy to figure out the java class for each of these types. All messages are defined in the common and common.msg packages in the common module. If you look at the source of one of these types, you will see an annotation @XStreamAlias that defines the xml tag for that type.

If you look at the code in sample-broker samplebroker.ContextManagerService, samplebroker.MarketManagerService, or samplebroker.PortfolioManagerService, you will see a number of handleMessage methods. When the broker starts up, all classes that implement the Initializable interface are inspected (in broker-core samplebroker.core.PowerTacBroker.registerMessageHandlers()) to discover handleMessage methods, and their respective message types are added to a hashmap in MessageDispatcher. Then when messages matching those types arrive, their respective handlers are called.

If you want to write a handler that will handle all incoming messages regardless of type, you could implement handleMessage(Object) in an Initializable class, but the MessageDispatcher in its current form will not see it because it only inspects the top-level class using message.getClass(). To dispatch on a superclass, or on a specific superclass like Object, you would have to add a couple lines in MessageDispatcher.routeMessage() around line 102 to check for superclass registrations. This could be as simple as checking whether there's a registration for the Object type.

Does this help?

John
Loading...