Changes between Version 2 and Version 3 of Documentation/Howto/OptimizeAnyLogicModels
- Timestamp:
- 04/26/11 22:17:41 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Documentation/Howto/OptimizeAnyLogicModels
v2 v3 25 25 Next we need to go to the "Advanced" section of the properties and configure the experiment loop: perform the parameter retrieval, run the simulation, send the quality back, reset the model and continue with another attempt of retrieving parameters. 26 26 27 In the "Imports:" section enter following code: 27 The following code samples need to be entered into the respective boxes. 28 29 ==== Imports ==== 28 30 {{{ 29 31 #!java … … 34 36 }}} 35 37 36 In the "Additional class code:" section enter following code: 38 ==== Additional class code ==== 37 39 {{{ 38 40 #!java … … 69 71 We have defined a method //getMessage()// that calls our library to get the next message from !HeuristicLab and extract the parameters. You'll notice that here I have put the same text as before in the box "Expression" which is an intentional coincidence ;-) 70 72 71 Now in the section "Initial experiment setup" we need to initialize our communication driver. Paste the following code: 73 ==== Initial experiment setup ==== 72 74 {{{ 73 75 #!java … … 78 80 The number '''2112''' is important as it is the TCP port that our service will be listening on. This must be reachable by !HeuristicLab through a network connection (yes this means you can run !HeuristicLab on a different computer than your simulation model). You can of course choose another port (basically any number from 1 to 65535, but some numbers like 80 might be used by another application already). 79 81 80 In the next section "Before each experiment run" we need to initialize our variables that store the quality and replications and we need to fetch the new parameters. Past the following code: 82 ==== Before each experiment run ==== 81 83 {{{ 82 84 #!java … … 89 91 The call to //getMessage()// will block, that means the simulation will wait here, until we have received a new set of parameters. 90 92 91 We can leave the next section "Before simulation run" empty, but in the section after that, called "After simulation run" we need to paste following code: 93 ==== Before simulation run ==== 94 leave this empty 95 96 ==== After simulation run ==== 92 97 {{{ 93 98 #!java … … 100 105 This calls the cost function in the `Main` object called //meanDailyCost()// in this case. This is the target that we want to optimize (note that we add an increasing penalty term if the customer waiting time is above a certain level). 101 106 102 Finally in the section "After iteration" we calculate the mean cost among all iterations performed and send that back to !HeuristicLab: 107 ==== After iteration ==== 103 108 {{{ 104 109 #!java … … 108 113 }}} 109 114 110 We are done here. Save the model. You can now start the !HeuristicLabOptimizationExperiement, although of course it won't do anything but block until it receives parameters.115 This sends the mean quality of the (possible) replications back to !HeuristicLab. We are done here. Save the model. You can now start the !HeuristicLabOptimizationExperiement, although of course it won't do anything but block until it receives parameters. 111 116 112 117 == Preparing the Optimization Problem in !HeuristicLab 3.3 ==