org.dbe.eve.simulator
Class EvEModel

java.lang.Object
  extended by uchicago.src.sim.engine.SimModelImpl
      extended by uchicago.src.sim.engine.SimpleModel
          extended by org.dbe.eve.simulator.EvEModel
All Implemented Interfaces:
uchicago.src.reflector.DescriptorContainer, uchicago.src.sim.engine.SimEventProducer, uchicago.src.sim.engine.SimModel

public class EvEModel
extends uchicago.src.sim.engine.SimpleModel

Represents the EvE Model as a Repast model

Author:
Roman Greil

Field Summary
private  LocalServicePool centralServicePool
           
private  int distanceSME
           
private  uchicago.src.sim.analysis.Plot fitnessPlot
           
private  uchicago.src.sim.gui.AbstractGraphLayout graphLayout
           
private  float growthFactor
           
private static EvEModel instance
           
private  boolean isRunning
           
private  boolean loadedModel
           
(package private) static org.apache.log4j.Logger logger
           
private  float migrationRate
           
(package private) static MersenneTwister mt
           
private  float mutationFactor
           
private  int nextServiceID
           
private  int nextSMEID
           
private  int numAttributes
           
private  int numAttributesMax
           
private  int numAttributesMin
           
private  int numDemandedServicesMax
           
private  int numDemandedServicesMin
           
private  int numOfSMEPerGroup
           
private  int numServices
           
private  int numSMEs
           
private  int numUselessHops
           
private  java.lang.String saveFitnessDataPath
           
private  java.lang.String saveModelPath
           
private  java.lang.String saveSmeInteractionPath
           
private  boolean servicePoolExchange
           
private  float servicePoolExchangeFactor
           
private  SettingsFrame sf
           
private  boolean showComparisonGraph
           
private  boolean shrinkByAge
           
private  boolean shrinkByProfile
           
private  boolean shrinkByUseage
           
private  float shrinkFactor
           
private  float sMEequalityFactor
           
private  boolean sMEgrouping
           
private  int sMEGroups
           
private  int speedFactor
           
private  int step
           
private  int stepsToEnd
           
private  uchicago.src.sim.gui.DisplaySurface surface
           
private  java.awt.Color surfaceColor
           
(package private)  uchicago.src.sim.gui.TextDisplay td
           
private  boolean useCentralServicePool
           
private  boolean useFitnessPlot
           
private  boolean useNetworkEdges
           
private  boolean usePartnerEdges
           
private  boolean useProducerEdges
           
private  int worldXSize
           
private  int worldYSize
           
 
Fields inherited from class uchicago.src.sim.engine.SimpleModel
agentList, autoStep, isGui, name, params, schedule, seed, shuffle, startAt
 
Fields inherited from class uchicago.src.sim.engine.SimModelImpl
descriptors, modelManipulator
 
Constructor Summary
private EvEModel()
          The EvEModel constructur.
 
Method Summary
 SME addSME(int id, int color, int x, int y)
          creates a new SME and adds it to the agetnList of the model
 SME addSME(int id, java.lang.String name, int color)
          creates a new SME and adds it to the agentList of the model
 SME addSMEbyFact()
          Creates a SME using the factory.
 SME addSMEbyFact(int prototypid)
          Creates a SME using the factory.
 SME addSMEperGroupByFact(int groupid, int prototypid)
          Creates a SME using the factory.
 void atEnd()
          this method is executed at the end of the simulation
 void begin()
          this method is executed after start button
 void buildDisplay()
          builds the repast display
 void buildModel()
          the buildModel method initials the model.
 void buildSchedule()
          the buildSchedule method defines when the methods have to run
private  void distributeOnOfferServices()
          this methode is used to create, out of the DemandedService of a group, service which will be distributed to all other clusters except the group which have stored the DemandedServices
 void drawFitnessPlotPoint()
          draws the fitness plot
private  void exchangeLocalServicePool(SME sMEa, SME sMEb)
          Adds Service of other SMEs to an target SME.
 void exchangeLocalServicePools(SME sme)
          this methode exchange servicePools
 java.util.ArrayList getAgentList()
          Returns the list of smes
 LocalServicePool getCentralServicePool()
           
 int getDistanceSME()
           
 float getGrowthFactor()
           
