6.7 Example Optimisation Task
Along with the different Optimisation algorithms there are a number of different tasks which you can optimise for. For example if you just want to optimise for GETUP
you would use a different task than that used to optimise KICK
distance. Once again we have defined a few different example optimisation tasks which are implemented in optimizationbehaviors.cc
and optimizationbehaviors.h
. Remember this is c++ so the prototype needs to be declared in the header file. One such example is OptimizationBehaviorWalkForward
defined as follows:
class OptimizationBehaviorWalkForward : public NaoBehavior {
const string outputFile;
int run;
double startTime;
bool beamChecked;
double INIT_WAIT;
double totalWalkDist;
void init();
bool checkBeam();
public:
OptimizationBehaviorWalkForward(const std::string teamName, int uNum, const map<string, string>& namedParams_, const string& rsg_, const string& outputFile_);
virtual void beam( double& beamX, double& beamY, double& beamAngle );
virtual SkillType selectSkill();
virtual void updateFitness();
};
The goal of this task was to optimise for straight line walking speed. The agent would be placed in the middle of the field and have a certain amount of time to walk towards the goal. The fitness of the agent was measured as the total distance walked over that period, this value would be return at the end of the alotted time.
The structure of all of these tasks are the same as they include:
- private variables to keep track of important information during the running of a task and in the case of
OptimizationBehaviorWalkForward
we keep track of
const string outputFile;
int run;
double startTime; //The starting time of the particular run
bool beamChecked;
double INIT_WAIT;
double totalWalkDist; //The total distance walked so far during the run
- beam function
virtual void beam( double& beamX, double& beamY, double& beamAngle );
This function is used to define the initial placement position of an agent
- selectSkill
virtual SkillType selectSkill();
This function is used to define what the agent should do during the task. In this case since it was to walk to the opponents goal it would return goToTarget(VecPosition(HALF_FIELD_X, 0, 0));
4 updateFitness
virtual void updateFitness();
This function basically works like a reward function in reinforcement learning and is used to specify the fitness of the agent during a run. For the example of OptimizationBehaviorWalkForward
it was used to define a value for totalwalkDist
.