de.upb.swtpra05.group03.shuttle
Class MasterShuttleNegotiation

java.lang.Object
  extended byde.upb.swtpra05.group03.shuttle.MasterShuttleNegotiation
All Implemented Interfaces:
Module, ShuttleModule

public class MasterShuttleNegotiation
extends java.lang.Object
implements ShuttleModule

ShuttleModule which is responsible for the acquisition of new orders for the shuttle. This implementation represents the "MasterShuttleStrategy", that is that:

Version:
$Revision: 1.3 $

Field Summary
protected  ActivityControllerInterface activityController
          The strategy control
protected  ShuttleControlInterface agent
          the shuttle control
private  boolean allowMaxOffer
          if set true, maxOffers are able to be used.
protected  java.util.Map bestOfferPrices
          Map of BestShuttleOfferPrice with an order id as key
protected  CompanyInterface company
          The company
protected  java.util.Map evaluatedSelfcosts
          Map of wakeUpTimes and lists of ExtendedOrders for which selfcosts were evaluated, so they should as fast as possible be removed if we don't offer for them.
private  boolean forceMaxOffer
          if set true, the shuttle will always send MaxOffer
private static java.util.logging.Logger log
          Logger for debugging
protected  MarginControllerInterface marginController
          the margin controller
private  java.util.Random maxOfferRandom
          Randomizer to send the Maxoffer
protected  int maxOrderCount
          Maximum number of order we should execute.
protected  OfferingControlInterface offeringControl
          The offering control
protected static int OFFERPRICE_SENDTIME
          Time between the sending of a offerPrice message and the possible receiving of a YouHaveWonMessage
protected  OrderContainerInterface orderContainer
          the extended order container
protected  int orderCount
          count of orders the shuttle is working on
protected  OrderEvaluaterInterface orderEvaluater
          The order evaluater
protected  RiskControlInterface riskControl
          The risk control
protected  SCCCalculatorInterface sccCalculator
          The strong connection components calculator
static int STRATEGY
          The strategy of this negotiation implementation
protected  StrategyControlInterface strategyControl
          The strategy control
protected  UnsuccessfulOfferInterface unsuccessfulOffer
          The unsuccessful offer module(s)
 
Constructor Summary
MasterShuttleNegotiation()
          Constructor for MasterShuttleNegotiation
 
Method Summary
protected  int calculateOfferPrice(ExtendedOrder eo)
           
protected  void checkAllOfferPricesReceived(java.lang.Integer orderId, BestShuttleOfferPrice bestOfferPrice)
           
 int getMaxOrderCount()
          Returns the max order count.
 int getOrderCount()
          Returns the order count.
protected  int getRandomMaxOffer(ExtendedOrder eo)
           
 void init(ModuleContainerInterface container)
          Initializes this module.
 void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
          React on the received message of the shuttle or not.
protected  void offerPriceMessage(OfferPriceMessage msg)
          If we are the MasterShuttle update best shuttle offerPrice and if we have the offerPrice of all shuttles send the YouHaveWonMessage to the shuttle with the best offerPrice.
protected  void orderAvailable(de.upb.swtpra.kernel.message.OrderAvailable msg)
          Send offer price of the order to the masterShuttle.
protected  void sendEvaluatedSelfcostsRemoveWakeUpRequest(ExtendedOrder eo, int curTime)
           
protected  void sendYouHaveWon(int orderId, de.upb.swtpra.kernel.id.ID bestShuttle)
           
 void setMaxOrderCount(int orderCount)
          Sets the max order count.
protected  void shuttleCountReduced()
           
protected  void turnierMessage(TurnierMessage msg)
          sets if the shuttle sends maxOffers
protected  void updateOfferPrices(java.lang.Integer orderId, de.upb.swtpra.kernel.id.ID shuttleID, int selfcosts)
          Update best offerPrice for given orderId, shuttle and offerPrice.
protected  void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
           
protected  void youHaveWonMessage(YouHaveWonMessage msg)
          Calculates the price to offer and sends the offer to the kernel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRATEGY

public static final int STRATEGY
The strategy of this negotiation implementation

See Also:
Constant Field Values

OFFERPRICE_SENDTIME

protected static final int OFFERPRICE_SENDTIME
Time between the sending of a offerPrice message and the possible receiving of a YouHaveWonMessage

See Also:
Constant Field Values

maxOrderCount

protected int maxOrderCount
Maximum number of order we should execute.


evaluatedSelfcosts

protected final java.util.Map evaluatedSelfcosts
Map of wakeUpTimes and lists of ExtendedOrders for which selfcosts were evaluated, so they should as fast as possible be removed if we don't offer for them.