static EvEModel getInstance()
          Singelton to ensure that only one Instance exsist
 float getMigrationRate()
           
 float getMutationFactor()
           
 double getNetworkFitness()
          calculates the fitness of the hole network
 int getNextServiceID()
          return and increase the id for the next service
 int getNextSMEID()
          return and increase the id for the next sme
 int getNumAttributes()
           
 int getNumAttributesMax()
           
 int getNumAttributesMin()
           
 int getNumDemandedServicesMax()
           
 int getNumDemandedServicesMin()
           
 int getNumOfSMEPerGroup()
           
 int getNumServices()
           
 int getNumSMEs()
           
 int getNumUselessHops()
           
private  SME getRandomAgent()
          returns an SMEs ehich is choosen randomly.
private  java.util.Vector getRandomAgents(int numOfAgents, SME initiatorSME)
          returns an Vector of SMEs the SMEs in the Vector are choosen randomly.
 java.lang.String getSaveFitnessDataPath()
           
 java.lang.String getSaveModelPath()
           
 java.lang.String getSaveSmeInteractionPath()
           
 boolean getServicePoolExchange()
           
 float getServicePoolExchangeFactor()
           
 boolean getShowComparisonGraph()
           
 boolean getShrinkByAge()
           
 boolean getShrinkByProfile()
           
 boolean getShrinkByUseage()
           
 float getShrinkFactor()
           
 SME getSMEbyId(int id)
          returns SME by id
 float getSMEequalityFactor()
           
 boolean getSMEgrouping()
           
 int getSMEGroups()
           
private  java.lang.String getSMEInteractionsAsString()
          return the SMEInteraction as an String
 int getSpeedFactor()
           
 int getStep()
           
 int getStepsToEnd()
           
 boolean getUseCentralServicePool()
           
private  java.lang.String getUsedServiceHistoryAsString()
          return the Histroy of the all UsedService of all SMEs as an String
 boolean getUseFitnessPlot()
           
 boolean getUseNetworkEdges()
           
 boolean getUsePartnerEdges()
           
 boolean getUseProducerEdges()
           
 int getWorldXSize()
           
 int getWorldYSize()
           
private  void instanciateFitnessPlot()
          instanciate the fitness plot
 boolean isRunning()
           
 void loadModel(java.lang.String type)
          load the model from a file
 void migrateService(Service service, SME fromSME)
          Migrates a service from the given SME by the migration probability of the Service
private  java.util.Vector networkLookup(SME initiatorSME)
           
 void restartModel()
           
private  void saveSMEInteractionIntoFile()
          write the sme interaction data into the file network.csv
 void setDistanceSME(int val)
           
 void setGrowthFactor(float growthFactor)
           
 void setLoadedModel(boolean loadedModel)
           
 void setMigrationRate(float val)
           
 void setMutationFactor(float mutationFactor)
           
 void setNumAttributes(int val)
           
 void setNumAttributesMax(int val)
           
 void setNumAttributesMin(int val)
           
 void setNumDemandedServicesMax(int val)
           
 void setNumDemandedServicesMin(int val)
           
 void setNumOfSMEPerGroup(int val)
           
 void setNumServices(int val)
           
 void setNumSMEs(int val)
           
 void setNumUselessHops(int val)
           
 void setSaveFitnessDataPath(java.lang.String val)
           
 void setSaveModelPath(java.lang.String val)
           
 void setSaveSmeInteractionPath(java.lang.String val)
           
 void setServicePoolExchange(boolean val)
           
 void setServicePoolExchangeFactor(float servicePoolExchangeFactor)
           
 void setShowComparisonGraph(boolean value)
           
 void setShrinkByAge(boolean val)
           
 void setShrinkByProfile(boolean val)
           
 void setShrinkByUseage(boolean val)
           
 void setShrinkFactor(float val)
           
 void setSMEequalityFactor(float val)
           
 void setSMEgrouping(boolean val)
           
 void setSMEGroups(int val)
           
 void setSpeedFactor(int speedFactor)
           
 void setStepsToEnd(int stepsToEnd)
           
 void setup()
          The setup method.
 void setupModelSimulation()
          setup new simulation
 void setUseCentralServicePool(boolean value)
           
 void setUseFitnessPlot(boolean val)
           
 void setUseNetworkEdges(boolean val)
           
 void setUsePartnerEdges(boolean val)
           
 void setUseProducerEdges(boolean val)
           
 void setWorldXSize(int val)
           
 void setWorldYSize(int val)
           
 void shrinkServicePools()
          call a shrink mechanism
 void step()
          this happens every step
 void stopModelSimulation()
          stop the Simulation
 void useGA()
          start one GA for a randomly chosen SME. scheduled in buildSchedule()
 
