Upcoming SlideShare
×

# AnyLogic - Free AnyLogic basic lessions - Learning AnyLogic by examples - Demo function

2,833 views

Published on

Free AnyLogic basic lessions - Learning AnyLogic by examples is made by Khoi Tran.

In this example you can learn, how to create functions in AnyLogic

Published in: Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
2,833
On SlideShare
0
From Embeds
0
Number of Embeds
194
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### AnyLogic - Free AnyLogic basic lessions - Learning AnyLogic by examples - Demo function

1. 1. How to create functions Become an AnyLogic Expert Step by Step
2. 2. About me khoi.tran@simbean.com 2 My name is Khoi Tran and I’m living in beautiful Stuttgart, Germany. As a 12-years expert in the software industry and 6-years expert in simulation with AnyLogic, I would like to share my experiences with you on a simple and fast path.
3. 3. Learning subjects khoi.tran@simbean.com 3 In this example you can learn, • How to create function • Without arguments • With arguments • How to create table function You can see the demo in action first http://simbean.com/en/knowhow/become-an-anylogic-expert.html If you like to know, how I built this model, this presentation may help you.
4. 4. Create plain variables khoi.tran@simbean.com 4 a and b are summands with a = 3 and b = 5 a and b are summands with a = 3 and b = 5 Simple function “sum = a + b“ is defined next
5. 5. Create a function and specify it khoi.tran@simbean.com 5 The return type of the function “calculate“ must be double Specify the function code
6. 6. Create an event for a function call khoi.tran@simbean.com 6 After 2 seconds the function call is executed and its result is assigned to the plain variable ”sum” Set properties for the event You can create a function call like this line of code e.g. in and event’s action or at another places for inserting code in the model.
7. 7. Create a function with argument input khoi.tran@simbean.com 7 Similar to the first function, there are two summand arguments defined for this function In the property “Code“ the result of the calculation for two summand arguments is returned
8. 8. Set properties for event khoi.tran@simbean.com 8 The method call must have arguments . Here they are two simple double values. Plain variables are possible for these arguments , too. E.g. Sum1 = calculateWithParameter( a, b);
9. 9. Create a table function khoi.tran@simbean.com 9 Interpolation type Argument-value-list defines the function as the figure If the value is not in the range, the function returns an error Argument-value-list defines the function as the figure
10. 10. Table function definitions khoi.tran@simbean.com 10 There is no interpolation, the function is explixitely defined only for these input argument values on the list Figure of step interpolation Figure of the step interpolation
11. 11. Table function definitions khoi.tran@simbean.com 11 “Out of range“ can be also defined with a custom value “Out of range“ can be also defined with a custom value. The function always returns a valid value, not an error anymore “Out of range“ is defined with “nearest“ and the figure is redrawn “Out of range“ is defined with “nearest“ and the figure is redrawn
12. 12. Table function call khoi.tran@simbean.com 12 Table function call
13. 13. Run the model khoi.tran@simbean.com Click on the run button and choose the simulation 13 1. You can run the model and see the result 2. Try to change or set properties to see some small effects e.g. 1. Test the functions with different values 2. Also with some out-of-range-values 3. You need to restart the model to see the effects
14. 14. The result khoi.tran@simbean.com 14 The result of function calculate is saved in the plain variable “sum“ The similar for the table function
15. 15. Thank You khoi.tran@simbean.com 15 IF YOU HAVE ANY QUESTION, IDEA, FEEDBACK or FIND ANY MISTAKE, PLEASE SEND ME an EMAIL khoi.tran@simbean.com BECAUSE I WOULD LIKE to IMPROVE this SLIDE CONTINUOUSLY. I APPRECIATE a lot YOUR TIME.