| 239 | |
| 240 | ==== Configuring the Evaluator ==== |
| 241 | |
| 242 | The evaluator in our case is an external application, the TORCS simulator. The Evaluator in the External Evaluation Problem is the operator that performs the task of collecting the solution variables, including them in a message and sending that message via the Client to the external process. If we click on the Evaluator we see a similar view to the !SolutionCreator. However the Operators tab in the !SolutionCreator is now named "Collected Values". First lets examine the Parameters tab which lists the parameters of this Evaluator. We can see that there are four parameters: Client, !MessageBuilder, Quality, and Successor. The Client again is a !ValueLookupParameter and its //Actual Name// is the same as the actual name of the !ValueParameter that is defined under the problem parameters. The !MessageBuilder is more interesting for us. |
| 243 | |
| 244 | [[Image(Tutorial_MessageBuilder.png)]] |
| 245 | |
| 246 | As you can see there are a number of different converters. These are used to transform the value found in the scope to a variable of a !SolutionMessage. This message is in turn sent to the external process, so here we can influence how our solution objects are represented in the solution message. When you define a new !ExternalEvaluationValuesCollector these are the default converters that are preselected. They will transform any type that is available in !HeuristicLab.Data and also derived types. Our representation is a !RealVector object which lives in the !HeuristicLab.Encodings.RealVectorEncoding namespace. Let's take a look at the class definition of RealVector: |
| 247 | {{{#!C |
| 248 | public class RealVector : DoubleArray |
| 249 | }}} |
| 250 | We see that it derives from `DoubleArray` and if we look at the definition of `DoubleArray` we see that it derives from `ValueTypeArray<double>`. When you now however over the !DoubleConverter to get the tooltip you can see that it indeeds converts a `ValueTypeArray<double>` among others and thus also our derived `RealVector`. We can uncheck or remove the others, but there is no harm in leaving them. |
| 251 | |
| 252 | For writing your own solution representation you can also write an own encoder. All you have to do is implement `IItemToSolutionMessage`, add your code as HeuristicLab plugin and you can add your converter using the yellow plus button. Note that if you have several converters for a given type, the last added converter will be used for that type. |
| 253 | |
| 254 | So in our case there exists a converter which will convert the !RealVector into a !DoubleArrayVariable and add it to the !SolutionMessage's !DoubleArrayVars. |
| 255 | |
| 256 | The last parameter we're going to look at is called "Quality" and denotes the variable that houses the fitness value. Let's leave its //Actual Name// as it is. And let's go back to the "Collected Values" tab instead. |
| 257 | |
| 258 | [[Image(Tutorial_ConfigureExternalEvaluator.png)]] |
| 259 | |
| 260 | As you may have guessed the next thing we're going to do is to tell the !ExternalEvaluationValuesCollector which variables that it should hand to the converters to include in the solution message. Of course we want to send the !RealVector, so we're going to add a parameter where to find that vector. You probably now know already how this works, basically it should look like in the following screenshot. This time we use a simple !LookupParameter because this parameter always should be looked up. |
| 261 | |
| 262 | [[Image(Tutorial_ConfigureExternalEvaluator2.png)]] |
| 263 | |
| 264 | If we now switch back to the Parameters tab, we can also see that there is a RealVector parameter there. All parameters that we add to the "Collected Values" appear also under Parameters. |
| 265 | |
| 266 | Next in the configuration of the problem and right below the Evaluator we can see another parameter called '''Maximization'''. This tells the algorithm wether it should attempt to increase the quality value (if Maximization = true) or decrease it otherwise. From the possible fitness values we obtain from the simulator there's top speed and distance which we likely want to increase and damage which we want to decrease. Overall, because the !ExternalEvaluationProblem is a single objective problem we have to calculate a single fitness value and it's likely that we want to maximize distance, so we set this to true here. |
| 267 | |
| 268 | [[Image(Tutorial_Maximization.png)]] |