Methods inherited from class uchicago.src.sim.engine.SimpleModel
atPause, getInitParam, getName, getNextDoubleFromTo, getNextIntFromTo, getSchedule, postStep, preStep, run, runAutoStep, setRngSeed, setStoppingTime, setStoppingTime
 
Methods inherited from class uchicago.src.sim.engine.SimModelImpl
addPropertyListener, addSimEventListener, clearMediaProducers, clearPropertyListeners, fireBooleanPropertyEvent, fireEndSim, fireNumericPropertyEvent, fireObjectPropertyEvent, firePauseSim, fireSimEvent, fireStopSim, fireStringPropertyEvent, generateNewSeed, getController, getMediaProducers, getModelManipulator, getParameterDescriptors, getPropertiesValues, getRngSeed, getTickCount, pause, registerDisplaySurface, registerMediaProducer, removePropertyListener, removeSimEventListener, setController, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static EvEModel instance

surfaceColor

private java.awt.Color surfaceColor

isRunning

private boolean isRunning

step

private int step

speedFactor

private int speedFactor

numOfSMEPerGroup

private int numOfSMEPerGroup

growthFactor

private float growthFactor

mutationFactor

private float mutationFactor

servicePoolExchangeFactor

private float servicePoolExchangeFactor

numSMEs

private int numSMEs

numServices

private int numServices

numDemandedServicesMin

private int numDemandedServicesMin

numDemandedServicesMax

private int numDemandedServicesMax

migrationRate

private float migrationRate

useProducerEdges

private boolean useProducerEdges

usePartnerEdges

private boolean usePartnerEdges

useNetworkEdges

private boolean useNetworkEdges

numAttributesMin

private int numAttributesMin

numAttributesMax

private int numAttributesMax

numAttributes

private int numAttributes

numUselessHops

private int numUselessHops

worldXSize

private int worldXSize

worldYSize

private int worldYSize

distanceSME

private int distanceSME

stepsToEnd

private int stepsToEnd

useCentralServicePool

private boolean useCentralServicePool

loadedModel

private boolean loadedModel

useFitnessPlot

private boolean useFitnessPlot

servicePoolExchange

private boolean servicePoolExchange

shrinkByProfile

private boolean shrinkByProfile

shrinkByUseage

private boolean shrinkByUseage

shrinkByAge

private boolean shrinkByAge

sMEgrouping

private boolean sMEgrouping

shrinkFactor

private float shrinkFactor

sMEequalityFactor

private float sMEequalityFactor

nextSMEID

private int nextSMEID

nextServiceID

private int nextServiceID

saveModelPath

private java.lang.String saveModelPath

saveSmeInteractionPath

private java.lang.String saveSmeInteractionPath

saveFitnessDataPath

private java.lang.String saveFitnessDataPath

showComparisonGraph

private boolean showComparisonGraph

centralServicePool

private LocalServicePool centralServicePool

graphLayout

private uchicago.src.sim.gui.AbstractGraphLayout graphLayout

surface

private uchicago.src.sim.gui.DisplaySurface surface

sf

private SettingsFrame sf

fitnessPlot

private uchicago.src.sim.analysis.Plot fitnessPlot

sMEGroups

private int sMEGroups

mt

static MersenneTwister mt

logger

static org.apache.log4j.Logger logger

td

uchicago.src.sim.gui.TextDisplay td
Constructor Detail

EvEModel

private EvEModel()
The EvEModel constructur. A name for the simulation is defined and the repast parameters are defined.

Method Detail

getInstance

public static EvEModel getInstance()
Singelton to ensure that only one Instance exsist

Returns:
AttributePool the instance

setup

public void setup()
The setup method. Default values are set.

Specified by:
setup in interface uchicago.src.sim.engine.SimModel
Overrides:
setup in class uchicago.src.sim.engine.SimpleModel

buildModel

public void buildModel()
the buildModel method initials the model.

Overrides:
buildModel in class uchicago.src.sim.engine.SimpleModel

addSME

public SME addSME(int id,
                  java.lang.String name,
                  int color)
creates a new SME and adds it to the agentList of the model

Parameters:
id - the id of the SME
color - the color of the SME
name - the name of the SME
Returns:
the new SME

addSME

public SME addSME(int id,
                  int color,
                  int x,
                  int y)
creates a new SME and adds it to the agetnList of the model

Parameters:
id - the id of the SME
color - the color of the SME
x - the x position
y - the y position
Returns:
the new SME