bestOfferPrices

protected final java.util.Map bestOfferPrices
Map of BestShuttleOfferPrice with an order id as key


orderCount

protected int orderCount
count of orders the shuttle is working on


agent

protected ShuttleControlInterface agent
the shuttle control


orderContainer

protected OrderContainerInterface orderContainer
the extended order container


marginController

protected MarginControllerInterface marginController
the margin controller


sccCalculator

protected SCCCalculatorInterface sccCalculator
The strong connection components calculator


riskControl

protected RiskControlInterface riskControl
The risk control


offeringControl

protected OfferingControlInterface offeringControl
The offering control


strategyControl

protected StrategyControlInterface strategyControl
The strategy control


orderEvaluater

protected OrderEvaluaterInterface orderEvaluater
The order evaluater


unsuccessfulOffer

protected UnsuccessfulOfferInterface unsuccessfulOffer
The unsuccessful offer module(s)


activityController

protected ActivityControllerInterface activityController
The strategy control


company

protected CompanyInterface company
The company


log

private static final java.util.logging.Logger log
Logger for debugging


maxOfferRandom

private java.util.Random maxOfferRandom
Randomizer to send the Maxoffer


forceMaxOffer

private boolean forceMaxOffer
if set true, the shuttle will always send MaxOffer


allowMaxOffer

private boolean allowMaxOffer
if set true, maxOffers are able to be used.

Constructor Detail

MasterShuttleNegotiation

public MasterShuttleNegotiation()
Constructor for MasterShuttleNegotiation

Method Detail

init

public void init(ModuleContainerInterface container)
Description copied from interface: Module
Initializes this module. References to other modules should be set here to avoid circle dependencies.

Specified by:
init in interface Module
Parameters:
container - The module manager which contain all modules

getOrderCount

public int getOrderCount()
Returns the order count.

Returns:
the order count

setMaxOrderCount

public void setMaxOrderCount(int orderCount)
Sets the max order count.

Parameters:
orderCount - The new max order count

getMaxOrderCount

public int getMaxOrderCount()
Returns the max order count.

Returns:
the max order count.

newMessageReceived

public void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
Description copied from interface: ShuttleModule
React on the received message of the shuttle or not.

Specified by:
newMessageReceived in interface ShuttleModule
Parameters:
msg - The received message of the shuttle

wakeUpCall

protected void wakeUpCall(de.upb.swtpra.kernel.message.WakeUpCallMessage msg)
Parameters:
msg -

turnierMessage

protected void turnierMessage(TurnierMessage msg)
sets if the shuttle sends maxOffers

Parameters:
msg - the turniermessage

orderAvailable

protected void orderAvailable(de.upb.swtpra.kernel.message.OrderAvailable msg)
Send offer price of the order to the masterShuttle.

Parameters:
msg - The OrderAvailable message

calculateOfferPrice

protected int calculateOfferPrice(ExtendedOrder eo)
Parameters:
eo -
Returns:
offer price

sendEvaluatedSelfcostsRemoveWakeUpRequest

protected void sendEvaluatedSelfcostsRemoveWakeUpRequest(ExtendedOrder eo,
                                                         int curTime)
Parameters:
eo -
curTime -

getRandomMaxOffer

protected int getRandomMaxOffer(ExtendedOrder eo)
Parameters:
eo - extendedorder
Returns:
the selfcosts

youHaveWonMessage

protected void youHaveWonMessage(YouHaveWonMessage msg)
Calculates the price to offer and sends the offer to the kernel.

Parameters:
msg - The YouHaceWonMessage

offerPriceMessage

protected void offerPriceMessage(OfferPriceMessage msg)
If we are the MasterShuttle update best shuttle offerPrice and if we have the offerPrice of all shuttles send the YouHaveWonMessage to the shuttle with the best offerPrice.

Parameters:
msg - The OfferPriceMessage

updateOfferPrices

protected void updateOfferPrices(java.lang.Integer orderId,
                                 de.upb.swtpra.kernel.id.ID shuttleID,
                                 int selfcosts)
Update best offerPrice for given orderId, shuttle and offerPrice.

Parameters:
orderId -
shuttleID -
selfcosts -

checkAllOfferPricesReceived

protected void checkAllOfferPricesReceived(java.lang.Integer orderId,
                                           BestShuttleOfferPrice bestOfferPrice)
Parameters:
orderId -
bestOfferPrice -

sendYouHaveWon

protected void sendYouHaveWon(int orderId,
                              de.upb.swtpra.kernel.id.ID bestShuttle)
Parameters:
orderId -
bestShuttle -

shuttleCountReduced

protected void shuttleCountReduced()