Class AgentsPopulations

java.lang.Object
  |
  +--AgentsPopulations
All Implemented Interfaces:
java.io.Serializable

public class AgentsPopulations
extends java.lang.Object
implements java.io.Serializable

This is the class where the population of agents are initialized. It is also here that the main loop of each experiment is located. In addition, various computations for graphs analysis are carried out here.

Since:
JDK 1.3
See Also:
Serialized Form

Field Summary
private  Agent[] agentSet
          The list of agents
private  java.util.Vector agSet
          The created agents list for purpose of communication
 double averClique
          Average cliquishness in the Agents population, for each problem
 int communication
          Communication between agents is allowed (=1) or not (=0)
private static XCSConstants cons
          Stores the relevant constants for XCS.
 double consultRatio
          Percentage of the population to be consulted by the agents
 double coreCompetence
          Competence range of the agents (determines their core specialisations)
 Environment env
          Stores the posed problem.
private  int maxProblems
          Specifies the number of exploration problems/trials to solve in one experiment by one agent.
private  int nrExps
          Specifies the number of investigated experiments for each agent.
(package private)  int[] orderAgentsTable
          The order in which agents receive the problem
(package private)  java.lang.String orgaType
          Type of the organization studied m= manager c= community
 int payoffType
          Structure of the reward function in the environment
(package private)  double performance
          Performance one agent gains in answering a signal from the problem space
private  double performanceCP
          the cumulated performance of the system
 java.lang.String problemType
          The type of the environment, i.e. the problem space
(package private)  java.io.PrintWriter pwCP
          The output file
(package private)  java.util.Random R
          Random generator
(package private)  int run
          Number of runs of the total simulation
(package private)  double saveProb
          Probabilities for data to be saved for statistical treatment
 int selectorAgent
          Selection in the PredictionArray for each Agent: 1: bestActionWinner 0: rouletteActionWinner
 int totalCommunications
          The total number of communications in the population for each problem.
private static int totalNumberOfAgents
          the number of agents constituting the population
private static AgentsPopulations wholePopulation
          The total population of agents
 
Constructor Summary
AgentsPopulations(int nbAgents, double competence, double consultRatio0, int selectAgent0, int communicate, int payoffType0, java.lang.String problem, int run0, double saveProb0, java.io.PrintWriter pwCP0, int maxProblems0)
          Constructor for the initial organisation
 
Method Summary
private  void affiche(int[][] matrix, java.io.PrintWriter pW1)
          Prints the matrix of relationships into the outfile
private  int[][] buildRelationships(int[][] mat)
          Constructs the matrix of the relationships between agents stored in the out file at the end of each experiment
private  double computeCliquishness(int[][] mat)
          Computes the average cliquishness of the graph derived from the matrix of relationships
private  double computePerformance(double[] perfArray)
          Computes the average performance of the population of agents based on the performance of the responding agents at each signal.
private  int computeSize(int[] neighborhood)
          Computes the size of the neignborhood of an agent
private  int countEdges(int[][] mat, int[] clus, int size)
          Count the number of links existing between the agents belonging to the same neignborhood
(package private)  void doOneSingleStepExperiment()
          Executes one single-step experiment.
 Agent[] getAgentSet()
          return the population of agents considered
 java.util.Vector getSet()
          return the population of agents considered during a communication process
private  int[] listNeighbors(int[][] mat, int[] neighborhood, int i)
          Builds the list of first neighbors of an agent.
 void run()
          The loop where the population of agents is generated and the experiment is launched
 void runExperiment(Environment envt)
          Runs the posed problem with XCS.
 void setNumberOfExperiments(int exps)
          Resets the number of experiments for each agent.
 void setNumberOfTrials(int trials)
          Resets the maximal number of trials in one experiment for an agent.
private  void shakeAgentsOrder(int nbAgents)
          Method used to build at each experiment a random list.
private  void startExperiments()
          This function runs the number of experiments specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxProblems

private int maxProblems
Specifies the number of exploration problems/trials to solve in one experiment by one agent.


nrExps

private int nrExps
Specifies the number of investigated experiments for each agent.


wholePopulation

private static AgentsPopulations wholePopulation
The total population of agents


totalNumberOfAgents

private static int totalNumberOfAgents
the number of agents constituting the population


performanceCP

private double performanceCP
the cumulated performance of the system


agentSet

private Agent[] agentSet
The list of agents


agSet

private java.util.Vector agSet
The created agents list for purpose of communication


env

public Environment env
Stores the posed problem.


cons

private static XCSConstants cons
Stores the relevant constants for XCS.

See Also:
XCSConstants

communication

public int communication
Communication between agents is allowed (=1) or not (=0)


coreCompetence

public double coreCompetence
Competence range of the agents (determines their core specialisations)


consultRatio

public double consultRatio
Percentage of the population to be consulted by the agents


selectorAgent

public int selectorAgent
Selection in the PredictionArray for each Agent: 1: bestActionWinner 0: rouletteActionWinner


payoffType

public int payoffType
Structure of the reward function in the environment


problemType

public java.lang.String problemType
The type of the environment, i.e. the problem space


totalCommunications

public int totalCommunications
The total number of communications in the population for each problem.