addSMEbyFact

public SME addSMEbyFact()
Creates a SME using the factory. No group, no Prototype specified

Returns:
the new SME

addSMEbyFact

public SME addSMEbyFact(int prototypid)
Creates a SME using the factory. No group, no Prototype specified

Parameters:
prototypid -
Returns:
the new SME

addSMEperGroupByFact

public SME addSMEperGroupByFact(int groupid,
                                int prototypid)
Creates a SME using the factory. Group specified, Prototype specified

Returns:
the new SME

distributeOnOfferServices

private void distributeOnOfferServices()
this methode is used to create, out of the DemandedService of a group, service which will be distributed to all other clusters except the group which have stored the DemandedServices


drawFitnessPlotPoint

public void drawFitnessPlotPoint()
draws the fitness plot


instanciateFitnessPlot

private void instanciateFitnessPlot()
instanciate the fitness plot


restartModel

public void restartModel()

stopModelSimulation

public void stopModelSimulation()
stop the Simulation


setupModelSimulation

public void setupModelSimulation()
setup new simulation


getAgentList

public java.util.ArrayList getAgentList()
Returns the list of smes

Returns:
ArrayList with SMEs

shrinkServicePools

public void shrinkServicePools()
call a shrink mechanism


getSMEInteractionsAsString

private java.lang.String getSMEInteractionsAsString()
return the SMEInteraction as an String


getUsedServiceHistoryAsString

private java.lang.String getUsedServiceHistoryAsString()
return the Histroy of the all UsedService of all SMEs as an String

Returns:

saveSMEInteractionIntoFile

private void saveSMEInteractionIntoFile()
write the sme interaction data into the file network.csv


exchangeLocalServicePools

public void exchangeLocalServicePools(SME sme)
this methode exchange servicePools

Parameters:
initiatorSME -

exchangeLocalServicePool

private void exchangeLocalServicePool(SME sMEa,
                                      SME sMEb)
Adds Service of other SMEs to an target SME. The service which will be added are stored in the ServicePool of an sertain SME.

Parameters:
rndAgents - vector of SMEs
targetSME - the SME which will get all Services of the SME of the rndAgents vector

buildDisplay

public void buildDisplay()
builds the repast display


step

public void step()
this happens every step

Overrides:
step in class uchicago.src.sim.engine.SimpleModel

migrateService

public void migrateService(Service service,
                           SME fromSME)
Migrates a service from the given SME by the migration probability of the Service

Parameters:
_service -
_sme -

atEnd

public void atEnd()
this method is executed at the end of the simulation

Overrides:
atEnd in class uchicago.src.sim.engine.SimpleModel

loadModel

public void loadModel(java.lang.String type)
load the model from a file


useGA

public void useGA()
start one GA for a randomly chosen SME. scheduled in buildSchedule()


getRandomAgents

private java.util.Vector getRandomAgents(int numOfAgents,
                                         SME initiatorSME)
returns an Vector of SMEs the SMEs in the Vector are choosen randomly.

Parameters:
numOfAgents - the number of Agents of which the Vector should consist
Returns:
Vector which store the random chosen Agents

getRandomAgent

private SME getRandomAgent()
returns an SMEs ehich is choosen randomly.

Returns:
SME the random picked SME

networkLookup

private java.util.Vector networkLookup(SME initiatorSME)
Returns:

begin

public void begin()
this method is executed after start button

Specified by:
begin in interface uchicago.src.sim.engine.SimModel
Overrides:
begin in class uchicago.src.sim.engine.SimpleModel

buildSchedule

public void buildSchedule()
the buildSchedule method defines when the methods have to run

Overrides:
buildSchedule in class uchicago.src.sim.engine.SimpleModel

getSMEbyId

public SME getSMEbyId(int id)
returns SME by id

Parameters:
id - id of SME

getNetworkFitness

public double getNetworkFitness()
calculates the fitness of the hole network


getNextServiceID

public int getNextServiceID()
return and increase the id for the next service

Returns:
id for new service

getNextSMEID

public int getNextSMEID()
return and increase the id for the next sme

Returns:
id for new sme

setNumSMEs

public void setNumSMEs(int val)

getNumSMEs

public int getNumSMEs()

setNumServices

public void setNumServices(int val)

getNumServices

public int getNumServices()

setNumDemandedServicesMin

public void setNumDemandedServicesMin(int val)

getNumDemandedServicesMin

