The base common class that evaluate the fitness of a robot. More...
Public Types | |
enum | Phases { INTEST, INEVOLUTION, NONE } |
this type define the phase of which the EvoRobotExperiment More... | |
Public Types inherited from ParameterSettable | |
enum | Property |
Public Types inherited from ResourcesUser | |
typedef Resource::ResourceChangeType | ResourceChangeType |
Public Types inherited from Resource | |
enum | ResourceChangeType |
Public Slots | |
int | getStepDelay () |
returns the current delay applied at each step More... | |
float | getWorldTimeStep () const |
helper method for getting timestep of the world at runtime More... | |
void | setStepDelay (int delay) |
set the delay to apply at each step for slowing down the simulation More... | |
Public Member Functions | |
EvoRobotExperiment () | |
Constructor. More... | |
virtual | ~EvoRobotExperiment () |
Destructor. More... | |
virtual void | afterSensorsUpdate () |
Called just after the updating of sensors and before the updating of the neural network. More... | |
bool | agentEnabled (int agentId) |
Returns true if the agent is enabled, false otherwise. More... | |
virtual void | beforeMotorsUpdate () |
Called just before the updating of motors and after the updating of the neural network. More... | |
virtual void | beforeWorldAdvance () |
Called just before the world advances, after the update of motors. More... | |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix) |
Configures the object using a ConfigurationParameters object. More... | |
void | disableAgent (int agentId) |
Disables the i-th agent. More... | |
void | doAllTrialsForIndividual (int individual) |
Performs all trials for the given individual. More... | |
void | enableAgent (int agentId) |
Enables the i-th agent. More... | |
virtual void | endGeneration (int generation) |
Called at the end of a generation. This function is NEVER called concurrently on different objects. More... | |
virtual void | endIndividual (int individual) |
Called at the end of an individual's life. More... | |
void | endIndividualLife () |
Ends the invidual life. More... | |
virtual void | endStep (int step)=0 |
Called at the end of the step. More... | |
virtual void | endTrial (int trial) |
Called at the end of a trial. More... | |
Phases | getActivityPhase () |
return the state of the EvoRobotExperiment More... | |
Arena * | getArena () |
Returns the arena. This can returns NULL if no arena object is present. More... | |
int | getCurStep () const |
Returns the current step. More... | |
int | getCurTrial () const |
Returns the current trial. More... | |
double | getError () |
return the current value of the error More... | |
Evoga * | getEvoga () |
Return the pointer to the Evoga setted. More... | |
double | getFitness () |
return the current value of the fitness More... | |
int | getGenomeLength () |
Returns the length of the genome. More... | |
Motor * | getMotor (QString motorName, int agentId=0) |
Return a pointer to the Motor with name specified. More... | |
int | getNAgents () |
return the number of agents present in the experiment More... | |
Evonet * | getNeuralNetwork (int agentId=0) |
Return the neural network used for the experiment. More... | |
int | getNSteps () const |
Returns the number of steps. More... | |
int | getNTrials () const |
Returns the number of trials. More... | |
Sensor * | getSensor (QString sensorName, int agentId=0) |
Return a pointer to the Sensor with name specified. More... | |
bool | inBatchRunning () |
Return true if the simulation is running in batch modality, false if is running with the GUI. More... | |
virtual void | initGeneration (int generation) |
Called at the beginning of a generation. This function is NEVER called concurrently on different objects. More... | |
virtual void | initIndividual (int individual) |
Called at the beginning of an individual's life. More... | |
virtual void | initStep (int step) |
Initialize whatever at step granularity when needed. More... | |
virtual void | initTrial (int trial) |
void | newGASeed (int seed) |
Called by the ga when the seed changes (e.g. in a new replication) More... | |
virtual void | postConfigureInitialization () |
This function is called after all linked objects have been configured. More... | |
void | restartTrial () |
Stops the current trial and restarts it from scratch. More... | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. More... | |
bool | selectAgent (int agentId) |
select the i-the agent and make available the corresponding resources More... | |
void | setActivityPhase (Phases newPhase) |
set the new activity phase More... | |
void | setEvoga (Evoga *ga) |
Set the Evoga on which this EvoRobotExperiment is used. More... | |
virtual void | setNetParameters (float *genes) |
Sets the free parameters of the neural network. This is done for all agents, even disabled ones. More... | |
virtual void | setNetParameters (int *genes) |
Sets the free parameters of the neural network. This is done for all agents, even disabled ones. More... | |
void | setNSteps (int new_nsteps) |
Sets the number of steps. More... | |
void | setNTrials (int new_ntrials) |
Sets the number of trials. More... | |
virtual void | setTestingAgentAndSeed (int idindividual, int nreplica) |
called by AbstractTest and subclasses to inform which individual is going to test More... | |
void | skipTrial () |
Skips the next trial. More... | |
void | stopTrial () |
Stops the current trial. More... | |
Public Member Functions inherited from ParameterSettable | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
void | removeObserver (RuntimeParameterObserver *obs) |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
Public Member Functions inherited from ConcurrentResourcesUser | |
void | addUsableResource (QString resource) |
void | addUsableResources (QStringList resources) |
void | declareResource (QString name, T *resource, QString lockBuddy="") |
void | deleteResource (QString name) |
T * | getResource (QString name, bool *resourceExists=NULL) |
bool | hasResource (QString name) const |
void | removeAllUsableResources () |
void | removeUsableResource (QString resource) |
void | removeUsableResources (QStringList resources) |
virtual void | shareResourcesWith (ResourcesUser *buddy) |
void | usableResources (QStringList resources) |
bool | usedResourcesExist (QStringList *nonExistingResources=NULL) const |
Static Public Member Functions | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. More... | |
Static Public Member Functions inherited from ParameterSettable | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
Public Attributes | |
QVector< int * > | m_weightIndividual |
Added by Jonata for the SpecializerSteadyState GA. More... | |
Public Attributes inherited from ParameterSettable | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
Protected Member Functions | |
RandomGenerator * | getRNG () |
Returns the random generator. More... | |
void | recreateAllNeuralNetworks () |
Recreates all neural networks. More... | |
void | recreateAllRobots () |
Recreates all robots. More... | |
void | recreateArena () |
Recreates the arena. More... | |
void | recreateNeuralNetwork (int agentId=0) |
Recreate the neural network. More... | |
bool | recreateRobot (int agentId=0) |
Recreate the robot. More... | |
void | recreateWorld () |
current trial More... | |
Protected Member Functions inherited from ParameterSettable | |
void | notifyChangesToParam (QString paramName) |
Protected Member Functions inherited from ConcurrentResourcesUser | |
T * | getResource () |
virtual void | resourceChanged (QString name, ResourceChangeType changeType) |
Protected Member Functions inherited from ResourcesUser | |
ResourcesUser (const ResourcesUser &other) | |
virtual void | notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0 |
ResourcesUser & | operator= (const ResourcesUser &other) |
Protected Attributes | |
int | nstep |
number of cycles More... | |
int | nsteps |
number of test More... | |
int | ntrial |
current step More... | |
int | ntrials |
ConfigurationParameters * | savedConfigurationParameters |
const QString * | savedPrefix |
double | totalErrorValue |
the error of the individual all over the trials More... | |
double | totalFitnessValue |
the fitness value of the individual all over the trials More... | |
double | trialErrorValue |
the error of the individual during the execution of one trial More... | |
double | trialFitnessValue |
the fitness value of the individual during the execution of one trial More... | |
Protected Attributes inherited from ResourcesUser | |
ResourceCollectionHolder | m_resources |
Additional Inherited Members | |
Static Public Attributes inherited from ParameterSettable | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
Static Protected Member Functions inherited from ParameterSettable | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
Detailed Description
The base common class that evaluate the fitness of a robot.
This class don't actually implement any particular scenario or fitness function. The user must subclass from this, and provide the implementation for the necessary methods for setting up his scenario and fitness function.
The main assumption that cannot be changed in the subclasses are:
- the robot and the environment are a simulated physic world (Worldsim::World).
- the controller is a neural network
- the fitness is computed evaluating the robot over a set of trials
The methods that can be re-implemented in order to setup a scenario and a fitness function are:
- initGeneration
- initIndividual
- initTrial
- initStep
- afterSensorsUpdate
- beforeMotorsUpdate
- endStep (this is pure virtual, so it MUST be re-implemented)
- endTrial
- endIndividual
- endGeneration In the most common cases, you need to re-implment just few of them but they are provided for fullfill almost any situations. The schema on which they are called during the evolution of individual is the following:
foreach generation do initGeneration foreach inidividual do initIndividual foreach trial do initTrial foreach step do initStep afterSensorsUpdate beforeMotorsUpdate endStep endTrial endIndividual endGeneration
In the most common case
The resources declared by this experiment are:
- "evonet": the neural network
- "neuronsIterator": the Neurons Iterator for iterate over neurons
- "world": the physic world where the robot are simulated
- "robot": the robot
- "arena": if present, the arena with objects for wheeled robots simulations
Definition at line 155 of file evorobotexperiment.h.
Member Enumeration Documentation
enum Phases |
this type define the phase of which the EvoRobotExperiment
Definition at line 343 of file evorobotexperiment.h.
Constructor & Destructor Documentation
Constructor.
Definition at line 54 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::usableResources().
|
virtual |
Destructor.
Definition at line 84 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::deleteResource().
Member Function Documentation
|
virtual |
Called just after the updating of sensors and before the updating of the neural network.
- Note
- useful, for example, to overwrite the inputs of the neural network (i.e.: to silence some neurons during the experiment withouth modifing sensors classes)
Definition at line 327 of file evorobotexperiment.cpp.
bool agentEnabled | ( | int | agentId | ) |
Returns true if the agent is enabled, false otherwise.
See the description of enableAgent() and disableAgent() for more information
- Parameters
-
agentId the ID of the agent
- Returns
- true if the agent is enabled, false otherwise
Definition at line 496 of file evorobotexperiment.cpp.
|
virtual |
Called just before the updating of motors and after the updating of the neural network.
- Note
- useful, for example, to overwrite the outputs of the neural network
Definition at line 331 of file evorobotexperiment.cpp.
|
virtual |
Called just before the world advances, after the update of motors.
- Note
- useful, for example, to manually actuate motors overriding the robot controller commands
Definition at line 335 of file evorobotexperiment.cpp.
|
virtual |
Configures the object using a ConfigurationParameters object.
This also creates and configures the neural network controlling the individual
- Parameters
-
params the configuration parameters object with parameters to use prefix the prefix to use to access the object configuration parameters. This is guaranteed to end with the separator character when called by the factory, so you don't need to add one
Implements ParameterSettableWithConfigureFunction.
Definition at line 108 of file evorobotexperiment.cpp.
References Arena::addRobots(), ConfigurationParameters::copyGroupTree(), ConfigurationParameters::createGroup(), ConcurrentResourcesUser::declareResource(), ConfigurationHelper::getBool(), ConfigurationHelper::getDouble(), ConfigurationParameters::getGroupsWithPrefixList(), ConfigurationHelper::getInt(), ConfigurationParameters::getValue(), farsa::globalRNG, Logger::info(), ParameterSettable::notifyChangesToParam(), EvoRobotExperiment::nsteps, EvoRobotExperiment::recreateArena(), EvoRobotExperiment::recreateWorld(), EvoRobotExperiment::selectAgent(), ConfigurationParameters::setResourcesUser(), and ConfigurationParameters::shareObserversWith().
|
static |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
- Parameters
-
type is the name of the type regarding the description. The type is used when a subclass reuse the description of its parent calling the parent describe method passing the type of the subclass. In this way, the result of the method describe of the parent will be the addition of the description of the parameters of the parent class into the type of the subclass
Definition at line 196 of file evorobotexperiment.cpp.
References ParameterSettable::addTypeDescription(), ParameterSettable::AllowMultiple, ParameterSettable::RealDescriptor::def(), ParameterSettable::SubgroupDescriptor::describeReal(), EvoRobotExperiment::getNTrials(), EvoRobotExperiment::getWorldTimeStep(), ParameterSettable::RealDescriptor::help(), ParameterSettable::IsMandatory, ParameterSettable::MaxInteger, ParameterSettable::RealDescriptor::runtime(), and EvoRobotExperiment::setNTrials().
void disableAgent | ( | int | agentId | ) |
Disables the i-th agent.
When an agent is disnabled, sensors, motors and the neural network are not updated and the robot is destroyed
- Parameters
-
agentId the id of the agent to disable
- Warning
- This function internally uses declareResource() to remove the robot resource, so it can only be called when the lock on resources is not held.
Definition at line 492 of file evorobotexperiment.cpp.
void doAllTrialsForIndividual | ( | int | individual | ) |
Performs all trials for the given individual.
Definition at line 242 of file evorobotexperiment.cpp.
References Evoga::commitStep(), EvoRobotExperiment::endIndividual(), EvoRobotExperiment::endTrial(), Evoga::getCurrentGeneration(), Evoga::getCurrentSeed(), Evoga::getNumReplications(), Logger::info(), EvoRobotExperiment::initIndividual(), EvoRobotExperiment::initTrial(), Evoga::isStopped(), farsa::msleep(), EvoRobotExperiment::ntrial, RandomGenerator::setSeed(), EvoRobotExperiment::totalFitnessValue, and EvoRobotExperiment::trialFitnessValue.
Referenced by Evoga::evolveGenerational(), Evoga::evolveSpecializerSteadyState(), Evoga::evolveSpecializerSteadyState2(), Evoga::evolveSteadyState(), EvaluatorThreadForEvoga::run(), EvaluatorThreadForXnes::run(), TestRandom::runTest(), TestIndividual::runTest(), TestCurrent::runTest(), and Evoga::xnes().
void enableAgent | ( | int | agentId | ) |
Enables the i-th agent.
When an agent is enabled, sensors, motors and the neural network are updated and the robot exists in the world
- Parameters
-
agentId the id of the agent to enable
- Warning
- This function internally uses declareResource() to declare the robot resource, so it can only be called when the lock on resources is not held.
Definition at line 488 of file evorobotexperiment.cpp.
|
virtual |
Called at the end of a generation. This function is NEVER called concurrently on different objects.
Definition at line 349 of file evorobotexperiment.cpp.
Referenced by Evoga::evolveGenerational(), Evoga::evolveSpecializerSteadyState(), Evoga::evolveSpecializerSteadyState2(), Evoga::evolveSteadyState(), TestRandom::runTest(), TestIndividual::runTest(), TestCurrent::runTest(), and Evoga::xnes().
|
virtual |
Called at the end of an individual's life.
Definition at line 345 of file evorobotexperiment.cpp.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual().
void endIndividualLife | ( | ) |
Ends the invidual life.
Call this function to end the life of the individual. This can only be called from initTrial(), initStep(), endStep() and endTrial(). When you call this function the current trial is stopped as if stopTrial() was called, so everthing said for the stopTrial() function also applies to this function when called inside initStep() or endStep(). If you call this function from initTrial() the trial is terminated immediately without calling any step function. After returning from initTrial(), endTrial() is called. In all cases the fitness for the last trial is taken into account. After the call to endTrial() endIndividual() is called as if the individual life ended normally. You should never mix calls to this functions with calls to stopTrial(), skipTrial() or restartTrial() during the same trial.
Definition at line 425 of file evorobotexperiment.cpp.
|
pure virtual |
Called at the end of the step.
|
virtual |
Called at the end of a trial.
- Note
- the default implementation will add the current trialFitnessValue to totalFitnessValue
Definition at line 339 of file evorobotexperiment.cpp.
References EvoRobotExperiment::totalErrorValue, EvoRobotExperiment::totalFitnessValue, EvoRobotExperiment::trialErrorValue, and EvoRobotExperiment::trialFitnessValue.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual().
|
inline |
return the state of the EvoRobotExperiment
Definition at line 349 of file evorobotexperiment.h.
|
inline |
Returns the arena. This can returns NULL if no arena object is present.
Definition at line 335 of file evorobotexperiment.h.
|
inline |
Returns the current step.
- Returns
- the current step
Definition at line 439 of file evorobotexperiment.h.
|
inline |
Returns the current trial.
- Returns
- the current trial
Definition at line 449 of file evorobotexperiment.h.
double getError | ( | ) |
return the current value of the error
Definition at line 322 of file evorobotexperiment.cpp.
References EvoRobotExperiment::totalErrorValue.
Referenced by EvaluatorThreadForXnes::run(), and Evoga::xnes().
Evoga * getEvoga | ( | ) |
Return the pointer to the Evoga setted.
Definition at line 512 of file evorobotexperiment.cpp.
double getFitness | ( | ) |
return the current value of the fitness
Definition at line 317 of file evorobotexperiment.cpp.
References EvoRobotExperiment::totalFitnessValue.
Referenced by Evoga::evolveGenerational(), Evoga::evolveSpecializerSteadyState(), Evoga::evolveSpecializerSteadyState2(), Evoga::evolveSteadyState(), EvaluatorThreadForEvoga::run(), EvaluatorThreadForXnes::run(), and Evoga::xnes().
int getGenomeLength | ( | ) |
Returns the length of the genome.
Definition at line 431 of file evorobotexperiment.cpp.
Referenced by TestRandom::buildRandomDNA(), and Evoga::postConfigureInitialization().
Motor * getMotor | ( | QString | motorName, |
int | agentId = 0 |
||
) |
Return a pointer to the Motor with name specified.
- Parameters
-
name is the name of the motor your are looking for agentID the id of the agent
- Returns
- a pointer to the motor or NULL is the sensor doesn't exists or the agent is disabled
Definition at line 450 of file evorobotexperiment.cpp.
References Logger::error().
int getNAgents | ( | ) |
return the number of agents present in the experiment
Definition at line 467 of file evorobotexperiment.cpp.
Evonet * getNeuralNetwork | ( | int | agentId = 0 | ) |
Return the neural network used for the experiment.
The pointer to the network is returned even if the agent is disabled
- Parameters
-
agentID the id of the agent
Definition at line 500 of file evorobotexperiment.cpp.
Referenced by TestRandom::buildRandomDNA(), and Evoga::xnes().
|
inline |
Returns the number of steps.
- Returns
- the number of steps
Definition at line 421 of file evorobotexperiment.h.
|
inline |
Returns the number of trials.
- Returns
- the number of trials
Definition at line 403 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::describe().
|
protected |
Returns the random generator.
You should use this function in experiments instead of using farsa::globalRNG because this returns the correct generator depending on whether the same random sequence should be generated for all individuals of the same generation or not. The actual seed for each individual in a given generation depends on the seed of the genetic algorithm, the current generation and the total number of replications (keep this in mind if you want to exactly replicate an experiment)
- Returns
- the random generator
Definition at line 654 of file evorobotexperiment.cpp.
Sensor * getSensor | ( | QString | sensorName, |
int | agentId = 0 |
||
) |
Return a pointer to the Sensor with name specified.
- Parameters
-
name is the name of the sensor your are looking for agentID the id of the agent
- Returns
- a pointer to the sensor or NULL is the sensor doesn't exists or the agent is disabled
Definition at line 438 of file evorobotexperiment.cpp.
References Logger::error().
|
slot |
returns the current delay applied at each step
Definition at line 679 of file evorobotexperiment.cpp.
|
slot |
helper method for getting timestep of the world at runtime
Definition at line 666 of file evorobotexperiment.cpp.
Referenced by EvoRobotExperiment::describe().
bool inBatchRunning | ( | ) |
Return true if the simulation is running in batch modality, false if is running with the GUI.
Definition at line 462 of file evorobotexperiment.cpp.
|
virtual |
Called at the beginning of a generation. This function is NEVER called concurrently on different objects.
Definition at line 296 of file evorobotexperiment.cpp.
Referenced by Evoga::evolveGenerational(), Evoga::evolveSpecializerSteadyState(), Evoga::evolveSpecializerSteadyState2(), Evoga::evolveSteadyState(), TestRandom::runTest(), TestIndividual::runTest(), TestCurrent::runTest(), and Evoga::xnes().
|
virtual |
Called at the beginning of an individual's life.
Definition at line 300 of file evorobotexperiment.cpp.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual().
|
virtual |
Initialize whatever at step granularity when needed.
Definition at line 313 of file evorobotexperiment.cpp.
|
virtual |
Called at the beginning of a trial. The default behaviour is to reset the neural network of all agents (even disabled ones)
Definition at line 304 of file evorobotexperiment.cpp.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual().
void newGASeed | ( | int | seed | ) |
Called by the ga when the seed changes (e.g. in a new replication)
- Parameters
-
seed the new seed
Definition at line 670 of file evorobotexperiment.cpp.
References RandomGenerator::setSeed().
Referenced by Evoga::evolveGenerational(), Evoga::evolveSteadyState(), and Evoga::xnes().
|
virtual |
This function is called after all linked objects have been configured.
Reimplemented from ParameterSettable.
Definition at line 212 of file evorobotexperiment.cpp.
References Evoga::doNotUseMultipleThreads().
|
protected |
Recreates all neural networks.
This method simply calls recreateNeuralNetwork() for all agents' neural networks (even disabled ones)
- Warning
- it will destroy the neural network and create a new one.
Definition at line 648 of file evorobotexperiment.cpp.
References EvoRobotExperiment::recreateNeuralNetwork().
|
protected |
Recreates all robots.
This method simply calls recreateRobot() for all enabled agents
- Warning
- it will destroy all robots and create a new ones.
Definition at line 595 of file evorobotexperiment.cpp.
References EvoRobotExperiment::recreateRobot().
|
protected |
Recreates the arena.
This methods creates an arena if the group Arena is in the ConfigurationParameters
- Warning
- this destroys the current arena and creates a new one
Definition at line 603 of file evorobotexperiment.cpp.
References Arena::addRobots(), ConcurrentResourcesUser::declareResource(), ConfigurationParameters::getObjectFromGroup(), ConfigurationHelper::hasGroup(), EvoRobotExperiment::recreateWorld(), ConfigurationParameters::setResourcesUser(), ConcurrentResourcesUser::shareResourcesWith(), and ResourcesLocker::unlock().
Referenced by EvoRobotExperiment::configure().
|
protected |
Recreate the neural network.
- Parameters
-
agentID the id of the agent having the neural network
This method helps in the creation of the Neural Network (only Evonet for now). It's strongly advised to use this method instead of creating a neural network by yourself. You can configure the neural network after this method accessing to the resource "evonet".
In case of collective experiment, the agentId allow to specify which neural network needs to be recreated
- Warning
- it will destroy the neural network and create a new one.
- Note
- This works also on disabled agents
Definition at line 638 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::declareResource().
Referenced by EvoRobotExperiment::recreateAllNeuralNetworks().
|
protected |
Recreate the robot.
- Parameters
-
agentID the id of the agent having the robot
This method helps in the creation of the Robot. It's strongly advised to use this method instead of creating a robot by yourself. You can configure the robot after having called this method accessing the resource "robot".
In case of collective experiment, the agentId allow to specify which robot needs to be recreated
- Returns
- false if the agent is disabled, true otherwise. If the agent is disabled, the robot is not created
- Warning
- it will destroy the robot and create a new one.
Definition at line 581 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::declareResource().
Referenced by EvoRobotExperiment::recreateAllRobots().
|
protected |
current trial
Recreate the world
This method helps in the creation of the World where the robot and the objects are simulated. It's strongly advised to use this method instead of creating a World by yourself. You can configure the World after this method accessing to the resource "world".
- Warning
- it will destroy the World with any robot and object inside and create a new one without restoring any robot and objects present before.
Definition at line 537 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::declareResource(), ConcurrentResourcesUser::deleteResource(), World::setFrictionModel(), World::setIsRealTime(), World::setMultiThread(), World::setSize(), World::setSolverModel(), and World::setTimeStep().
Referenced by EvoRobotExperiment::configure(), and EvoRobotExperiment::recreateArena().
void restartTrial | ( | ) |
Stops the current trial and restarts it from scratch.
Call this function to stop the current trial and restart it from scratch. The current fitness value is discarded, too. You can call this function only from initStep() or endStep(). After the end of the function from which this is called, the trial is restarted and initTrial() is called. In particular no call to endTrial() is performed in any case and, if you call this function from initStep(), the functions afterSensorsUpdate(), beforeMotorsUpdate() and endStep() for the current step are not called. You should never mix calls to this functions with calls to stopTrial(), skipTrial() or endIndividualLife() during the same trial.
Definition at line 420 of file evorobotexperiment.cpp.
|
virtual |
Save the actual status of parameters into the ConfigurationParameters object passed.
This is not implemented, a call to this function will cause an abort
- Parameters
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Implements ParameterSettable.
Definition at line 190 of file evorobotexperiment.cpp.
References Logger::error().
bool selectAgent | ( | int | agentId | ) |
select the i-the agent and make available the corresponding resources
- Parameters
-
agentID the id of the agent
The resources robot, evonet and neuronsIterator references to the selected agent
By default the selected agent is the 0-th, hence in the single robot experiments the resources robot, evonet and neuronsIterator points to the only robot present into the world
- Returns
- false if the agent is disabled, true otherwise. If the agent is disabled, no action is performed
- Warning
- This function internally uses declareResource() to change the robot, evonet and neuronsIterator pointed by resources. This means that this can only be called when the lock on resources is not held.
Definition at line 471 of file evorobotexperiment.cpp.
References ConcurrentResourcesUser::declareResource().
Referenced by EvoRobotExperiment::configure().
|
inline |
set the new activity phase
Definition at line 353 of file evorobotexperiment.h.
Referenced by EvoRobotComponent::evolve(), EvolveOperation::run(), TestRandom::runTest(), TestIndividual::runTest(), and TestCurrent::runTest().
void setEvoga | ( | Evoga * | ga | ) |
Set the Evoga on which this EvoRobotExperiment is used.
Definition at line 505 of file evorobotexperiment.cpp.
References Evoga::getCurrentSeed(), and RandomGenerator::setSeed().
Referenced by Evoga::configure(), Evoga::evolveSpecializerSteadyState(), Evoga::evolveSpecializerSteadyState2(), Evoga::evolveSteadyState(), and Evoga::xnes().
|
virtual |
Sets the free parameters of the neural network. This is done for all agents, even disabled ones.
Definition at line 516 of file evorobotexperiment.cpp.
Referenced by Evoga::evolveGenerational(), Evoga::evolveSteadyState(), TestRandom::runTest(), TestIndividual::runTest(), EvaluatorThreadForEvoga::setGenotype(), EvaluatorThreadForXnes::setGenotype(), and Evoga::xnes().
|
virtual |
Sets the free parameters of the neural network. This is done for all agents, even disabled ones.
Definition at line 524 of file evorobotexperiment.cpp.
|
inline |
Sets the number of steps.
- Parameters
-
nsteps the new number of steps
Definition at line 430 of file evorobotexperiment.h.
|
inline |
Sets the number of trials.
- Parameters
-
ntrials the new number of trials
Definition at line 412 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::describe().
|
slot |
set the delay to apply at each step for slowing down the simulation
- Parameters
-
delay the delay expressed in msec
- Note
- if the delay is equal to the timestep the simulation will run at real-time
Definition at line 675 of file evorobotexperiment.cpp.
|
virtual |
called by AbstractTest and subclasses to inform which individual is going to test
Definition at line 532 of file evorobotexperiment.cpp.
References Logger::error().
void skipTrial | ( | ) |
Skips the next trial.
Call this function to skip the execution of the next trial. This function can only be called from initTrial(). If you call this function, after initTrial(), execution continues with initTrial() (if there are more trials) or with endIndividual() (if there are no more trials to do). Of course no fitness is assigned for the skipped trials. You should never mix calls to this functions with calls to stopTrial(), restartTrial() or endIndividualLife() during the same trial.
Definition at line 415 of file evorobotexperiment.cpp.
void stopTrial | ( | ) |
Stops the current trial.
Call this function to stop the current trial and move to the next trial (if present). This function can only be called initStep() or endStep(). If you call this from initStep(), the functions afterSensorsUpdate(), beforeMotorsUpdate() and endStep() are also called before terminating the trial. After endStep(), execution continues with endTrial() as if the trial ended normally. This also means that trialFitnessValue is taken into account (unless you overrided the endTrial() function, in which case the behaviour depends on your implementation). You should never mix calls to this functions with calls to skipTrial(), restartTrial() or endIndividualLife() during the same trial.
Definition at line 410 of file evorobotexperiment.cpp.
Member Data Documentation
QVector<int*> m_weightIndividual |
Added by Jonata for the SpecializerSteadyState GA.
This filled with the weights in the tests.cpp file
Definition at line 467 of file evorobotexperiment.h.
Referenced by Evoga::evolveSpecializerSteadyState(), and Evoga::evolveSpecializerSteadyState2().
|
protected |
number of cycles
Definition at line 485 of file evorobotexperiment.h.
|
protected |
number of test
Definition at line 484 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::configure().
|
protected |
current step
Definition at line 486 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual().
|
protected |
the error of the individual all over the trials
Definition at line 562 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::endTrial(), and EvoRobotExperiment::getError().
|
protected |
the fitness value of the individual all over the trials
Definition at line 558 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual(), EvoRobotExperiment::endTrial(), and EvoRobotExperiment::getFitness().
|
protected |
the error of the individual during the execution of one trial
Definition at line 560 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::endTrial().
|
protected |
the fitness value of the individual during the execution of one trial
Definition at line 556 of file evorobotexperiment.h.
Referenced by EvoRobotExperiment::doAllTrialsForIndividual(), and EvoRobotExperiment::endTrial().
The documentation for this class was generated from the following files:
- experiments/evorobot/include/evorobotexperiment.h
- experiments/evorobot/src/evorobotexperiment.cpp