averClique

public double averClique
Average cliquishness in the Agents population, for each problem


performance

double performance
Performance one agent gains in answering a signal from the problem space


run

int run
Number of runs of the total simulation


orgaType

java.lang.String orgaType
Type of the organization studied m= manager c= community


pwCP

java.io.PrintWriter pwCP
The output file


orderAgentsTable

int[] orderAgentsTable
The order in which agents receive the problem


saveProb

double saveProb
Probabilities for data to be saved for statistical treatment


R

java.util.Random R
Random generator

Constructor Detail

AgentsPopulations

public AgentsPopulations(int nbAgents,
                         double competence,
                         double consultRatio0,
                         int selectAgent0,
                         int communicate,
                         int payoffType0,
                         java.lang.String problem,
                         int run0,
                         double saveProb0,
                         java.io.PrintWriter pwCP0,
                         int maxProblems0)
Constructor for the initial organisation

Parameters:
nbAgents - Number of Agents (except manager) used in the experiments
competence - Size of the domain of specialisation of agents
consultRatio0 - Percentage of agents' population that is asked at random
selectAgent0 - Mode of rule selection used by agents
communicate - Whether (1) or not (0) communication among agents is allowed
payoffType0 - Structure of the reward function of the environment
problem - The type of problem space
run0 - Number of runs
saveProb0 - Probability of data to be saved
pwCP0 - Name of the first file where results are stored
maxProblems0 - Number of experiments in one run
Method Detail

run

public void run()
The loop where the population of agents is generated and the experiment is launched


getAgentSet

public Agent[] getAgentSet()
return the population of agents considered


getSet

public java.util.Vector getSet()
return the population of agents considered during a communication process


setNumberOfTrials

public void setNumberOfTrials(int trials)
Resets the maximal number of trials in one experiment for an agent. (The default is set to 15000)

Parameters:
trials - The number of problems submitted to agents during one experiment

setNumberOfExperiments

public void setNumberOfExperiments(int exps)
Resets the number of experiments for each agent. (The default is set to 500)

Parameters:
exps - The number of experiments

runExperiment

public void runExperiment(Environment envt)
Runs the posed problem with XCS. The function essentially initializes the output File and then runs the experiments.

Parameters:
envt - The problem space
See Also:
startExperiments()

startExperiments

private void startExperiments()
This function runs the number of experiments specified. After the initialization of the empty population and of the manager, the problem solving routine by the organisation is executed. The problem addressed here is actually a one-step problem.

See Also:
Agent.Agent(double,double), Book#Book(int, int), XClassifierSet.XClassifierSet(int, int), Agent.setAddressBook(Book), Agent.setXClassifierSet(XClassifierSet), Agent.setName(int), doOneSingleStepExperiment()

doOneSingleStepExperiment

void doOneSingleStepExperiment()
Executes one single-step experiment. This is the loop actually monitoring the performance. In addition, performances, efficiencies and some indicators of the graphs produced are computed after matrix of relationships between agents have been built.

See Also:
Square.resetState(), Agent.doOneSingleStepProblemExplore(String, int, AgentsPopulations, int), buildRelationships(int[][]), affiche(int[][], PrintWriter), computeCliquishness(int[][]), computePerformance(double[]), XClassifierSet.printCharacteristics(PrintWriter)

buildRelationships

private int[][] buildRelationships(int[][] mat)
Constructs the matrix of the relationships between agents stored in the out file at the end of each experiment

Parameters:
mat - the matrix initialized with 0s

affiche

private void affiche(int[][] matrix,
                     java.io.PrintWriter pW1)
Prints the matrix of relationships into the outfile

Parameters:
matrix - The matrix of relationships
pW1 - The output file

computeCliquishness

private double computeCliquishness(int[][] mat)
Computes the average cliquishness of the graph derived from the matrix of relationships

Parameters:
mat - the matrix of links (or edges)
See Also:
#listNeighbors(int[][],int,int), #computeSize(int), #countEdges(int[][],int,int)

listNeighbors

private int[] listNeighbors(int[][] mat,
                            int[] neighborhood,
                            int i)
Builds the list of first neighbors of an agent. That is, for an agent i, the routine builds the set of j such that d(i,j)=1 or d(j,i)=1

Parameters:
mat - the matrix of relationships
neighborhood - the initialized neighborhood with all values set to -1
i - the agent of which we seek the neighborhood

computeSize

private int computeSize(int[] neighborhood)
Computes the size of the neignborhood of an agent

Parameters:
neighborhood - The list of first neignbors of the agent considered

countEdges

private int countEdges(int[][] mat,
                       int[] clus,
                       int size)
Count the number of links existing between the agents belonging to the same neignborhood

Parameters:
mat - The matrix of relationships
clus - The list of first neighbors considered
size - The number of neighbors in the neignborhood considered

computePerformance

private double computePerformance(double[] perfArray)
Computes the average performance of the population of agents based on the performance of the responding agents at each signal.

Parameters:
perfArray - The array storing the performance of agents

shakeAgentsOrder

private void shakeAgentsOrder(int nbAgents)
Method used to build at each experiment a random list. When an agent cannot answer a problem (by itself or by communicating), it passes it to the next agent in this list.