public int getNumDemandedServicesMin()

setServicePoolExchange

public void setServicePoolExchange(boolean val)

getServicePoolExchange

public boolean getServicePoolExchange()

setNumDemandedServicesMax

public void setNumDemandedServicesMax(int val)

getNumDemandedServicesMax

public int getNumDemandedServicesMax()

setNumAttributesMin

public void setNumAttributesMin(int val)

getNumAttributesMin

public int getNumAttributesMin()

setNumAttributesMax

public void setNumAttributesMax(int val)

getNumAttributesMax

public int getNumAttributesMax()

setNumAttributes

public void setNumAttributes(int val)

getNumAttributes

public int getNumAttributes()

setNumUselessHops

public void setNumUselessHops(int val)

getNumUselessHops

public int getNumUselessHops()

setWorldXSize

public void setWorldXSize(int val)

getWorldXSize

public int getWorldXSize()

setWorldYSize

public void setWorldYSize(int val)

getWorldYSize

public int getWorldYSize()

setDistanceSME

public void setDistanceSME(int val)

getDistanceSME

public int getDistanceSME()

getGrowthFactor

public float getGrowthFactor()

setGrowthFactor

public void setGrowthFactor(float growthFactor)

getSpeedFactor

public int getSpeedFactor()

setSpeedFactor

public void setSpeedFactor(int speedFactor)

setStepsToEnd

public void setStepsToEnd(int stepsToEnd)

getStepsToEnd

public int getStepsToEnd()

getShrinkByProfile

public boolean getShrinkByProfile()

setShrinkByProfile

public void setShrinkByProfile(boolean val)

getShrinkByUseage

public boolean getShrinkByUseage()

setShrinkByUseage

public void setShrinkByUseage(boolean val)

getShrinkByAge

public boolean getShrinkByAge()

setShrinkByAge

public void setShrinkByAge(boolean val)

getServicePoolExchangeFactor

public float getServicePoolExchangeFactor()

setServicePoolExchangeFactor

public void setServicePoolExchangeFactor(float servicePoolExchangeFactor)

getMutationFactor

public float getMutationFactor()

setMutationFactor

public void setMutationFactor(float mutationFactor)

isRunning

public boolean isRunning()

setLoadedModel

public void setLoadedModel(boolean loadedModel)

setShowComparisonGraph

public void setShowComparisonGraph(boolean value)

getShowComparisonGraph

public boolean getShowComparisonGraph()

setUseCentralServicePool

public void setUseCentralServicePool(boolean value)

getUseCentralServicePool

public boolean getUseCentralServicePool()

setShrinkFactor

public void setShrinkFactor(float val)

getShrinkFactor

public float getShrinkFactor()

setSMEGroups

public void setSMEGroups(int val)

getSMEGroups

public int getSMEGroups()

getNumOfSMEPerGroup

public int getNumOfSMEPerGroup()

setNumOfSMEPerGroup

public void setNumOfSMEPerGroup(int val)

getSMEequalityFactor

public float getSMEequalityFactor()

setSMEequalityFactor

public void setSMEequalityFactor(float val)

getSMEgrouping

public boolean getSMEgrouping()

setSMEgrouping

public void setSMEgrouping(boolean val)

getMigrationRate

public float getMigrationRate()

setMigrationRate

public void setMigrationRate(float val)

getUseFitnessPlot

public boolean getUseFitnessPlot()

setUseFitnessPlot

public void setUseFitnessPlot(boolean val)

getStep

public int getStep()

getUseProducerEdges

public boolean getUseProducerEdges()

setUseProducerEdges

public void setUseProducerEdges(boolean val)

getUsePartnerEdges

public boolean getUsePartnerEdges()

setUsePartnerEdges

public void setUsePartnerEdges(boolean val)

getUseNetworkEdges

public boolean getUseNetworkEdges()

setUseNetworkEdges

public void setUseNetworkEdges(boolean val)

getCentralServicePool

public LocalServicePool getCentralServicePool()

getSaveModelPath

public java.lang.String getSaveModelPath()

setSaveModelPath

public void setSaveModelPath(java.lang.String val)

getSaveFitnessDataPath

public java.lang.String getSaveFitnessDataPath()

setSaveFitnessDataPath

public void setSaveFitnessDataPath(java.lang.String val)

getSaveSmeInteractionPath

public java.lang.String getSaveSmeInteractionPath()

setSaveSmeInteractionPath

public void setSaveSmeInteractionPath(java.lang.String val)