org.powertac.common
Class Competition

java.lang.Object
  extended by org.powertac.common.Competition

public class Competition
extends Object

A competition instance represents a single PowerTAC competition and at the same time serves as the place for all competition properties that can be adjusted during competition setup (i.e. during server runtime but before competition start). This is an immutable value type, and most parameters are included in the PluginConfig instances, rather than in individual fields. The single instance is communicated to brokers at the beginning of a game scenario.

Author:
Carsten Block, KIT; John Collins, U of Minnesota

Method Summary
 Competition addBroker(String brokerUsername)
          Adds a broker to the Competition.
 Competition addCustomer(CustomerInfo customer)
          Adds a customer to the Competition.
 int computeTimeslotIndex(org.joda.time.Instant time)
          Converts a time value to the number of timeslots since the beginning of the simulation.
static Competition currentCompetition()
          Returns the current Competition instance.
 int getBootstrapTimeslotCount()
          Number of timeslots in the bootstrap data report for a normal sim.
 List<String> getBrokers()
          The Brokers who are participating in this Competion.
 List<CustomerInfo> getCustomers()
          The list of customers (or more precisely, customer models) in the simulation environment.
 int getDeactivateTimeslotsAhead()
          Number of timeslots, starting with the current timeslot, that are closed for trading.
 String getDescription()
          Uninterpreted text that further describes the competition.
 int getExpectedTimeslotCount()
          Expected value of timeslot count for a normal sim session.
 long getId()
           
 int getMinimumTimeslotCount()
          Minimum number of timeslots for this competition.
 String getName()
          Returns the competition name
 org.joda.time.Instant getSimulationBaseTime()
          Start time of a sim session in the sim world.
 long getSimulationModulo()
          Minimum value in milliseconds by which time advances in a simulation, or in other words, the size of a clock tick.
 long getSimulationRate()
          The time-compression factor for the simulation.
 long getTimeslotDuration()
          Returns the duration of a timeslot in milliseconds real-time.
 int getTimeslotLength()
          Returns the length of a timeslot in minutes (sim time).
 int getTimeslotsOpen()
          Number of timeslots simultaneously open for trading.
static Competition newInstance(String name)
           
 String toString()
           
 void update(Competition template)
          Updates selected fields of this Competition from a template.
 Competition withBootstrapTimeslotCount(int bootstrapTimeslotCount)
          Fluent setter for the bootstrap timeslot count.
 Competition withDeactivateTimeslotsAhead(int deactivateTimeslotsAhead)
          Fluent setter for number of timeslots, starting with the current timeslot, that are closed for trading.Default value is 1.
 Competition withDescription(String description)
          Fluent setter for competition description.
 Competition withExpectedTimeslotCount(int expectedTimeslotCount)
          Fluent setter for the expected length of a normal sim session.
 Competition withMinimumTimeslotCount(int minimumTimeslotCount)
          Fluent setter for minimumTimeslotCount.
 Competition withSimulationBaseTime(org.joda.time.Instant simulationBaseTime)
          Fluent setter for simiulation base time.
 Competition withSimulationModulo(long simulationModulo)
          Fluent setter for simulation modulo.
 Competition withSimulationRate(long simulationRate)
          Fluent setter for time compression ratio.
 Competition withTimeslotLength(int timeslotLength)
          Fluent setter for timeslot length, interpreted as minutes in sim time.
 Competition withTimeslotsOpen(int timeslotsOpen)
          Fluent setter for the open timeslot count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newInstance

public static Competition newInstance(String name)

currentCompetition

public static Competition currentCompetition()
Returns the current Competition instance. There should always be either zero or one of these.


getId

public long getId()

getName

public String getName()
Returns the competition name


getDescription

public String getDescription()
Uninterpreted text that further describes the competition.


withDescription

public Competition withDescription(String description)
Fluent setter for competition description.


getTimeslotLength

public int getTimeslotLength()
Returns the length of a timeslot in minutes (sim time).


