imit_model / AnyLogic / UsersManual(AnyLogic)
.pdf
AnyLogic V User’s Manual
1.The destruction starts with the call to the method cleanup(). By the time cleanup() is called, all elements of the structure diagram still exist. You can
override the method cleanup() to do some custom cleanup. The method cleanup() can be defined in the Additional class code code section of the active object class.
2.The method destroy() is called. The user cannot insert the custom code into the method destroy(). AnyLogic places there the code destroying all elements of the structure diagram.
3.Finally, the method onDestroy() is called. The user can override the method onDestroy() to do some additional necessary work. Usually in onDestroy() you manually destroy encapsulated objects which were created manually. By the time this method is called, all elements of the structure diagram are already destroyed. You can define the method onDestroy() in the Additional class code code section of the active object class.
15.2Dynamically changing connections
You can model systems with dynamically evolving component interconnection by changing interface elements connections at runtime. See section 4.3.2.2, “Connecting variables at runtime” and section 7.4.12, “Connecting ports at runtime” for more details.
© 1992-2004 XJ Technologies http://www.xjtek.com |
357 |
Chapter 16. Optimization
16. Optimization
If you need to run a simulation and observe system behavior under certain conditions, as well as improve system performance, for example, by making decisions about system parameters and/or structure, you can use the optimization capability of AnyLogic. Optimization is the process of finding the optimal combination of conditions resulting in the best possible solution. Optimization can help you find, for example, the optimal performance of a server or the best method for processing bills.
AnyLogic optimization is built on top of the OptQuest Optimization Engine1, one of the most flexible and user-friendly optimization tools on the market. The OptQuest Engine automatically finds the best parameters of a model, with respect to certain constraints. AnyLogic provides a convenient graphical user interface to set up and control the optimization.
The optimization process consists of repetitive simulations of a model with different parameters. Using sophisticated algorithms, the OptQuest Engine varies controllable parameters from simulation to simulation to find the optimal parameters for solving a problem.
►To optimize your model
1.Specify the function to be minimized or maximized, parameters to be varied, and constraints to be met. See section 16.1, “Setting up an optimization”.
2.Optionally, adjust the OptQuest Engine settings for your problem. See section 16.3, “Optimization settings”.
3.Run the optimization. See section 16.4, “Running the optimization”.
1 OptQuest is a registered trademark of OptTek Systems, Inc. For advanced information about the OptQuest Engine, please visit OptTek’s web site www.opttek.com.
358 |
© 1992-2004 XJ Technologies http://www.xjtek.com |
AnyLogic V User’s Manual
16.1 Setting up an optimization
You set up an optimization with these five steps:
1.Create an optimization experiment
2.Define the objective
3.Define optimization parameters
4.Define constraints (optional)
5.Specify the simulation stop condition
6.Specify the optimization stop condition
16.1.1Creating an optimization experiment
►To create an optimization experiment
1.Click the New Experiment
toolbar button, or
Choose Insert|New Experiment… from the main menu, or
In the Project window, right-click the Experiments item and choose New Experiment… from the popup menu.
The Create a new experiment dialog box is displayed.
2.Select the Optimization experiment option.
3.Type the experiment name in the Name edit box.
4.Choose the root object of the experiment from the Root object drop-down list.
5.Click OK.
You need to set the created optimization experiment as a current experiment.
© 1992-2004 XJ Technologies http://www.xjtek.com |
359 |
AnyLogic V User’s Manual
Properties
Name – the name of the experiment.
Root object – the root object of the experiment.
Optimization method – the optimization method used. OptQuest method is set by default.
Settings – the button opens the OptQuest settings dialog box. See section 16.3, “Optimization settings” for the details on changing optimization settings.
Objective function – the objective function. See section 16.1.2, “Defining the objective” to know how to define an objective.
Minimize|Maximize – the optimization criterion. Determines whether the objective function should be minimized or maximized.
Parameters – the set of optimization parameters. See section 16.1.3, “Defining optimization parameters” to know how to define parameters.
Constraints – [optimal] the set of constraints. Constraints are checked at the end of each simulation, and if they are not met, the parameters used are rejected. Otherwise the parameters are accepted. See section 16.2, “Constraints” for details.
16.1.2Defining the objective
The goal of the optimization process is to find the parameter values that result in a maximum or minimum of a function called the objective function. Objective function is a mathematical expression describing a relationship of the optimization parameters or the result of an operation (such as simulation) that uses the optimization parameters as inputs. The optimization objective is the objective function plus optimization criterion. The latter determines whether the goal of the optimization is to minimize or maximize the value of the objective function.
►To define the objective
1.In the Project window, click the optimization experiment.
2.In the Properties window, specify the objective function in the Objective edit box. Choose one of the variables of the root active object from the drop-down list, or enter a custom expression.
© 1992-2004 XJ Technologies http://www.xjtek.com |
361 |
AnyLogic V User’s Manual
during simulation. A parameter is normally a constant in a single simulation, and is something that influences the behavior of the model.
In order to perform optimization, you must have at least one parameter in the root active object class.
16.1.3.1 Optimization parameter types
During the optimization process, the parameter's value is changed in accordance to its type within an interval, specified by lower and upper bounds. There are the following types of optimization parameters:
•Continuous parameter
•Discrete parameter
•Design parameter
Continuous parameter can take any value from the interval. The parameter precision determines the minimal value continuous parameters can change.
Discrete parameter is represented by a finite set of decisions with essential direction: the parameter influences the objective like a numeric parameter, but can take values from the specified set only. It begins at a lower bound and increments by a step size up to an upper bound. For example, a discrete parameter with 1.0 step represents a set of integer values.
Sometimes the range and step are exactly defined by the problem; but generally you will have to choose them. If you specify the step for the parameter, only the discrete points will be involved in the optimization, so it will be impossible to determine optimal parameter value more precisely than defined by the step. So, if you are not sure what the step should be, choose the Continuous rather than the Discrete parameter type.
Design parameter is represented by a finite set of decisions, where there is no clear sense of direction. Value of design parameter represents an alternative but not a quantity. It begins at a lower bound and increments by a step size up to an upper bound. Values order is inconsequentional. Using design parameters you can model choosing the best alternative from the catalog, where the choices are not in a specific order. For example, a design
© 1992-2004 XJ Technologies http://www.xjtek.com |
363 |
AnyLogic V User’s Manual
16.2 Constraints
AnyLogic supports constraints - additional restrictions imposed on the solution found by the optimization engine.
16.2.1Defining a constraint
In AnyLogic, a constraint is a range specified for a model variable. This means that if all variables meet their constraints at the end of the simulation, the corresponding set of parameter values is considered feasible, and the result of the simulation is accepted by the optimization engine. Otherwise, parameter values are considered infeasible, and the result is rejected.
A constraint is a well-formed arithmetic expression describing a relationship between the optimization parameters. It always defines a limitation by specifying a lower bound and/or an upper bound.
VarA + VarB + 2*VarC = 10
VarC - VarA*VarB >= 300
It can also be a restriction on a response that requires its value to fall within a specified range. Constraint may contain any variables of the active object, the model time symbol t, any arithmetic operations and method calls, such as, e.g., sin(), cos(), sqrt(), etc., or calls to your own methods.
0 <= 2*VarB – dataset1.max() <= 500
sqrt(VarC)>=49
►To define a constraint
1.Click the optimization experiment in the Project window.
2.Go to the last row in the Constraints table.
3.Double-click the Constraint field. Specify the constraint expression. The constraint is defined as a string.
© 1992-2004 XJ Technologies http://www.xjtek.com |
365 |
