Changes between Version 2 and Version 3 of Documentation/DevelopmentCenter/IntegrateHeuristicLab
- Timestamp:
- 06/15/12 22:19:17 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Documentation/DevelopmentCenter/IntegrateHeuristicLab
v2 v3 4 4 Attached to this page you can find a zip file containing the sample HeuristicLab file, the needed assemblies as well as a Visual Studio project with the source code. 5 5 6 We will start out by creating a new Visual Studio C# console application. Because we want to read in a user-defined algorithm based on a G Acontaining a Traveling Salesman Problem, we first need to reference the following assemblies:6 We will start out by creating a new Visual Studio C# console application. Because we want to read in a user-defined algorithm based on a Genetic Algorithm containing a Traveling Salesman Problem, we first need to reference the following assemblies: 7 7 8 8 [[Image(assemblies.png)]] … … 47 47 }}} 48 48 49 The LoadingCompleted method gets an object of type IStorableContent. This is the object which the ContentManager loaded from the HeuristicLab file. In this simple example we only support user-defined algorithms and the TSP. Therefore we cast the algorithmto a user-defined algorithm and the problem to the TSP. In the next step we can then set the parameters of the problem and the algorithm. After parameterizing the algorithm we have to register event handlers for the algorithm so that we receive status updates during execution. The Parameterize* methods set parameters of the algorithm and the problem:49 The LoadingCompleted method gets an object of type IStorableContent. This is the object which the ContentManager loaded from the HeuristicLab file. In this simple example we only support user-defined algorithms and the TSP. Therefore we cast the content to a user-defined algorithm and the problem to the TSP. In the next step we can then set the parameters of the problem and the algorithm. After parameterizing the algorithm we have to register event handlers for the algorithm so that we receive status updates during execution. The Parameterize* methods set parameters of the algorithm and the problem: 50 50 51 51 {{{#!csharp … … 62 62 63 63 Algorithm parameters can be accessed through the parameters collection. In the code above the maximum generations is set from 1000 generations to 5000 generations. 64 The problem has various properties that can be set, like in the above code we define that the problem is a minimization problem. Another example would be to set the problem data using the coordinates or distance matrix properties.64 The problem offers some properties that can be changed. For example it is shown how to configure the problem to be a minimization or a maximization problem. Another example would be to set the problem data using the coordinates or distance matrix properties. 65 65 66 RegisterAlgorithmEventHandlers registers for some events so that the application canprint the execution time and state changes of the algorithm during execution.66 RegisterAlgorithmEventHandlers registers some events so that the application is able to print the execution time and state changes of the algorithm during execution. 67 67 68 68 {{{#!csharp … … 104 104 }}} 105 105 106 And that's all! You have now a HeuristicLab console client for a specific algorithm and problem. If you want to use different algorithms and problems, you have to reference the required assemblies and can then parameterize and execute these algorithms.106 And that's all! You have now created a HeuristicLab console client for a specific algorithm and problem. If you want to use different algorithms and problems, you have to reference the required assemblies and can then parameterize and execute these algorithms.