getTimeslotDuration

public long getTimeslotDuration()
Returns the duration of a timeslot in milliseconds real-time.


computeTimeslotIndex

public int computeTimeslotIndex(org.joda.time.Instant time)
Converts a time value to the number of timeslots since the beginning of the simulation.


withTimeslotLength

public Competition withTimeslotLength(int timeslotLength)
Fluent setter for timeslot length, interpreted as minutes in sim time.


getMinimumTimeslotCount

public int getMinimumTimeslotCount()
Minimum number of timeslots for this competition. The actual number is randomized by CompetitionControl at sim start time.


withMinimumTimeslotCount

public Competition withMinimumTimeslotCount(int minimumTimeslotCount)
Fluent setter for minimumTimeslotCount.


getBootstrapTimeslotCount

public int getBootstrapTimeslotCount()
Number of timeslots in the bootstrap data report for a normal sim.


withBootstrapTimeslotCount

public Competition withBootstrapTimeslotCount(int bootstrapTimeslotCount)
Fluent setter for the bootstrap timeslot count. It only makes sense to change this before running a bootstrap session.


getExpectedTimeslotCount

public int getExpectedTimeslotCount()
Expected value of timeslot count for a normal sim session.


withExpectedTimeslotCount

public Competition withExpectedTimeslotCount(int expectedTimeslotCount)
Fluent setter for the expected length of a normal sim session.


getTimeslotsOpen

public int getTimeslotsOpen()
Number of timeslots simultaneously open for trading.


withTimeslotsOpen

public Competition withTimeslotsOpen(int timeslotsOpen)
Fluent setter for the open timeslot count. Default value is 24.


getDeactivateTimeslotsAhead

public int getDeactivateTimeslotsAhead()
Number of timeslots, starting with the current timeslot, that are closed for trading.


withDeactivateTimeslotsAhead

public Competition withDeactivateTimeslotsAhead(int deactivateTimeslotsAhead)
Fluent setter for number of timeslots, starting with the current timeslot, that are closed for trading.Default value is 1.


getSimulationBaseTime

public org.joda.time.Instant getSimulationBaseTime()
Start time of a sim session in the sim world. This is actually the start of the bootstrap session, which is typically 15 days before the start of a normal sim session.


withSimulationBaseTime

public Competition withSimulationBaseTime(org.joda.time.Instant simulationBaseTime)
Fluent setter for simiulation base time. This is the start of a simulation scenario, in the sim world, at the beginning of a bootstrap session. So if the bootstrap session collects data for 14 days, with an addional day of discarded data at the beginning, it is 15 days before the start of a normal sim.


getSimulationRate

public long getSimulationRate()
The time-compression factor for the simulation.


withSimulationRate

public Competition withSimulationRate(long simulationRate)
Fluent setter for time compression ratio. Default value is 720, which runs 1-hour timeslots in 5 real-time seconds.


getSimulationModulo

public long getSimulationModulo()
Minimum value in milliseconds by which time advances in a simulation, or in other words, the size of a clock tick. Normally it's one timeslot. In the sim world, time is always at the beginning of a clock tick.


withSimulationModulo

public Competition withSimulationModulo(long simulationModulo)
Fluent setter for simulation modulo. Most likely, most server components will not respond properly for values that are different from a timeslot length. Default value is 3600000 msec.


getBrokers

public List<String> getBrokers()
The Brokers who are participating in this Competion.


addBroker

public Competition addBroker(String brokerUsername)
Adds a broker to the Competition. This only makes sense in the server environment.


getCustomers

public List<CustomerInfo> getCustomers()
The list of customers (or more precisely, customer models) in the simulation environment.


addCustomer

public Competition addCustomer(CustomerInfo customer)
Adds a customer to the Competition. This only makes sense in the server environment.


update

public void update(Competition template)
Updates selected fields of this Competition from a template. This is designed to be used to copy attributes from a bootstrap run into a normal sim run.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.