Class AgentsPopulations

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

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

Title : communities of practice Description : Model emergence of communities of practice from heterogeneous interacting agents Copyright : Copyright (c) Olivier Dupouet, Murat Yildizoglu

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
private static XCSConstants cons
          Stores the relevant constants for XCS.
 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.
private  java.io.File outFile1
          Stores the specified output File, where the performance will be written.
private  java.io.File outFile2
          Stores the specified output File, where the performance will be written.
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, Environment envt, java.lang.String outFileString1, java.lang.String outFileString2)
          Constructor for the initial population of agents
 
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(java.io.PrintWriter pW1, java.io.PrintWriter pW2)
          Executes one single-step experiment monitoring the performance.
 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.
static void main(java.lang.String[] args)
          The Main loop
 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 startExperiments(java.io.PrintWriter pW1, java.io.PrintWriter pW2)
          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

outFile1

private java.io.File outFile1
Stores the specified output File, where the performance will be written.


outFile2

private java.io.File outFile2
Stores the specified output File, where the performance will be written.


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


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
Constructor Detail

AgentsPopulations

public AgentsPopulations(int nbAgents,
                         Environment envt,
                         java.lang.String outFileString1,
                         java.lang.String outFileString2)
Constructor for the initial population of agents

Parameters:
nbAgents - Number of Agents used in the experiments
envt - The environment chosen for the experiment
outFileString1 - Name of the first file where results are stored
outFileString2 - Name of the second file where results are stored
Method Detail

main

public static void main(java.lang.String[] args)
The Main loop

Parameters:
args - The parameters passed to the programme

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 20000)

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 ten.)

Parameters:
exps - The numbre 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.

See Also:
startExperiments(java.io.PrintWriter, java.io.PrintWriter)

startExperiments

private void startExperiments(java.io.PrintWriter pW1,
                              java.io.PrintWriter pW2)
This function runs the number of experiments specified. After the initialization of the empty population, either one single- or one multi-step problem is executed. The problem addressed here is actually a one-step problem

Parameters:
pW1 - This print writer refers to the first output file for matrices of relationships.
pW2 - This print writer refers to the first output file for various characteristics of agents.
See Also:
Agent.Agent(), Book#Book(int, int), XClassifierSet.XClassifierSet(int, int), Agent.setAddressBook(Book), Agent.setXClassifierSet(XClassifierSet), doOneSingleStepExperiment(java.io.PrintWriter, java.io.PrintWriter)

doOneSingleStepExperiment

void doOneSingleStepExperiment(java.io.PrintWriter pW1,
                               java.io.PrintWriter pW2)
Executes one single-step experiment monitoring the performance.

Parameters:
pW1 - This print writer refers to the first output file for matrices of relationships.
pW2 - This print writer refers to the first output file for various characteristics of agents.
See Also:
Agent#doOneSingleStepProblemExplore(String, int, int), square#resetState(), #buildRelationships(), 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