/// <summary> /// Constructs the behavior vector at the end of an individual evaluation. /// </summary> List<double> IBehaviorCharacterization.calculate(SimulatorExperiment exp, instance_pack ip) { // initialize the BC vector BehaviorVector = new List<double>(); // If the robot never Stopped, set the max evaluation time as the end tick if (endTick == 0) endTick = exp.evaluationTime; // Adjust end tick by the fraction we are sampling endTick = (int)(endTick * 0.5); // Calculate when to perform an update int numBehaviorChunks = VectorLength / 2; chunkSize = Convert.ToInt32(Math.Floor((double)endTick / (double)numBehaviorChunks)) * 2; float x, y; for (int chunkNum = 1; chunkNum < numBehaviorChunks + 1; chunkNum++) { // Take bc samples from the internal Trajectory store x = Trajectory[chunkNum * chunkSize - 2]; x = (x - ip.env.AOIRectangle.Left) / ip.env.AOIRectangle.Width; BehaviorVector.Add(x); y = Trajectory[chunkNum * chunkSize - 1]; y = (y - ip.env.AOIRectangle.Top) / ip.env.AOIRectangle.Height; BehaviorVector.Add(y); } return BehaviorVector; }
/// <summary> /// Constructs the behavior vector at the end of an individual evaluation. /// </summary> List <double> IBehaviorCharacterization.calculate(SimulatorExperiment exp, instance_pack ip) { // initialize the BC vector BehaviorVector = new List <double>(); // If the robot never Stopped, set the max evaluation time as the end tick if (endTick == 0) { endTick = exp.evaluationTime; } // Adjust end tick by the fraction we are sampling endTick = (int)(endTick * 0.5); // Calculate when to perform an update int numBehaviorChunks = VectorLength / 2; chunkSize = Convert.ToInt32(Math.Floor((double)endTick / (double)numBehaviorChunks)) * 2; float x, y; for (int chunkNum = 1; chunkNum < numBehaviorChunks + 1; chunkNum++) { // Take bc samples from the internal Trajectory store x = Trajectory[chunkNum * chunkSize - 2]; x = (x - ip.env.AOIRectangle.Left) / ip.env.AOIRectangle.Width; BehaviorVector.Add(x); y = Trajectory[chunkNum * chunkSize - 1]; y = (y - ip.env.AOIRectangle.Top) / ip.env.AOIRectangle.Height; BehaviorVector.Add(y); } return(BehaviorVector); }
/// <summary> /// Records the individual's location at each tick of the simulation. /// </summary> void IBehaviorCharacterization.update(SimulatorExperiment exp, instance_pack ip) { if (ip.robots[0].Stopped) { // If this is the first update after the robot has Stopped, // send the endpoint to be the current simulation tick if (endTick == 0) { endTick = Convert.ToInt32(ip.timeSteps * exp.timestep); } } // initialize the Trajectory list if (!Initialized) { // initialize the sensor value sampling/storage components Trajectory = new List <int>(exp.evaluationTime * 2); Initialized = true; } // update the Trajectory at every tick Trajectory.Add(Convert.ToInt16(ip.robots[0].Location.X)); Trajectory.Add(Convert.ToInt16(ip.robots[0].Location.Y)); }
/// <summary> /// Records the individual's location at each tick of the simulation. /// </summary> void IBehaviorCharacterization.update(SimulatorExperiment exp, instance_pack ip) { if (ip.robots[0].Stopped) { // If this is the first update after the robot has Stopped, // send the endpoint to be the current simulation tick if (endTick == 0) endTick = Convert.ToInt32(ip.timeSteps * exp.timestep); } // initialize the Trajectory list if (!Initialized) { // initialize the sensor value sampling/storage components Trajectory = new List<int>(exp.evaluationTime * 2); Initialized = true; } // update the Trajectory at every tick Trajectory.Add(Convert.ToInt16(ip.robots[0].Location.X)); Trajectory.Add(Convert.ToInt16(ip.robots[0].Location.Y)); }