Class SimpleDemandManager

java.lang.Object
  extended by SimpleDemandManager
All Implemented Interfaces:
InterfaceDemandManager

public class SimpleDemandManager
extends java.lang.Object
implements InterfaceDemandManager

A very simple demand manager.


Nested Class Summary
(package private)  class SimpleDemandManager.OrderHandler
          Used for sorting orders and/or RFQs
 
Field Summary
private  DailyActions actions
           
private  AgentInfo agentInfo
           
private  int[] completedComputers
          number of computers remaining in inventory
private  double[] componentCost
           
private  int[][] components
          number of components remaining
private  double[] computerCost
           
private  int[] cycles
          cycles remaining each day
private  int date
           
private  DailyInfo dayInfo
           
(package private) static int numComponents
           
(package private) static int numComputers
           
private  int numProductionDays
          how many days of production to plan for
private  se.sics.tasim.props.OfferBundle offers
           
private  int[][] producedPerDay
          how many of each computer are produced per day
private  double[] salesPrices
           
private  GameSettings settings
           
 
Constructor Summary
SimpleDemandManager()
           
 
Method Summary
private  void calculateCosts()
          Predicts replacement costs for each type of component and computer
private  void getProductionDays()
          Determines how many days of production should be planned for.
private  void handleRFQs()
          Makes offers on RFQs.
private  void predictSalesPrices()
          Predicts the price that each type of computer will sell for.
 void produceDeliverBid(GameSettings settings, DailyInfo dayInfo, AgentInfo agentInfo, DailyActions actions)
          Performs all of the demand manager's actions: produce and deliver computers, and bid on RFQs from customers.
private  void produceExistingOrders()
          Tries to deliver or produce existing orders.
 void projectFutureComponentUse()
          Project component use for some number of days in the future, so the supply manager will know what to order.
private  void sendProductionSchedule()
          Determines the production schedule for tomorrow, and sends it to the factory.
private  void setupResources()
          Initializes the resources - cycles, components, and completed computers.
private  boolean tryToProduce(int index, int quantity, int daysUntilDue)
          Tries to produce the needed computers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numComponents

static final int numComponents
See Also:
Constant Field Values

numComputers

static final int numComputers
See Also:
Constant Field Values

settings

private GameSettings settings

dayInfo

private DailyInfo dayInfo

agentInfo

private AgentInfo agentInfo

actions

private DailyActions actions

date

private int date

numProductionDays

private int numProductionDays
how many days of production to plan for


offers

private se.sics.tasim.props.OfferBundle offers

componentCost

private double[] componentCost

computerCost

private double[] computerCost

salesPrices

private double[] salesPrices

components

private int[][] components
number of components remaining


completedComputers

private int[] completedComputers
number of computers remaining in inventory


cycles

private int[] cycles
cycles remaining each day


producedPerDay

private int[][] producedPerDay
how many of each computer are produced per day

Constructor Detail

SimpleDemandManager

public SimpleDemandManager()
Method Detail

calculateCosts

private void calculateCosts()
Predicts replacement costs for each type of component and computer


predictSalesPrices

private void predictSalesPrices()
Predicts the price that each type of computer will sell for.


getProductionDays

private void getProductionDays()
Determines how many days of production should be planned for.


setupResources

private void setupResources()
Initializes the resources - cycles, components, and completed computers.


produceExistingOrders

private void produceExistingOrders()
Tries to deliver or produce existing orders. Orders are sorted by profit, then considered one at a time. Orders that are due or late will be delivered if possible. Other orders will not be delivered yet. An attempt will be made to produce each order up to its cancellation date.


handleRFQs

private void handleRFQs()
Makes offers on RFQs. A fixed offer price is used for each type of computer. RFQs are sorted in order of profit, then considered one at a time. An offer will be made for any RFQ that can be produced in time. To make sure that some cycles are reserved for RFQs on future days, only some of the remaining cycles are made available.


tryToProduce

private boolean tryToProduce(int index,
                             int quantity,
                             int daysUntilDue)
Tries to produce the needed computers. The computers will be produced using cyles and components from the latest possible days. If not all computers can be produced, the remainder will be taken from already completed computers if possible.

Parameters:
index - computer index
quantity - how many are needed
daysUntilDue - how far in the future the due date is
Returns:
whether production was possible

sendProductionSchedule

private void sendProductionSchedule()
Determines the production schedule for tomorrow, and sends it to the factory. If there are free cycles, projected production from future days is moved forwards.


projectFutureComponentUse

public void projectFutureComponentUse()
Project component use for some number of days in the future, so the supply manager will know what to order.


produceDeliverBid

public void produceDeliverBid(GameSettings settings,
                              DailyInfo dayInfo,
                              AgentInfo agentInfo,
                              DailyActions actions)
Performs all of the demand manager's actions: produce and deliver computers, and bid on RFQs from customers.

Specified by:
produceDeliverBid in interface InterfaceDemandManager