edu.ntnu.ecosim.agents.consumers
Class Consumer

java.lang.Object
  extended by edu.ntnu.ecosim.agents.Agent
      extended by edu.ntnu.ecosim.agents.consumers.Consumer

public class Consumer
extends Agent

This is the class that represent the consumer agents.

Author:
Martin

Field Summary
 
Fields inherited from class edu.ntnu.ecosim.agents.Agent
market
 
Constructor Summary
Consumer(int ID, Market market)
          This is the basic constructor, creating a new user without service provider at a specific time.
Consumer(int ID, ServiceProvider spro, Market market)
          This constructor can be used when an initial base of users are to be simulated.
 
Method Summary
 boolean becomeFriend(int friendID)
          Method used to make this consumer become friend with another consumer.
 double getCalculatedValue(int sp)
          Method to get the value this consumer calculated for the specified service provider (used for statistical purposes)
 int[] getFriends()
          Method to get a list of the unique IDs for the friends of this consumer
 int getNofFriends()
          Method to get the number of friends of this consumer
 int getUniqueID()
          Getter method for the unique ID of the consumer.
 boolean hasEnoughFriends()
          Method to check whether or not there is room for more friends.
 boolean isFriend(int friendID)
          Method to check whether this consumer is friend with a specific other consumer.
 boolean isUsing(java.lang.String spUniqueID)
           
 boolean knowsInnovation(java.lang.String unique)
          Method for getting whether or not this consumer knows the specified innovation
 void performAction()
          This is the method that is called for each new time step.
 boolean providerChanged()
          Method to check whether the consumer has changed service provider this round
 void receiveProviderInformation(java.lang.String sproUniqueID, int persuation, java.util.HashMap<java.lang.String,java.lang.String> innovations)
          Method used to receive information about provider from a friend
 void sortFriendList()
          Method to be used to sort the friend list of this consumer in increasing order
 void trimFriendList()
          By using this method, the empty slots of the friend list are removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Consumer

public Consumer(int ID,
                Market market)
This is the basic constructor, creating a new user without service provider at a specific time.

Parameters:
ID - the unique ID of this consumer
market - the market the consumer operates within

Consumer

public Consumer(int ID,
                ServiceProvider spro,
                Market market)
This constructor can be used when an initial base of users are to be simulated.

Parameters:
spro - the service provider this consumer has initially
ID - the unique ID of this consumer
market - the market the consumer operates within
Method Detail

becomeFriend

public boolean becomeFriend(int friendID)
Method used to make this consumer become friend with another consumer.

Parameters:
friendID - the ID of the potential friend
Returns:
true if it's room for this friend, else false

getCalculatedValue

public double getCalculatedValue(int sp)
Method to get the value this consumer calculated for the specified service provider (used for statistical purposes)

Parameters:
sp - The service provider
Returns:
The value of the service provider

getFriends

public int[] getFriends()
Method to get a list of the unique IDs for the friends of this consumer

Returns:
a list of the unique IDs

getNofFriends

public int getNofFriends()
Method to get the number of friends of this consumer

Returns:
the number of friends

getUniqueID

public int getUniqueID()
Getter method for the unique ID of the consumer.

Returns:
the unique ID of the consumer

hasEnoughFriends

public boolean hasEnoughFriends()
Method to check whether or not there is room for more friends.

Returns:
true if the friend network is full, else false

isFriend

public boolean isFriend(int friendID)
Method to check whether this consumer is friend with a specific other consumer.

Parameters:
friendID - the ID of the friend to check
Returns:
true if the consumer is friend with the specified consumer

isUsing

public boolean isUsing(java.lang.String spUniqueID)

knowsInnovation

public boolean knowsInnovation(java.lang.String unique)
Method for getting whether or not this consumer knows the specified innovation

Parameters:
unique - the unique ID of the innovation
Returns:
true if the consumer knows the innovation

performAction

public void performAction()
Description copied from class: Agent
This is the method that is called for each new time step. The method contains the basic operations that an agent performs for each time step.

Specified by:
performAction in class Agent

providerChanged

public boolean providerChanged()
Method to check whether the consumer has changed service provider this round

Returns:
true if the service provider is changed

receiveProviderInformation

public void receiveProviderInformation(java.lang.String sproUniqueID,
                                       int persuation,
                                       java.util.HashMap<java.lang.String,java.lang.String> innovations)
Method used to receive information about provider from a friend

Parameters:
sproUniqueID - the unique ID of the service provider
persuation - the rate of persuation the friend has on this consumer
innovations - a list of known innovations for this provider

sortFriendList

public void sortFriendList()
Method to be used to sort the friend list of this consumer in increasing order


trimFriendList

public void trimFriendList()
By using this method, the empty slots of the friend list are removed. This will save some memory if there are many consumers in the market