evorobotexperiment.cpp
75 // be the first to declare resources (if we did this later we should have used addUsableResources
77 usableResources( QStringList() << "world" << "arena" << "experiment" << "robot" << "evonet" << "neuronsIterator" );
119 batchRunning = ConfigurationHelper::getBool(params, "__INTERNAL__/BatchRunning", batchRunning); // If we are running in batch or not
120 ntrials = ConfigurationHelper::getInt(params, prefix + "ntrials", ntrials); // number of trials to do
121 nsteps = ConfigurationHelper::getInt(params, prefix + "nsteps", nsteps); // number of step for each trial
149 Descriptor d = addTypeDescription( type, "The experimental setup that defines the conditions and the fitness function of the evolutionary experiment" );
150 d.describeInt( "ntrials" ).def(1).limits(1,MaxInteger).runtime( &EvoRobotExperiment::setNTrials, &EvoRobotExperiment::getNTrials ).help("The number of trials the individual will be tested to calculate its fitness");
151 d.describeInt( "nsteps" ).def(1).limits(1,MaxInteger).help("The number of step a trials will last");
152 d.describeInt( "nagents" ).def(1).limits(1,MaxInteger).help("The number of embodied agents to create", "This parameter allow to setup experiments with more than one robot; all agents are clones");
153 d.describeSubgroup( "NET" ).props( IsMandatory ).type( "Evonet" ).help( "The Neural Network controlling the robot");
155 d.describeSubgroup( "Sensor" ).props( AllowMultiple ).type( "Sensor" ).help( "One of the Sensors from which the neural network will receive information about the environment" );
156 d.describeSubgroup( "Motor" ).props( AllowMultiple ).type( "Motor" ).help( "One of the Motors with which the neural network acts on the robot and on the environment" );
159 SubgroupDescriptor world = d.describeSubgroup( "World" ).help( "Parameters affecting the simulated World" );
160 world.describeReal( "timestep" ).def(0.05).runtime( &EvoRobotExperiment::setWorldTimestep, &EvoRobotExperiment::getWorldTimeStep ).help( "The time in seconds corresponding to one simulated step of the World" );
361 Logger::error( "getSensor returned NULL pointer because there is no sensor named "+name+" in the agent "+QString::number(id) );
370 Logger::error( "getMotor returned NULL pointer because there is no motor named "+name+" in the agent "+QString::number(id) );
471 if (!ConfigurationHelper::hasGroup( *savedConfigurationParameters, (*savedPrefix) + "Arena" ) ) {
538 // Reading the sensors parameters. For each sensor there must be a subgroup Sensor:NN where NN is a progressive number
540 QStringList sensorsList = exp->savedConfigurationParameters->getGroupsWithPrefixList((*(exp->savedPrefix)), "Sensor:");
555 Sensor* sensor = exp->savedConfigurationParameters->getObjectFromGroup<Sensor>((*(exp->savedPrefix)) + sensorGroup);
557 Logger::error("Cannot create the Sensor from group " + *(exp->savedPrefix) + sensorGroup + ". Aborting");
561 // the Sensors are renamed using the same name of the Group when they don't have a name assigned
568 // if the user manually set the name and create a name clash, it is only reported as error in Logger
570 Logger::error( "More than one sensor has name "+sensor->name()+" !! The name has to be unique !!" );
578 QStringList motorsList = exp->savedConfigurationParameters->getGroupsWithPrefixList((*(exp->savedPrefix)), "Motor:");
593 Motor* motor = exp->savedConfigurationParameters->getObjectFromGroup<Motor>((*(exp->savedPrefix)) + motorGroup);
595 Logger::error("Cannot create the Motor from group " + *(exp->savedPrefix) + motorGroup + ". Aborting");
606 // if the user manually set the name and create a name clash, it is only reported as error in Logger
608 Logger::error( "More than one motor has name "+motor->name()+" !! The name has to be unique !!" );
617 exp->declareResource( resourcePrefix+"neuronsIterator", neuronsIterator, resourcePrefix+"evonet" );
645 robot = exp->savedConfigurationParameters->getObjectFromGroup<Robot>((*(exp->savedPrefix)) + "ROBOT");
659 if ( exp->savedConfigurationParameters->getValue( (*(exp->savedPrefix))+"NET/netFile" ).isEmpty() ) {
670 exp->savedConfigurationParameters->createParameter( (*(exp->savedPrefix))+"NET", "nSensors", QString::number(nSensors) );
671 exp->savedConfigurationParameters->createParameter( (*(exp->savedPrefix))+"NET", "nMotors", QString::number(nMotors) );
673 // Now creating the neural network. We first set ourself as the resouce manager, then we lock resources (because during configuration
674 // evonet could use resources, but the resource user it will use is not thread safe (SimpleResourceUser))
677 evonet = exp->savedConfigurationParameters->getObjectFromGroup<Evonet>( (*(exp->savedPrefix))+"NET" );
680 exp->declareResource( resourcePrefix+"evonet", static_cast<farsa::ParameterSettable*>(evonet) );
689 neuronsIterator->defineBlock( sensor->name(), EvonetIterator::InputLayer, startIndex, sensor->size() );