Getting Started

From powerwiki
Revision as of 17:04, 11 November 2012 by Grampajohn (talk | contribs) (Running the server)
Jump to: navigation, search

This page is intended to help agent developers get started with the Power TAC server and agent framework. Please feel free to add your experiences and insights to the Discussion page (note that you may need to log in to edit that page).

There are currently two main components needed by broker developers: the simulation server, and the sources for the sample broker. Released versions are always available on the github download page. In addition, a log-analysis tool is under development and will soon be available as well.

Power TAC simulation server

The Power TAC simulation server (or just the "server") is designed to be installed and run using maven, a tool that provides a rich dependency-management infrastructure as well as goal-directed build automation. If you do not have a copy of maven on your system, you will need to install it. Although it is not absolutely necessary, we recommend that you build your brokers as maven projects as well, or using some other tool that uses maven repositories, such as Gradle. Note that the server release packages are simply maven configuration files with some documentation; all the actual code will be downloaded by maven the first time you try to run the server.

Running the server

The server runs the Power TAC simulation in two modes; detailed instructions are in the README file included with the server distribution:

  • In "bootstrap" mode, the model runs for a period of time with only the default broker, and collects data on customer power usage, market prices, and weather. This data is saved to a file at the end of the bootstrap period. The resulting data file can be used to run multiple sim sessions.
  • In "sim" mode, the model loads a bootstrap data file and restores the model to its state at the end of the bootstrap period, then allows brokers to log in and sends them the bootstrap data before starting a simulation. The simulation literally starts at the end of the bootstrap period, so for example the first timeslot is not number 0, but the number of timeslots in the bootstrap period. Note that not all of the timeslot-related data is carried over from the bootstrap sim - for example, you cannot see the orderbooks from timeslots that completed in the bootstrap period.

As described in the README file, you can run the server as a web-based app under the jetty webserver, or as a command-line app without a visual interface. In bootstrap mode, there is not much to see, and it runs too fast for the visualizer to keep up. However, you can run a bootstrap session using the visualizer to generate the bootstrap data file needed by the full simulator.

Vcp1.png

For most testing purposes, it makes more sense to run the server from the command line. The main class is org.powertac.server.PowerTacServer in the server-main project. Command-line arguments and other configuration details are described on the Server-configuration page.

Sample Broker

At the time of this writing, the only sample broker implementation available is in Java. Others, including a Repast framework, are on the agenda but awaiting a volunteer to take responsibility.

Currently, the recommended way to use the sample broker is by pulling down the source from Github and modifying it. Note that you can clone it if you want to use git, or fork it if you want to share your work on Github, or you can pull down a source package from the downloads page in the format of your choice. As long as you confine your changes to modules outside the core package, you should be able to integrate your work with future releases fairly easily.

All interaction with the simulation server is through xml-serialized jms messages. You receive them by including them in the registration list in the init() method (see MarketManagerService.java for example), and then writing a handleMessage() method to process it. You may, of course, add additional message-handling modules simply by following the pattern in the existing MarketManagerService and PortfolioManagerService, and adding a call to its init() method in SampleBroker.init(). Outgoing messages to the server are sent by calling the sendMessage() method on the SampleBroker instance. All the message types are in the common module, specifically in the common and common.msg packages. You should not need to download the common package; maven will take care of that.

Brokers also need to interact with the Power TAC Tournament Manager, through a REST interface. This interaction is encapsulated in the core.BrokerTournamentService module. The only purpose of this interaction is to acquire credentials and access details for simulation servers that run under control of the Tournament Manager.

If you want to add new top-level modules to the broker, it should be enough to simply label with with the @Service annotation ahead of the class declaration. MarketManagerService and PortfolioManagerService are labeled this way. This is all the information Spring needs to attempt to instantiate it and wire it in through dependency injection.