Home
English Edition
Contents
1. Agt_Init Replace Agt_Init 3 Agt_Step Agt_Init and Agt_Step are already written Agt_Init is an initial rule which is only executed once when the agent is first created in the simulation Agt_Step is an execution rule which is executed at every step while running the simulation Curly braces indicate the beginning and end of the rules with the required declarations written between them Agt_Step is an execution rule which is executed at every step during the simulation Agt_Init is an initial rule which is only executed once when the agent is first created 1 3 7 Writing Our First Rule Let s try writing our first rule in Agt Step Forward X is a function which moves the agent in the direction of the X axis by the amount specified in the argument Prog02 model Turtle agent rules Agt Step 16 artisoc User Manual Forwardx 1 Step artisoc simulations are run in units of time called steps artisoc executes the Agt_Step execution rules of every agent included under Universe in random order and when these end the step count is increased by one 1 3 8 Running a Simulation Bullet Turtle When you finish writing the rule try clicking the Start button in the Run Panel If an error occurs find and correct errors in the highlighted line If the simulation runs properly the value of the X coordinate of the agent increases by one at ever
2. minutes Stop conditions Wait for l milliseconds Initial seed value of random number Display at every steps 2 agent rule execution GC interval Run for steps Specifies the number of steps for which artisoc runs before it stops the simulation You can stop the simulation by clicking the Stop button in the Run Panel before the number of executed steps reaches this value Run for minutes Specifies the number of minutes for which artisoc runs before it stops the simulation You can stop the simulation by clicking the Stop button in the Run Panel before the amount of time reaches this value Stop conditions Specifies the conditions that artisoc stops the simulation You can stop the simulation by clicking the Stop button in the Run Panel before this conditions are satisfied artisoc User Manual Wait for milliseconds When a step has ended processing stops and waits for the amount of time specified by this value Enter a suitable value here if for example the simulation speed is too fast on a high performance machine Initial seed value of random number Specifies the seed value in order to generate the fixed sequence of random numbers Display at every Specifies the timing of the output to the screen If Steps is selected the screen will be redrawn at every specified steps If Agent Rule Execution is selected the screen will be redrawn every time an agent executes rules GC int
3. 2 7 Console Screen By placing Print or PrintLn functions within a rule you can output values to the console screen The difference between Print and PrintLn lies in whether or not a linefeed is sent Format PrintLn lt argument gt 6699 Tf the argument is a string place it inside Example Agt Init Dim X as Integer X 0 PrintLn value amp X X Xt 1 PrintLn plus 1 amp X 78 artisoc User Manual 2 8 Debugging Console value plus 1 1 Debugging capabilities are used to find errors in your agent rules or display the assigned variables In the debug mode also you can execute your rules line by line 2 8 1 Debug Mode To enter the debug mode select Debug gt Run Debugger The artisoc window will change as follows New File artisoc FiletF Edit E View Insert Settings S Debug D RuntR Logi Window Help H Universe W W Space pac 2 nae So The Debug Panel is used to debug New File artisoc Eilet EdittE Wiew DA Inserh SetingsiSiy Deb lt 2 EDR Eak artisoc User Manual 79 The following screenshot is the Replay Panel floated by dragging the shaded region ule Is used to debug next line Using this button you can debug each line within functions E Step over Is used to debug next line however lines within functions are executed without stopping M Pause
4. You have now created a two dimensional space for a grid model in Universe Verify that Spacel has appeared under Universe in the tree HI r4 Ib artisoc Prt RRO ATM BAD REQ TivFD STR AFH Dry ED avs g Universe 1 3 3 Adding a Component Agent Select and right click Space1 in the tree and select Add Agent from the menu Agent artisoc User Manual 11 Properties dialog is displayed Input Turtle for the Agent Name and 1 for the Agent Count as the following screenshot When you have finished with these settings click OK to close the dialog We have now successfully created a turtle agent directly under the space Agent Properties Agent name Turtle Agent count If you click on the of the Turtle you can see the variables which have been automatically included in that agent New File artisoc File F Edit E View t Inserti Settings S Debug D RunfR Logi Window HelpfH Space Turtle ID Direction X and Y indicate the agents location coordinates in a two dimensional space in which 0 0 is taken to be the upper left hand corner Layer indicates the agents layer in the space Direction indicates the direction of the agents in frequency in radians 360 12 artisoc User Manual 1 3 4 Adding Outputs Component Placement and Settings M Outputs Settings Vv Agent Rule Declarations v Run and Debug You have now succe
5. e Drop Down List Select this when you want to choice from drop down list Delimt list item by the comma artisoc User Manual 2 3 Run Panel Run Panel is used to start simulation run only one step pause simulation and stop simulation by clicking a button Mew File artisoc wiew Inser gt Start Starts the simulation co Single step Runs the simulation by one step and then pauses the simulation each time it is clicked m panse Pauses the simulation E Stops the simulation The simulation will also stop if the ESC key is pressed 2 4 Replaying a Simulation When you want to display a simulation for a presentation replaying a simulation which has already been ran will enable drawing on the screen proceed more smoothly than running the simulation right then and there In addition the state at a specific step can be 74 artisoc User Manual displayed and reverse replay can be performed In order to use these capabilities you must run and record the simulation in advance 2 4 1 Saving a Log When you select Run gt Run and Save Simulation the Simulation Memo dialog appears Simulation Memo Enter simulation memo log When you enter a memo to identify the simulation to be replayed and click OK the simulation runs and is saved to a file When you click the Stop button in the Run Panel the simulation will end and the saving of the simulation will be concluded 2 4 2 Log
6. is declared line 6 the results of the calculation of b c in this rule 5 3 is artisoc User Manual 77 assigned to answer1 line 7 and then the value of answer is returned to the location of the function call in Agt Step line 8 In other words in this rule the following 1s described Assign the answer to the calculation 5 3 to the variable a However if it is not necessary to assign the calculation result to the variable a then there will be no need for the user defined function to return a value in which case you should use Sub rather than Function 3 4 Naming Conventions The following rules must be followed for variable names and function names within agent rules e The first character of a name must be an English letter or _ underscore e Fach character starting from the second character must be an English letter a number or underscore e Names must be 256 characters or less e Reserved words see Section 3 8 must not be used as names Note No distinction is made between upper and lower case letters Examples The following names are all treated identically SUM Sum sum Examples of valid names Sum sum x sum100 Examples of invalid names e 1x A number is used as the first character e x Special characters is used as the second character e next This is one of the reserved words 3 5 Variable Declaration Section In the variable dec
7. A rule is a collection of functions Agt_Init lt local declaration section gt lt execution section gt Agt_step lt local declaration section gt lt execution section gt lt user defined function gt Note User defined functions are not necessarily required For Universe rather than Agt Init and Agt Step Univ Init Univ Step Begin Univ Step End and Univ Finish are used 3 2 Special Functions Agt Init This function is executed just once when the simulation starts and agents are created The name Agt Init has a special significance and is a reserved word which cannot be used for any other purpose It is expressed in the following format Agt_Init lt variable declarations section gt lt execution section gt Agt _ Step This function is executed at every step until the simulation ends The name Agt Step has a special significance and is a reserved word which cannot be used for any other purpose It is expressed in the following format 74 artisoc User Manual Agt_Step lt variable declarations section gt lt execution section gt Univ_Init This function is used in rules for Universe and is executed just once at the beginning of the simulation The name Univ Init has a special significance and is a reserved word which cannot be used for any other purpose It is expressed in the following format Univ_Init lt variable declarations section gt lt executi
8. Check if the respective properties are set properly Countermeasure 2 There is more than one way to set the initial value of components as follows e In Initial Values of Variables dialog the values of individual components are set separately e Values can also be assigned using assignment statements in component rules If you use both of the above methods of specifying initial values the settings will be prioritized in the following order component rules Initial Values of Variables dialog Try checking if a setting is being overwritten somewhere artisoc User Manual 23 1 4 Summary of Section 1 1 1 3 In this section let s review the things you have learned through Section 1 1 1 3 1 4 1 Terminology and Methodology z Component tree Universe Run Panel Space Agent Variable Adding a space under Universe Adding an agent Setting outputs Opening the Rule Editor Two types of rules Agt_Init and Agt_Step my to indicate a component itself Conditional branching declarations If Then End If Adding an variable to the agent Creating multiple agents Giving initial values to variables EE Fa Oa ll e a Pa Debugging 1 4 2 Checklist 24 C Were you able to understand the basic component elements in the artisoc programming environment Q Were you able to grasp the basic flow for artisoc programming Component Placement and Settings v Outputs Settings v Agent Rule Declaration
9. Pauses the simulation running Continue Runs the simulation until the next breakpoint is encountered a Exit debugger Exits the debug mode 2 8 2 Breakpoint 80 When you want to pause the simulation at a specific line in the rules you can use breakpoint Open the Rule Editor right click a target line to display the context menu and select Toggle Breakpoint artisoc User Manual mouth _com model artisoc FilecF Edit E View Inserti Settings S Debug D RunfR LogiL Window Help H jb IL ii gt n Find Replace Univ_Init Dim i As Integer Dim obj As Agt Dim myAqtSet As AqtSet For i 0 To Universe VYalkerCount 1 obj CreateAgt Universe TwoDimensionalSpace Walker Next i oDimensionalSpace vYalker False To cancel a breakpoint which has been defined right click the line and select Toggle Breakpoint again 2 9 Synchronized Remote Simulation You can run synchronously multiple artisoc models Select one of models to be synchronized as a server and define remote settings on it This server model will synchronize simulation step of every other model In each model to be synchronized by the server remote identification name must be defined using the RemoteName function in advance of running synchronized simulation 2 9 1 Remote Settings When you select Settings gt Remote Settings the following dialog appears artisoc User
10. Rule Editor for Universe in which rules for Universe are written and Rule Editor for agents in which rules for agents are written To open Rule Editor for agents select the agent and either select View gt Rule Editor or right click the agent and select Rule Editor A window such as the following will open artisoc User Manual Rule Editor Agent1 Agt_Init Agt Step 2 Write agent rules within this window e Between the and of Agt_Init write a rule which is to be executed once when the agents are created e Between the and of Agt_Step write a rule which is to be executed at every step in the simulation For Universe four types of special rules can be written e Between the and of Univ_Init write a rule which is to be executed once at the beginning when the simulation starts e Between the and of Univ_Step_Begin write a rule which is to be executed at the beginning of every step in the simulation e Between the and of Univ_Step_End write a rule which is to be executed at the end of every step in the simulation e Between the and of Univ_Finish write a rule which is to be executed once at the end when the simulation stops artisoc User Manual 41 Rule Editor Universe Univ_Init Univ Step Begin Univ Step _End Univ_Finish Note Traditionally multi agent simulators have a drawback that simulations cannot be constructed without first learning a
11. These dialogs set the initial value of each component Selecting a component in the tree and then selecting Settings gt Initial Values will open the initial values dialog for the component The dialog will vary depending on the type of component that was selected Initial Values Dialog for Agents and Variables If an agent or a variable is selected in the tree and then Settings gt Initial Values is selected the following dialog here Initial Values of Agents dialog is displayed In these dialogs the initial values of the agent or the variable at the beginning of the simulation can be set Initial Values of Agents x H Layer Direction variable 0 0 0 0 0 0 0 Set values individually F Agent1 X Inthe case that Agent number is 1 Set values individually If the number of agents has been set to more than one then if this item is checked the values of the individual agents can be set individually artisoc User Manual 47 2 2 2 48 Export Import If you click the Select File button you will be able to save initial value data to a file or load initial value data from an existing file Space Drawing Dialogs In the artisoc2 0 Agent Settings Network Settings and Variables Settings in a space will be simply run by using drawing dialogs Since a drawing dialogs perform set only however a screen output is different Select Space component in the tree Choose Select Settings gt Initial Values then
12. To lt final value gt Step lt step value gt 1 If omitted lt block gt 4 artisoc User Manual Next lt loop variable gt For example total 0 For i L To 1 Step 1 total total 1 Next i To perform the same operations on each agent in an agent set the following syntax can also be used For Each lt loop agent gt In lt agent set gt lt block gt Next lt loop agent gt For example For Each TmpAgt In TurtleSet TmpAgt X 25 0 Next TmpAgt 2 Do While This is used to repeat while the value of an expression is true Do While lt expression gt lt block gt Loop 3 Do Until This is used to repeat while the value of an expression is false 1 e until it becomes true Do Until lt expression gt lt block gt Loop 3 6 7 Jump Statements These statements are used to change the flow of control 1 Goto This is used to jump to the specified location Goto lt jump target label name gt lt jump target label name gt artisoc User Manual 85 For example Do While x gt 0 If err_flag True Then Goto error_handling Jump to specified label End If Loop error_handling 2 Break This is used to exit a loop For example e While loop Do While lt conditional expression gt Do While lt conditional expression gt If lt exit condition expression gt Then Break Exit one level End If Loop Loop e For loop For i 0 To 10 Step 1 For j 0 To 10 Step 1 If lt
13. b lt linear expression gt The following is a summary of the operators which can be used in expressions along with their order of precedence Order of Type Operator Meaning Precedence l Expression enclosed in Other 0 A 2 0 Function 2 Function call a 3 Power x 4 Minus sign x F 5 Multiplication x y Arithmetic operators rer oo 5 Real division result is real number x y used in arithmetic ares 6 Integer division result is integer x y expressions Mod 7 Remainder in integer division x Mod y a 8 Addition x y 8 Subtraction x y String concatenation String operators amp 9 g p a 99 amp cede abcde 10 Equal to note differs from lt gt 10 Not equal to same as Relational operators 10 Not equal to same as lt gt used in relational lt 10 Less than expressions lt 10 Less than or equal to gt 10 Greater than gt 10 Greater than or equal to Not 10 Negation Logical operators And 1 And used in logical Or 12 Or expressions Xor 13 Exclusive Or Assignment 14 Assignment assign result of expression operators lt variable specifier gt lt expression gt 3 6 4 Function Calls Syntactically function calls are linear expressions They are either used within arithmetic expressions relational expressions and logical expressions or u
14. Agent Number The cursor coordinates are shown in X and Y The total number of Point Agent and Link Agent are shown in the total number of Agent and Link Agent Undo Return to previous action Background image Display the background image in a screen Select the screen which you want to display in the background since the dialog to select files are appeared artisoc User Manual 51 52 Delete background image Delete background image Input file Load the Point Agent Link Agent Variable Data from file Only use the files which comply with the following format File Format example Point Point_Agt Type Name ID X Coordinates Y Coordinates Layer No Point Point_Agt Type Name ID X Coordinates Y Coordinates Layer No Variable Space Variable Name Space Width Space Height Layer Layer No Variable Value 1 1 Variable Value 1 2 Variable Value 1 x Variable Value y 1 Variable Value y 2 Variable Value y x Layer Layer No Variable Value 1 1 Variable Value 1 2 Variable Value 1 x Variable Value y 1 Variable Value y 2 Variable Value y x Link Link_Agt Type Name ID Begin Point_Agt Type Name ID of Begin Point_Agt End Point_Agt Type Name ID of End Point_Agt Link Link_Agt Type Name ID Begin_Agt Type Name ID of Begin Point_Agt End Point_Agt Type Name ID of End Point_Agt Point Agent Point_Agt Link Agent Ling_Agt Output File Output Point Agen
15. JA stieuny lt 9 Marker Link Agent Display Object if Line Type Arrow Type Color Setting Method Not Selected Point Only O Link Paint and Link Delete E oi fs y Riadia ZIEN A DN St Pompe a a inte tori Sy WA Si a HA i Lie Parn ons Clamps Fly in Arr SA kM b L ee RK i Undo Select Background Image Delete Background Image Input File Output File Total Agents 0 Total Link Agents 0 Cancel Tab Select Tab and replace an setting object The standard tab is Point Link tab Space Space name to run the Placement Available to replace the other space by artisoc User Manual 49 50 pull down Layer Space Layer Number to place Available to replace the other layer by pull down Transparent If this is checked placed agent is displayed at other Layer not current settings Layer Ruled lines If this is checked it is drawn in accordance with space cell ID If this is checked Agent ID is displayed Ratio If you move slide bar the ratio of display screen is changed Space Display Show the space for setting When you drag in the screen the screen display is transferred with mouth Point Agent Specify the type of Point Agent to arrange Marker in the display screen and color Link Agent Specify the type of Link Agent to use the Point Agent connection line type in the display scre
16. a Drawing Dialogs are displayed Preparation before starting You need to define a Point Agent in the tree if you arrange agent with Drawing Dialogs and to define a Link Agent in the tree if you connect to link Point Agent It s the agent which is placed inthe map All agents that are defined under the Space identify as Point Agent Link Agent Link Agent store the link information among point agent Create the Link Agent under the Universe and get two Agent Variables Begin_Agt and End_Agt When you run the connect set for Link Agent the Unique ID of Point Agent for begin and end point will be stored in the Agent Variable Since the Link Agent is available to add the variable except for Begin_Agt and End_Agt it may have the additional information such as road width and slop artisoc User Manual ig Direction 9 Link i iD i Begin Act i End Act Point Agent and Link Agent are voluntarily given Drawing Dialogs can t display if you don t define the Begin_Agt End Agt as Agent Valiables Point Agent Link Agent Settings Point Agent and Link Agent are placed by Point Link tab Space Map x Layer ly Origin Position Left Top M C Transparent Ruled Line JID 10 Q 1000 f F TAN 5 a gt So w zena a f Vite Pointand Link Variable tae ON J OF i lt 9 Me Gacne Commercals lt 3 Point Agent h z4 Unum du Pate gee a jdes Congr s Display Object Point M
17. are declared in the variable declarations section The call statement must be in the same agent rules You cannot call them from the agent rules of other agents User Defined Function Syntax Function lt function name gt lt parameter declarations gt As lt type of return value gt lt variable declarations section gt lt execution section gt Return lt expression gt Function Declares that a user defined function is defined thereafter lt function name gt Is the name of this user defined function You can enter an arbitrary name However reserved words previously declared variable names and name constants etc cannot be used because this will confuse the artiSoc lt parameter declarations gt If there are parameters to be passed to the function they are declared in the following format lt variable specifier 1 gt As lt variable type gt lt variable specifier n gt As lt variable type gt For example Function functionl a As Integer b As Integer c As Double As Integer As lt type of return value gt This is expressed when a function needs to return a value If it is omitted the function will not be able to return a value For the lt type of return value gt specify the type of the value which this function returns This is specified in the same manner as for 76 artisoc User Manual the variable type User Defined Sub Syntax Sub lt function name gt lt parameter declarations
18. can be called from within any function For details concerning built in functions see the help file help pdf 3 8 Reserved Words When creating agent rules reserved words cannot be used as variable names user defined function names etc The names of built in functions also cannot be used For details concerning built in functions see the help file help pdf 3 9 Comments Comments can be placed in agent rules Anything can be written in a comment because artiSOC ignores comment sections We recommend that you insert as many comments as possible because rule statements with no comments can become a confusing jumble which is hard for a human being to understand at a glance Comments make agent rules easier to understand when you or others revisit them later on Comments can be placed anywhere that blank space can be placed The following describes how to express comments artisoc User Manual 87 88 a The area from the until the end of the line will be treated as a comment For example sim r Tareas ze sum In this case the sum 0 portion is interpreted as a rule 2 The area from the until the end of the line will be treated as a comment For example Determine the direction and then move direction Rnd 360 8 a l The area from to is treated as a comment Comment area can span multiple lines For example J gt KKEKKKKKKKKKKKKKKKK KKK KKK KKK KK KKK KK KK KKKKKKKKKKK Tur
19. can be freely denominated but reserved words previously declared variable names and name definitions cannot be used Using these can cause confusion in artisoc so exercise care in this regard User defined function Function lt function name gt lt argument gt As lt argument type gt As lt return value type gt The correction rules will require a return value so we will use Function You can write this anywhere in the Rule Editor but you cannot put them into Agt_Init or Agt_Step So place the function after Agt_Step The rules in which the map end processing portion of the execution rule Agt_Step is removed are as follows Prog11 model Turtle agent rules Agt Init Agt Step If Int Rnd 5 0 Then My DIRX 1 Int Rnd 3 My DIRY 1 Int Rnd 3 End If My X FixX My X My DIRX My Y FLxy My My DIRY Function FixX 1X As Double as Double Dim LimX As Double LimX GetWidthSpace Universe Spacel If 1X gt LimX 1 Then 1X 1X LimX ElseIf iX lt 0 Then 1X 1X LimX End If Return 1X Function FixY iY As Double as Double Dim LimY As Double LimY GetHeightSpace Universe Spacel Le ay 2 tam en 1Y 1Y LimyY ElseIf iY lt Q Then artisoc User Manual 1 SY ae cm End If Return 1Y Select File gt Save As and save the model as prog11 model There are functions in Function FixX and Function FixY with which you are as yet
20. characteristic of variables which are handled in computers is that they always have a type Integer Double String etc and what type a variable is going to be must be declared prior to using it You must always use variables which are appropriate for the type of information stored in them You can define the variables in the agent rules refer to Chapter 3 however it is convenient to create the variables in the tree if you want to refer it many times By defining the variables in the tree you can refer it from any part of the rules In addition when you create the agent under space in the tree the variables ID X Y Laver Direction will be automatically generated 1 3 2 Adding a Component Space 10 Component Placement and Settings Vv Outputs Settings y Agent Rule Declarations y Run and Debug When you right click Universe in the component tree a menu will appear Select Add Space Space Properties dialog will appear Input Space1 for the Space Name select Grid Model for the Space Type input 50 for the Space Size X and Y input 1 for the Layer and select Don t Loop for the End of Space as the following screenshot When you have finished click OK to close the dialog artisoc User Manual Space Properties Space name Space Space type Grid model 7 Space dimensions Space Size H 50 Space size Y Layer End of space 2 Loop iconnect with opposite end Dontloop dead end
21. here ml number of array elements in 1 dimension 1 mn number of array elements in n dimension 1 There is no limit on the number of dimensions For example to declare a one dimensional array dx with 11 Integer type elements from dx 0 to dx 10 Dim dx 10 As Integer To declare a two dimensional array ds with 3x4 String type elements ds 0 0 ds 0 1 ds 0 2 ds 0 3 ds 1 0 ds 1 1 ds 1 2 ds 1 3 ds 2 0 ds 2 1 ds 2 2 ds 2 3 Dim dst S3 AS Str1ng AS Is a reserved word indicating that a variable type follows thereafter artisoc User Manual 79 3 5 2 Variable Type Declarations Variables have the following types Type Type Value Range Name Boolean Boolean Returns True if true or False if false String String Character count is 0 to no limit Integer Integer Integer from 2 147 483 648 to 2 147 483 647 Long Long Integer from 9 223 372 036 854 775 808 integer to 9 223 372 036 854 775 807 Real Double If negative number 1 79769313486232x10 4 94065645841247x10 If positive 4 94065645841247x10 1 79769313486232x10 Agent AgtType Type of agent defined in the model tree type Agent Agt An agent itself Actual value of agent Agent set AgtSet Set of agents Space Space Name of space defined in the model tree Space height and width 1 10 000 3 6 Execution Section The execution section is comprised of a sequence of execution stateme
22. is assigned a value of 1x3 Agent s array number are allotted sequentially starting from 0 Array variable When a large amount of data must be handled at one time giving a name to each item is extremely cumbersome For example if you are assigning variables to the test scores of 10 people in 5 subjects creating a number of variables equal to the product of the number of people and the number of subjects e g Enl Mal Hil Sol Scl En2 Ma2 Hi2 So2 Sc2 would be exceedingly inefficient and moreover if the number of people were to change this system would be unable to support the change In such situations array variables are used Array variables can be handled in the form variable name array number with an array number simply provided in the parentheses In the example with test scores for 5 subjects this would be En 1 Ma 1 Hi 1 So 1 Sc 1 En 2 Ma 2 Hi 2 So 2 Sc 2 66599 1 By employing this method we can use variable 1 with a repetition statement such as For Next En i Mai HiG SoG Sc artisoc User Manual 27 In artisoc the variables held by agents automatically become array variables In addition if variables are added to the space a grid shaped three dimensional array which conforms with the size of the space is created A three dimensional array is specified as variable name X_coordinate Y_coordinate Layer 1 5 8 Running a Simulation Many Uni
23. range of 2 to 4 used as the initial value of a particular variable ordinarily you would have to redo the setting of the initial value ten times and run a simulation for each one By using this setting however you can make the setting once and perform simulations while varying the initial value automatically until the conditions are fulfilled Minimum Value Maximum Value These set the minimum and maximum values of the range of random numbers for the variable to be changed Number of Executions with Same Initial Value This sets the number of times to execute the same simulation before changing the initial value artisoc User Manual 69 Number of Executions with Different Initial Value This sets the number of times to execute the simulation with the initial value varied randomly Set Different Values for Same level Variables Select this check box when you want to apply the different random number to identical variables of the same agent for example turtle 0 turtle 1 turtle 2 2 2 5 Control Panel 70 Using the Control Panel the variables which are directly under Universe can be modified in real time during the simulation In addition a specific rule can also be executed using the mouse or keyboard Selecting View gt Control Panel will display a window such as the following This Control Panel is a sample to illustrate control interface Every control name button toggle button etc should be
24. replaced with other name to represent its control purpose Control Panel toggle button Slider direct input field drop down list button After the button is pressed it will be on artisoc User Manual toggle button When the button is pressed it becomes on when it is pressed again it becomes off and so on slider Changes the value of the target variable by dragging within the range which has been defined in the Control Panel setting direct input field Changes the value of the target variable by clicking this field and directly entering with the keyboard drop down list Changes the value of the target variable by selecting this drop down list Configuring the Control Panel To configure the Control Panel select Settings gt Control Panel The following dialog appears Control Panel User Settings List toggle button slider direct input field drop down list Add Adds a control item to be displayed in the Control Panel Edit Edits a control item which is already displayed in the Control Panel Delete Deletes a control item which is already displayed in the Control Panel When the Add or Edit is clicked the User Settings dialog such as that below appears artisoc User Manual 71 12 User Settings Control name N Setting target Rule description Array index n form Rule Shortcut key 0 9 a 2 If t
25. the Space Settings Value is input Variables of clicked Variables of cell in in the Space Variables cell which specify range of cell included line artisoc User Manual 53 Except for the Variable tab the methods are as same as Point Agent Placement and Link Agent Connection 2 2 3 Output Setting Dialogs When Settings gt Outputs is selected the Output Item List dialog is displayed as shown in the screenshot below Output Item List aj El Two dimensional_map_1 E ETime Serios graph 1 Add 4 Edit E Copy iC Delete D Type of outputto add Time Series Graph Dd By selecting a type of output to be set from the Type of Output to Add list in this dialog and then clicking the Add button the details of the output can be set If multiple outputs are necessary repeat this procedure Using the arrow icons the output order can be changed Use checkboxes in the list to display hide that output 1 Map Settings You can display specific agents and variables on a two dimensional map and observe the agents movement and increase decrease In the Output Item List dialog select the Map from the Type of Output to Add list and click the Add button 54 artisoc User Manual Map Settings Space name Layer Map name Two dimensional map_1 hap tithe Map show legend Show rulec lines Background image o Background Color Select Origin loca 2 Upperleft Lower left View Type O chess go axis Y ax
26. up Now let s get accustomed to using artisoc by actually trying it out Preparation 1 Click Programs artisoc models Words of mouth Model from start menu Word of Mouth Model Asimulation of information which is spread by word of mouth 1 About this model This model simulates the process that a rumor spreads by having a small number of people holding information pass this information by word of mouth A Walker agent who has the information red is wandering around in a two dimensional space When this agent bumps into an agent who does not have the information green the information is conveyed and the color of the agent which was bumped into changes from green to red The number of red agents gradually increases and the rumor spreads Of course you are free to modify the various settings in this model but first let s try running a simulation as is artisoc User Manual 2 Running a simulation When you open the Words of mouth Model file the window such as that shown below will open mouth_com model artisoc File F Edit E View v Insert Settings S Debug D Run R Log L Window Help H ogo 9 amp TwoDimensionalSpace Walker ID ip x ig yY Layer Direction WalkerColor Withinfo WalkerCount W W StaggerLevel WalkersvithInfo Tree Tree window is the most basic screen in the artisoc which displays the various components
27. when calling up this graph Graph title Is displayed in the graph window Show legend If this is checked a legend is displayed beside the graph Axis label for X axis and Y axis Is displayed as the label for the axis Maximum steps to display for X axis As the steps of the simulation progress the time series graph is horizontally compressed because the graph window width does not change If a step count is set here then only this number of steps will be displayed at any given time In other words old data will progressively fall off of the left edge and be discarded Minimum Maximum for Y axis Step interval for X axis and Y axis Specifies the minimum value of the Y axis maximum value of the Y axis and graduation step interval Time series graph element list Lists the target elements When the Add button in the Time Series Graph Element List area is Clicked the following dialog is displayed to set the element of this graph If you want to display multiple elements on the graph each of them e g Agent Agent2 Variablel etc must be added to the Time Series Graph Element List artisoc User Manual Using the Edit button in the Time Series Graph Element List area any existing graph element can be edited Also using the Delete button any existing graph element can be deleted Element Settings Element name Output values Line width Bet Line color E select Other _ Show markers E
28. IRY 1 End TT If My Y gt 49 Then My DIRY 1 End If Forwardy My DIRY In this Turtle agent s execution rule a rule which randomly changes the direction is placed before the determination as to whether the end of space has been reached Since changing direction every step would result in a sort of drunken stagger the If statement is set up such that there is a one in ten chance that the direction will be changed In addition unlike the previous examples the If statements here obtain a value of 1 0 or 1 In this way agents will be seen to occasionally stand still To cause a branch with a probability of 1 in A If Int Rnd A 0 Then End if Select File gt Save As and save the model as prog10 model 30 artisoc User Manual 1 7 Creating a Spacing that Loops Looped space is a coordinate system which is utilized in LOGO s turtle graphics The top and bottom of the map and the right and left of the map are connected so that for example an agent which disappears off the right side of the map will reappear on the left side This coordinate system is convenient in that it can represent a pseudo spherical space but handling it in artisoc requires a bit of trickery We will describe the procedure and rules for a looped space Thus far in progXX model If statements have been incorporated in order to change direction when a end on the map has been reached but now with the sp
29. Manual 81 Remote Settings Remote name list Add Delete Global Space Info Global space width 100 Global space height 100 Show Space Map Add Adds a remote identification name Edit Edits a remote identification name which has been defined Delete Deletes a remote identification name which has been defined Global Space Information When you want to create a transfer model which represents one spacious space incorporating multiple artisoc models you must set the fields in Global Space Info area Global space width Defines the width of the global space Global space height Defines the height of the global space Show space map Opens the Global Space Info window and displays space map 82 artisoc User Manual Global Space Info Remote Name Settings When you click Add or Edit in the Remote Name List area the Remote Name Settings dialog appears Remote name Settings Remote name Has local space Local Space Infomation coordinate ofthe space Y coordinate of the space Space width Space height Space color Remote name Defines the remote identification name in the format of lt IP address gt lt identification name gt such as 10 94 42 135 A_Client and localhost B_ Client Has local space Allows you to define local space information If you want to create a transfer model on the global space check this option X coordinate of the space Specifies the X coo
30. Playback and Deletion When you select Log gt Start Replay the Replay Simulation dialog appears Replay Simulation Select simulation mouth_com model artisoc log 7 The simulation is recorded under the name lt model_file_ name gt artisoc lt simulation_memo gt When you select the simulation you want to replay from the pulldown menu and click OK the simulation becomes replayable If you want to delete a recorded simulation select that simulation and click Delete Replay Panel Once you have finished selecting the simulation that you want to replay the Replay Panel appears under the menu bar It is comprised of buttons which closely resemble those on the Run Panel a slider and a Current Step field The following screenshot is the Replay Panel floated by dragging the shaded region artisoc User Manual 75 76 Start replay reversely Replays continuously the simulation while rewinding from the end It is the same as Log gt Start Replay Reversely menu gt Start replay Replays continuously the simulation until it reaches the end It is the same as Log gt Start Replay menu Co Single step Replays the simulation by one step each time it is clicked It is the same as Log gt Single Step menu pause If this button is clicked during replay replay will be paused It is the same as Log gt Pause menu sop Stops replay It is the same as Log gt Stop Replay menu By dragging t
31. ables Set values individually agent Set values individually array E Turtle 7 j Export Select File Import Select File ox Cancel 20 artisoc User Manual Agents are given initial values individually using Initial Values of Variables dialog 3 Provide agents variables with a single value other than 0 at once Next let s say that we want to start all of the agents from a Y coordinate of 5 What can we do to accomplish this There are two answers to this One is to right click the variable Y select Initial Values and set the value of Y for all three agents to 5 The other is to add my Y 5 to Agt Init in the same manner as was already described for setting DIRX Select File gt Save As and save the model as prog05 model artisoc User Manual 21 1 3 11 22 If the Simulation Does Not Run Properly Component Placement and Settings M Outputs Settings y Agent Rule Declarations y Run and Debug The process of tracking down the cause of an error in a program and then fixing the program so that it runs properly is called debugging No matter how carefully your programming may be the program can hardly run perfectly on the first try It is safe to say that problems such as a program stopping due to syntax errors a program exhibiting unexpected behavior etc will always occur No matter how proficient you may be oversights and slips are a fact o
32. ace being configured to loop this map end processing will be taken out 1 7 1 Configuring Space First of all you can select Loop or Don t loop in the Space Properties dialog To cause looping Loop must be selected However this will only be in effect for space manipulation functions which have already been pre defined and therefore the preparations for a looped space are still not sufficient To loop the space Loop setting in the Space Properties dialog is not sufficient 1 7 2 Creating Coordinate Location Correction Functions We will need to provide rules which correct agents coordinate locations However since the rules themselves have gradually grown larger and since this correction rules seem to have the potential for reuse elsewhere as well let s try making use of user defined functions Function and Sub are functions that allow you to freely define the user defined functions The use of Function and Sub is differentiated as follows e Ifareturn value is required Function e Ifareturn value is not required Sub Function Syntax Function lt function name gt lt parameter declarations gt As lt type of return value gt lt variable declarations section gt lt execution section gt Return lt expression gt artisoc User Manual 31 32 Sub Syntax Sub lt function name gt lt parameter declarations gt lt variable declarations section gt lt execution section gt Note Function names
33. artisoc English Edition User Manual Disclaimer 1 The copying or reproduction of all or part of this manual using any method including but not limited to electronic copying mechanical copying photographic copying and audio recording for any purpose whatsoever without our expressed written permission is strictly prohibited 2 The contents of this manual are subject to change without notice 3 Every effort has been made to ensure that the contents of this manual are accurate but in the event that any items are discovered which are or might be erroneous please contact us 4 Section 3 notwithstanding we accept no responsibility for the consequences of putting this information into actual use 5 We will replace any manual which is incorrectly paginated or which has missing pages KOZO KEIKAKU ENGINEERING Inc All rights reserved Kozo Keikaku Engineering and its logo are registered trademarks of Kozo Keikaku Engineering Inc Kozo Keikaku Engineering Inc 4 38 13 Honmachi Nakano ku Tokyo 164 0012 Japan Tel 81 3 5342 1125 Innovative Information Technology Dept artisoc Section Chapter 1 Introduction to the artisoc artisoc User Manual 1 2 1 1 Running a Sample Model We have included sample simulation models in order to give you a feel for how the artisoc actually works When you use model files model you will quickly be able to run the simulation after just a minimum amount of set
34. ay only a specific portion of the space on the map The default maximum value is the space size Map element list Lists the agents and variables displayed on the map When the Add button in the Map Element List area is clicked the following dialog is displayed to set the element of this map If you want to display multiple elements on the map each of them e g Agent1 Agent2 Variablel etc must be added to the Map Element List Using the Edit button in the Map Element List area any existing map element can be edited Also using the Delete button any existing map element can be deleted Element Settings Element name Target Tu rtle Marker 2 None Select Filename Variable specifying marker Agent color Fixed color a Select O Variable specifying color Agent variable information C Show information Cancel artisoc User Manual Element name Is the name of this map element You can enter an arbitrary name Target Selects the element agent etc whose movement you want to watch on this map Marker Selects what marker to be displayed for the element on the map With None a marker is not displayed With Select you can select one of the built in markers With Filename you can select an arbitrary image file only icon files are currently supported by entering the path to the file With Variable Specifying Maker File you can select a variable immediately under the Unive
35. e O Variable specifying marker 0000000000 Fixed color C Variable specifying color OOOOOOOOOOO _ Show information Ll Draw lines 14 artisoc User Manual Click OK on the Map Settings dialog to close it The Two dimensional_map_1 is added to the Output Item List Click OK to close the dialog 1 3 5 Running a Simulation Do Nothing Turtle Let s try clicking on the Start button in the Run Panel In this state the agent does not have any rules yet so it cannot move from the location at which it was placed But you have at least built the minimal model for an agent to move around New File artisoc File F Edit E View Inserti Settings S Debug D RunfR LogfL Window Help H x yY il Two dimensional mapi 2222 een oe Space Click the Stop button to stop the simulation Select File gt Save As and save the model as prog01 model 1 3 6 Opening the Rule Editor Component Placement and Settings vy Outputs Settings vy Agent Rule Declarations y Run and Debug The agent cannot move as it is so let s give the agent a rule We ll add the new information to prog01 model artisoc User Manual 15 Select and right click the Turtle in the component tree Select Rule Editor from the menu The Rule Editor window for the agent is displayed New File artisoc FiletF Edit E View Inserti Settings S Debug D Runi LogfL Windowiy HelpfH gt
36. e Execution rule If the return value of Forward X is not 1 consider the turtle agent to reach the dead end and multiply DIRX by 1 Converting these rules to code results in the following Prog03 model Turtle agent rules Agt Init My DIRX 1 Agt Step If ForwardX My DIRX lt gt 1 Then My DIRX My DIRX 1 End If When you type My variables menu to select X Y Direction etc is displayed Here we use DIRX so select DIRX using the arrow keys and press Enter This My is a special expression which refers to the agent itself Therefore My DIRX indicates the DIRX variable which is contained in this agent itself To make the code easier to read you should place spaces between variable names and operators such as and My is a special expression to indicate an agent itself artisoc User Manual in a rule is an assignment operator As mentioned above Agt_Init is a rule which is executed once when an agent is created The new variable are set to O as its initial state so if DIRX is not set to 1 or 1 in the initial rule the turtle will not be able to move In the prog03 model a conditional branching rule is newly added It is written with the following syntax If condition Then rule to perform if the condition is true End If Any number of lines can appear between the Then and the End If It is common to use Tab to indent this p
37. en arrowed line type and color How to set Specify the operation in the display screen Five settings lunselect point only link between point link with point delete are available Unselect It doesn t run the Point Agent placement and Link Agent Connection Point only If you left click in the display screen the Point Agent which you select is arranged in the clicked screen Link between Point Using the selected Link Agent you can connect Point Agent artisoc User Manual Link Agent Connection Select the Begin Agent at first left click The Begin Agent is highlighted If you select the End Agent in left click the Link Agent is connected After connecting the End Agent is automatically set to the Begin Agent In addition if you left click the connected Agent you can connect to the Link Agent The End Agent is cancelled by right click Link with Point As same as Link between Point it connects Point Agent with using Link Agent If you left click the point where there are no Point Agent the Point Agents are arranged So you can simultaneously run the placement of Point Agent and Link Agent Connection Deletion If you left click the Agent in a display screen the data is deleted If you delete the Point Agent when you connect to Link Agent the Link Agent is deleted at the same time Display List Display only the checked items in the screen X Y Total Agent Number Total Link
38. ent executing the rules at each step will be restricted by agent type Setting the priority to 1 for all of the agent type is equivalent to choosing the Random option above mentioned If only one agent type here bbb is set to priority of 2 and the others is set to priority of 1 the agents belonging to bbb type execute their rules after the other agents have executed The execution order of the agents with the same priority level is rearranged at random at every step In addition if the Change Execution Order on First Time Only is checked the execution order is rearranged just once when the simulation starts artisoc User Manual 4 Run Continuously Tab When Initial Values Change Setting Is Set to None Run Preferences Simulation Run Type Multi Type Initial value change setting None O Linear O Random hax Repeat i Times Maximum Number of Executions The simulation is repeated the number of times entered unless you quit the simulation artisoc User Manual 67 68 5 Run Continuously Tab When Initial Values Change Setting is Set to Linear Run Preferences Simulation Run Type Multi Type Initial value change setting i None Linear O Random Changing Var Mame Universe abel Start End 5 Range of Change 1 Repeat Mumberin Same Initial Number 2 Initial Value Change Variable Name When you want to perform a simulation with the initial value of a particula
39. erval Specifies the timing of Java garbage collection so that screen output will be performed smoothly By default this is set to 10 meaning that GC will be performed at every 10 Steps If O is specified garbage collection will not be performed explicitly so the simulation will proceed at maximum speed 2 Rule Execution Tab Run Preferences Simulation Run Type Multi Type Execution order of agent rules Random O Random by agent type Change execution order on first time only artisoc User Manual 65 66 Execution order of agent rules For Universe Univ_Step_Begin is executed at the beginning of a step and Univ_Step_End is executed at the end of a step but for agents execution order can be changed by these settings If the Execution Order of Agent Rule is Random the order of agent executing the rules will be changed randomly at every step In addition if the Change Execution Order on First Time Only is checked the execution order is rearranged just once when the simulation starts 3 Rule Execution Tab when Random By Agent Type is selected Run Preferences Simulation RunTyoe Multi Type Execution order of agent rules O Random Random by agenttype _ Change execution order on first time only 1 Universe Spacel aaa 1 Universe Space cee 2 Universe Space bbb Export Impart Execution order of agent rule If the Random By Agent Type is selected the random order of ag
40. ettings dialog is displayed 6 artisoc User Manual Time Series Graph Settings Graph name Series Graph of Red Walkers Graph title The Amount of Red Walkers Show legend F Background Color x axis Y axis Axis label Axis label Maximum steps to display lo Minimum Step interval 10 Waxiriurm Step interval Time series graph element list VWalkersy ithinfo Select WalkersWithInfo from Time Series Graph Element List and click the Edit button Change Line Width from 2 pt to 4 pt check Show Markers and click the OK button Element Settings Element name iWyalkersyvithInta Gutput values Universe WalkersvvithInt J Line width ato oo ooo F Line color E setect Other Show markers e We re ready once again Click the Start button in the Run Panel artisoc User Manual 7 mouth_com model artisoc SEE FiletF Edit E View Inserti Settings S DebugfD RunfR LogfL Window HelptH i n E Spaco mar TE Universe a Walker ID ig x ig yY Layer Direction Two Dimensional Space WalkerColor VWithinfo W WalkerCount W StaggerLevel WalkersWithinfo al Time Series Graph of Red Walkers The Amount of Red Walkers Nn U eO ON O 0 10 20 30 40 50 60 70 80 90 100 110120130 140 150 160170 1 3 Creating a Simple Model In this section you will learn the basic elements and procedures for b
41. exit condition expression gt Then Break Exit one level End If Next j Next 1 3 6 8 Include Statements These statements are used to load functions which have been defined in external files include files If functions which are used frequently are placed into an include file these functions can be called from multiple agents Normally this is expressed in the following format in the top lines of the Rule Editor include lt external filename 1 gt inc include lt external filename 2 gt inc Note When using multiple include files write them as one file per line 6 artisoc User Manual 3 6 9 Other Statements Return This ends execution of a function and returns execution control to the caller At that point if the function was defined as one which returns a value then it can return a value It is expressed in the following format Return lt expression gt Note Any number of Return statements can be placed in a function Note In the following situations an interpreter error will result e Ifthe function was defined as one which returns a value but the expression 1s omitted e Ifthe function was defined as one which returns a value but the type of the return value and the type of the expression are different e Ifthe function was defined as one which does not return a value but an expression is written 3 Built In Functions The artisoc has predefined functions called built in functions These functions
42. f life in programming Therefore you may ultimately make quicker progress by appropriately solving the problems that inevitably occur rather than trying to prevent errors beforehand In contrast to human beings who tend to be ambiguous about things computers all run by logic Unless something quite unusual happens exceptions deviating from logic do not occur As a result it can be said that a computer error always has a clear cause If the results of a program are not as you expected it is because there is some sort of problem on logic and not because for example the machine is in a bad mood or the machine hates me To resolve errors it is important to first track down and isolate in accordance with the logic of the computer the area which has caused the problem The followings are errors which beginners are especially prone to make 1 Syntax errors in rules When a program behaves differently from what was expected or when a warning appears the first thing to suspect is syntax errors in the rules These sorts of errors are experienced often as a result of carelessness and not only by beginners but by proficient programmers as well Countermeasure 1 artisoc has a feature in which when an error is found prior to run a warning is displayed indicating the line involved In most cases the cause of the error is a mistake in the code in the highlighted line so check the followings e Spelling errors in variable or fu
43. f the agent in question For example e An agent which is an array Universe agent_a i Agent_b e Specifying an agent starting from Universe Universe Agent_a agent_b i e Specifying the current agent My artisoc User Manual 81 lt variable specifier gt The expression format is the same as that for variables which are declared in agent rules Assignment statement examples a 0 a b Function_a c a i b Universe a 0 Universe a i b Universe Agent_a i My a 1 E T 0b C 3 6 3 Expressions Expressions either are linear expressions or are the combination of linear expressions using operators e Arithmetic expression x y Rnd 10 e Relational expression If x gt y Then e Logical expression If x gt y And x gt z Then e Character expression multi_agent multi_ amp agent Linear expressions are one of the following e Numeric constant e String constant e Variable specifier same as variable specifiers in assignment statements e Function call e lt linear expression gt e Not lt linear expression gt Not bit operator e lt expression gt Examples of linear expressions 0 Constant z Variable specifier 1 Variable specifier Function a a b Function call 2 artisoc User Manual X lt linear expression gt Function_a a b lt linear expression Not a Not lt linear expression gt a b FE lt expression gt a
44. formly Arranged Turtles Now let s try running a simulation with an agent count of let s say 6 You will see that the turtle agents line up in a uniformly spaced manner as specified in Univ_Init 1 6 Giving an Agent a Randomness 1 6 1 28 Based on what you ve done so far we trust that you now understand the way of giving variables uniformly varying values However this still seems somewhat mechanical and not quite multi agent like In light of this let s next try adding a randomness to the initial rule Randomly Arranging Agents in the Space It is a relatively simple matter to randomly arrange agents in the space We will use the agent function RandomPutAgtSetCell which is already provided in artisoc in Univ_Init In the parentheses we will set the first argument to be the agent to be placed the second argument to be either True or False to indicate whether or not to permit multiple agents to be placed in a single cell You may assume you should write the assignment statement such as i RandomPutAgtSetCell because functions by nature have return values However in this case only the capability to randomly arrange the agents is important so the return value is not necessary When the return value will not be used the assignment expression is often omitted as is the case in the rule below RandomPutAgtSetCell arranges agents randomly ProgO7 model Universe rules Univ Init Dim TurtleSet As A
45. gt lt variable declarations section gt lt execution section gt Sub Declares that a user defined function is defined thereafter lt function name gt Is the name of this user defined function You can enter an arbitrary name However reserved words previously declared variable names and name constants etc cannot be used because this will confuse the artiSoc lt parameter declarations gt If there are parameters to be passed to the function they are declared in the following format lt variable specifier 1 gt As lt variable type gt lt variable specifier n gt As lt variable type gt For example Sub subl a As Integer b As Integer c As Double Differences between Function and Sub If after execution of a user defined function you want to use its resulting value return value in the execution statement use Function otherwise use Sub For example consider the following rules 1 Agent_Step 2 Dim a As Integer 3 a Functnond 53 4 5 Function functionl b As Integer c As Integer As Integer 6 Dim answerl As Integer 7 answerl btc 8 Return answerl 9 In Agt Step the Integer variable a is declared in line 2 Next in line 3 the values 5 and 3 are passed to the user defined function function1 for calculation and the result of the function1 is assigned to a In the definition of the user defined function starting at line 5 an Integer variable answer1
46. gtSet MakeAgtSet TurtleSet Universe Spacel Turtle RandomPutAgtSetCell TurtleSet False A set of turtles in the space is defined as TurtleSet and the initial values of TurtleSet are obtained using MakeAgtSet Subsequently obtained agent set TurtleSet is arranged randomly by RandomPutAgtSetCell Select File gt Save As and save the model as prog07 model artisoc User Manual 1 6 2 Adding Randomness to Variable Values To assign a random number to a variable we use the Rnd function Rnd generates a random number which is greater than or equal to 0 and less than 1 A random number which is an integer is often required so the method below in which Int is used to truncate the decimal part is employed 1 Int Rnd 5 66599 1 In this case the value of the variable i will be an integer value from 0 to 4 If you want to obtain a value from 1 to a you can use the following statement i TAERA va el In the previous example if RandomPutAgtSetCell is not used you can write the Univ_Init as follows Prog08 model Universe rules Univ Init Dim i As Integer For 1 0 to CountAgt Universe Spacel Turtle 1 Universe Spacel Turtle 1 X Int Rnd 50 Universe Spacel Turtle 1 Y Int Rnd 50 Next 1 Select File gt Save As and save the model as prog08 model To obtain a random integer from 0 toa i Int Rnd a 1 In addition to this let s also try
47. he Rule Description is selected as the setting target a button is added to the Control Panel When this button is pressed the rule which has been defined will be executed If a shortcut key has been specified then this particular rule will be executed in response to keyboard input without pressing the button on the Control Panel The User Settings dialog for button toggle button slider direct input is as follows artisoc User Manual Control name Is the name of this control You can enter any easy to understand name Setting target Selects the variable which you want to manipulated from the Control Panel You can however only select variables which are directly under Universe Interface User Settings Control name N Setting target ValiableString Array index n form Interface Button ON value Toggle button Direct input Drop down list List item Shortcut key _ 0 9 a z Selects the type of this control e Button Select this when you want to assign some arbitrary value only when this is on 1 e clicked e Toggle Button Select this when you want to assign separate arbitrary values when this is on and when it is off e Slider Select this when you want to intermittently change a value within some range by dragging a slider to the left and right e Direct Input Select this when you want to directly enter the value to assign to a variable
48. he step to be displayed can be freely moved slider Current step Displays the step which is being outputted to the screen By entering a value directly into this field you can output the state at the specified step to the screen artisoc User Manual 2 4 3 Database Settings You can change the database to save log files to the other database from the artisoc s database as standard equipment The acceptable databases are PostgreSQL 8 1 8 2 SQL Server 2000 2005 Database setting JDBC Driver Database URL User Password 2 5 Window Arrangement Cascade By selecting Window gt Cascade you can arrange the windows being displayed in a cascaded overlapping fashion Tile By selecting Window gt Tile you can arrange the windows being displayed in a tiled fashion artisoc User Manual 77 2 6 Help Function Show Help Functions 2 6 1 Display Version Information When you select Help gt Version Information the program s version information is displayed About artisoc altisoc professional Ver 2 0 08 04 22 Copyright 2 Susumu Yamakage Tokyo University and Kozo Keikaku Engineering Inc 2 6 2 Changing over Ver1 0 Menu If you select Help gt Changing over Ver1 0 Menu the function and menu display for artisoc are appeared Ver 1 0 The artisoc Ver 2 0 include the function and menu display for the artisoc Ver 1 0 however please refer to manual of artisoc Ver 1 0 for details
49. imparting a random direction to the agents We will first need to remove the initial rule which has been left in the Turtle agent In the following rules the complicated expression 1 Int Rnd 2 2 appears This is just a simple technique for obtaining a result of either 1 or 1 ProgO9 model Universe rules Univ Init Dim 1 As Integer For 1 0 to CountAgt Universe Spacel Turtle 1 Universe Spacel Turtle 1 X Int Rnd 50 Universe Spacel Turtle 1 Y Int Rnd 50 Universe Spacel Turtle i DIRX 1 Int Rnd 2 1 Universe Spacel Turtle i DIRY 1 Int Rnd 2 1 Next 1 artisoc User Manual 29 Prog09 model Turtle agent rules Agt Init Select File gt Save As and save the model as prog09 model 1 6 3 Rewriting Execution Rules of the Agent We now have a program in which the initial location and direction of agents is provided randomly Next as an application of this let s try also adding a randomness to the agents execution rule Agt Step Right now an agent s direction does not change until it reaches the end of space so let s instead try changing the direction randomly Prog10 model Turtle agent rules Age Stepi If Int Rnd 10 0 Then My DIRX 1 Int Rnd 3 My DIR b 4 Tat Rnd 3 End If If My X lt 0 Then My DIRX 1 End If If My X gt 49 Then My DIRX 1 End If ForwardX My DIRX If My Y lt 0 Then My D
50. in a tree structure In the tree there will always be one Universe Under this components such as spaces agents and variables can be defined These will be explained in detail in Chapter 2 Now let s try actually running this model To run it use the Run Panel which is under the menu bar You can float the Run Panel using drag and drop Start button Starts the simulation Single Step button Runs just one step of the simulation Pause button Pauses the simulation a El Stop button Stops the simulation artisoc User Manual 3 Let s run a simulation Click the Start button Was a screen such as the following displayed mouth_com model artisoc File F Edit E Viewt Insert Settings S DebugiD RunfR Logi Window Help H Pie a TwoDimensionalSpag Walker ID ig x gy Layer Direction Two Dimensional Space VWalkerColor E Withinfo VWalkerCount StaggerLevel Walkersvithinfo The Amount of Red Walkers 70 80 90 100 110 120 3 Simulation results Four windows Tree Time Series Graph of Red Walkers Space Map and Console Screen like those shown above were displayed right In these windows the simulation will continue and the results will be displayed in real time until Stop or Pause is pressed or until the information has been passed to all of Walker agents 1 2 Arranging the Simulation In the previous section we tried actuall
51. is Axis label Axis label Minimum Minimum Maximum hl asin Ui Map element list human Space name Specifies the space to be displayed Layer Specifies the layer to be displayed If the Layer field in the Space Properties dialog has been set to 1 you cannot set to the value other than 0 If the Layer field in the Space Properties dialog has been set to greater than 1 you can set to the value from 0 to that value 1 Map name Is the name to reference when calling up this map Map title Is displayed in the map window Show legend If this is checked a legend is displayed beside the map Show ruled lines If this 1s checked horizontal and vertical lines are drawn on the map artisoc User Manual 55 56 Background image If this is checked the map is displayed against a background image Specify the image either by checking Filename and entering the path relative path from the folder in which the model file is placed or by checking Variable Specifying Image File and selecting the variable string variable immediately under the Universe Origin location Selects whether to position the origin in the upper left as is common in computer or information science or in the lower left as is common in mathematics View type Selects whether to place each agent within a cell Chess type or on the point of intersection Go type X axis Y axis By setting minimum and maximum values it is possible to displ
52. l be placed under Universe Universe Only one Universe exists at the highest level of the simulation model A simulation model is constructed by placing various components under Universe A space is not necessarily required as it would be in the real universe abstract models which have no accompanying space can be constructed as well Spaces In a space agents variables etc are placed In the current version of artisoc a three dimensional space is supported Normally Grid models providing a vertical and a horizontal dimension are used but a Hexagon model can be used as well You can connect the end of space to the opposite end by specifying Loop If you select Loop then agents which disappear off of the right border will reappear on the left border artisoc User Manual 9 However since this functionality is only in effect within artisoc s functions in programs you have to write the code to loop Agents In simulations components which move and behave according to specific rules are called agents Agents affect other components and are affected by other components With artisoc using simple procedures you can arrange these sorts of agents and perform simulations involving them Variables You can store the information and state number character etc associated with each component in its variables You can think of these as being roughly synonymous with the x and y variables in mathematics A distinctive
53. laration section variables which are only used in that function are declared These variables must always be declared before they are used Using a variable without declaring it will result in an undefined variable error in the interpreting stage Variables declared here are called local variables and can only be referenced and modified from within the function in which they are declared Local variables are initialized when execution of the function begins and are discarded when the execution of the function ends When they are initialized String variables are cleared to the null string and all 78 artisoc User Manual other variables are cleared to 0 3 5 1 Variable Declarations The variable declarations are expressed in the following format They are not required if local variables will not be used Dim lt variable specifier 1 gt As lt variable type 1 gt lt variable specifier n gt As lt variable type n gt Examples Dim x As Integer Dim xl As Double x2 10 As Double x3 10 20 30 As Double Dim Is a reserved word indicating the beginning of variable declarations lt variable specifier gt This is expressed in the following format e For simple zero dimensional variables lt variable name gt e For array variables These are declared in the following format Dim lt variable name 1 gt ml mn As lt variable type gt lt variable name 2 gt ml mn As lt variable type gt 7 t 4 i
54. lement name Is the name of this graph element You can enter an arbitrary name Output values Specifies the elements variable etc whose progression you want to watch in this graph Line width Line color Sets the width and color of the line The default line colors are in the order added red blue gt green purple light blue gt yellow grey Show markers If this is checked markers will be displayed on the graph 3 Bar Graph Settings You can display specific components in a bar graph In the Output Item List dialog select the Bar Graph from the Type of Output to Add list and click the Add button artisoc User Manual 59 Bar Graph Settings Graph name Graph title Show legend v Stack bar Direction of bars Horizontal Vertical Background Color x axis Y axis Axis label Axis label Minimum Maximum Step interval Bar graph element list Edit Delete The settings are basically the same as those for the time series graph 4 Values Screen Settings You can display the values of the specified components in a window In the Output Item List dialog select the Values Screen from the Type of Output to Add list and click the Add button Values Screen Settings Output name Values tithe Walues element list Output name Is the name to reference when calling
55. lowing procedure is an example that the agent is created under the space Procedure 1 Select a space here Space1 in which to create the agent 2 Select Insert gt Add Agent 3 An Agent Properties dialog such as the following appears Agent Properties Agent name Agenti Agent count q Agent name Is the name of this agent You can enter an arbitrary name for example Agent1 Agent count Is the number of instances of this agent When you run simulation the specified number of agents are created and they behave based on the same rules Think as How many copies of this agent should be created artisoc User Manual 39 4 Click the OK button The dialog closes and the new agent appears in the tree Space oO ia Thus we have successfully created a new agent under the space The process is the same even when creating a new agent directly under Universe or when creating a new child agent under another agent Note When an agent is placed in a space five variables ID X Y Layer and Direction are automatically placed under the agent because agents always have coordinate information in the space 2 1 5 Agent Rule Declaration 40 Even after an agent is created it will not do anything if no rules are written for it It is necessary to create agent rules for each agent Procedure 1 Select the agent and open the Rule Editor There are two types of Rule Editor window
56. med in the above example programs O Try changing the value of the variables in the example programs and consider potential applications of them 1 9 Syntax Differences between artisoc and Visual Basic 34 The syntax in artisoc basically follows that of Microsoft Visual Basic but there are some points of difference These differences are shown below Item Function definitions artisoc Function Sub todd Visual Basic Function End Function Sub End Sub Function return values Return lt return value gt Specified as an argument to the Return function lt function name gt lt return value gt Inputted to function name Variable declarations Type is required If type not specified Variant Relational operators If A B Then EndIf Two characters If A B Then EndIf One character For Next For i 0 To 10 For i 0 To 10 Next i Next Variable is required at the end Comments El is From to Special functions artisoc User Manual Agt_Init executed just once upon agents creation Agt_Step executed at every step Chapter 2 Reference artisoc User Manual 35 2 1 Model Configuration 2 1 1 36 In this section we will describe the model configuration capabilities which are used to configure components such as agents and variables Model File Input Output To perform such tasks as creating new simulation models l
57. n artisoc and original functions can be defined by the user as well For CountAgt if an agent Turtle is specified within the parentheses the number of the agents copies of Turtle will be returned as an Integer Function are a mechanism in which data is supplied and a specific value is returned 1 5 6 Specifying a Component In terms of how an agent is specified within the parentheses the hierarchical relationship with respect to Universe is expressed delimited by periods The Turtle agent will be Universe Spacel Turtle This sort of expression is used in a variety of places so be 26 artisoc User Manual sure to remember it To specify a component describe its hierarchical relationship with respect to Universe Periods indicate hierarchical relationships 1 5 7 Accessing Individual Agents A simple technique is necessary to obtain the information held by an individual agent This sort of expression is used frequently so be sure to remember how to use it First created agents are allotted array number sequentially starting with 0 The variables in agents are stored as an array and are called up in the form variable_name array number For example the X coordinate of the turtle agent with an array number of 4 is represented as Universe Space1 Turtle 4 X In prog06 model the variable 1 represents array number by changing its value from 0 to agent count 1 and each respective X coordinate
58. n extremely complicated programming environment artisoc was developed with this issue in mind However in order to create simulation models programming the rules is inevitable You can learn more about these rules by referring for instance to the sample models The syntax which are used by artisoc are similar to that in Microsoft Visual Basic which is relatively easy to learn For information on artiSOc syntax see Section 1 9 and Chapter 3 Find and Replace in Rule Editor With the Rule Editor open when Edit gt Find or Replace is selected the Find or Replace dialog opens Find what Turtle Find Mest _ Use regular expressions _ Match case Cancel 42 artisoc User Manual Replace Find what Red Turtle Find Mext Replace with Green Turtle Replace and Find Mest C Use regular expressions Replace All E Match case Rule Editor Configuration By selecting Settings gt Other Settings settings for the Rule Editor can be changed Other Settings Rule Editor Settings Auto indent Coloration Keep output screen open after simulation Auto indent If this item is checked automatic indentation will be performed when entering rules in the Rule Editor Coloration If this item is checked coloration will be performed when entering rules in the Rule Editor To improve the response of your Rule Editor uncheck this Font If you want to change the font settings in Rule Editor click Font bu
59. nction names e Appropriate spaces not inserted when writing statements variables and operators The space between words in a program has an important significance If words are strung together they will not be recognized correctly Countermeasure 2 Check the values of variables using the PrintLn built in artisoc User Manual function within rules For example PrintLn DIRX will display the value of DIRX variable on the console screen 2 Mistakes in output settings In artisoc if you don t specify output settings then nothing will be displayed when you run the simulation Also when two types of output are expected and only one appears or when a graph or value behaves in an unexpected way this is often due to errors in the output settings In many cases warnings are not displayed for these errors so finding these errors may be difficult at first Countermeasure When you are trying to obtain some sort of result in the simulation the output settings are indispensable In the respective output settings check if the item name and the element name in the element settings are correct The reason why an output element is missing is often an error in the element name 3 Mistakes in component properties If nothing in particular is wrong with the rules but the behavior is nevertheless unusual you should suspect that there may be an error in the component properties agent count initial values etc Countermeasure 1
60. next try creating multiple agents No matter how many of them we create if they are all initially placed in the same location they will all move in the same way We will thus vary the location at which every agent is placed Select the Turtle agent in the component tree and right click to display the context menu Select Properties to display Agent Properties dialog Set the Agent Count to 3 and click OK The agent count is set using Agent Properties 2 Provide agents with initial locations individually We want to start the respective agents from different locations What do we need to do in order to provide separate initial values to the X and Y variables representing the agents locations in the space Variables have the ability to have initial values individually so we will be using this functionality Select the variable X under the Turtle agent in the component tree and right click to display the context menu Select Initial Values to display Initial Values of Variables dialog Three turtle agents numbers 0 1 and 2 are listed Give these the values 5 10 and 15 respectively as shown in the following screenshot If the numbers are hard to see drag the right edge of gray column header X to adjust the width of the column After you have entered these settings click OK to close the dialog You will see that despite the simplicity of the rules the movements which result are quite interesting Initial Values of Vari
61. nts called a block and describes the behavior of an agent A block is a sequence of 0 or more consecutive execution statements Types of execution statements include empty statements assignment statements conditional statements iteration statements and jump statements 3 6 1 Empty Statements These are statements which do not execute anything They are used to make programs easier to read Example If x 1 And y 1 Then Else Z 0 End If The above is equivalent to the following Lt eG A OIE ay SL Ten f 0 artisoc User Manual End If 3 6 2 Assignment Statements These are statements for setting variables with values lt variable specifier gt lt expression gt lt variable specifier gt Is either a variable which has been declared within an agent rule or an agent variable which has been set using the GUI These are expressed in the following format 1 For variables declared within an agent rule e For simple zero dimensional variables lt variable name gt For example X e For array variables lt variable name gt lt expression representing element number in first dimension gt T lt expression representing element number in n dimension gt For example x 0 For one dimensional array y i For one dimensional array z i J Eor two dimensional array 2 For agent variables lt agent specifier gt lt variable specifier gt lt agent specifier gt Specifies the path name o
62. oading existing simulation model files and saving simulation settings which have been created select a command from the File menu as shown in the screenshot below Simulation configuration data is saved as a model file model Mew File artisoc File F EditE View Insert Settings Mewth Ctrl N Opento Ctrl 0 Savers Ctrl S Save Asta Creating a New Simulation Model To newly configure a simulation model select File gt New Loading a Simulation Model To load a model file select File gt Open Saving a Simulation Model To save a configured simulation as a model file select File gt Save or Save As artisoc User Manual 2 1 2 New Model Creation When you start up the artisoc or select File gt New a screen such as the following is displayed New File artisoc FiletF Edit E ViewtY Insert Settings S DebugfD RunfR Logi Window HelpfH gt i gt Tree Tree window is the most basic screen in the artisoc which displays the various components in a tree structure In the tree there will always be one Universe The simulation model is configured by placing components such as spaces agents and variables under this 2 1 3 New Space Creation A space is a flat surface It is created in order to observe agents moving there Procedure 1 Select Universe in the tree 2 Select Insert gt Add Space 3 Space Properties dialog such as the following is displayed artisoc User Man
63. on section gt Univ_Step Begin This function is used in rules for Universe and is executed at every step until the simulation ends At each step it is executed before all other rules The name Univ_Step Begin has a special significance and is a reserved word which cannot be used for any other purpose It is expressed in the following format Univ_Step_ Begin lt variable declarations section gt lt execution section gt Univ_Step End This function is used in rules for Universe and is executed every step until the simulation ends At each step it is executed after all other rules The name Univ_Step_ End has a special significance and is a reserved word which cannot be used for any other purpose It is expressed in the following format Univ_Step_End lt variable declarations section gt lt execution section gt Univ_ Finish This function is used in rules for Universe and is executed just once at the end of the simulation The name Univ Finish has a special significance and is a reserved word which cannot be used for any other purpose artisoc User Manual 75 It is expressed in the following format Univ_Finish lt variable declarations section gt lt execution section gt 3 3 User Defined Functions User defined functions are functions which can be freely defined by the user You can call them from Agt Init Agt Step and other user defined functions in the Same manner as for name constants which
64. ortion in order to make the branched structure of the conditional expression easy to read In rule declarations no distinction is made between upper and lower case characters Consequently my DIRX and My dirx are actually both treated identically If condition Then rule for when the condition is true End If In rule declarations no distinction is made between upper and lower case characters 3 Run a simulation back and forth turtle After you finish writing the rule try clicking the Start button in the Run Panel If the simulation runs properly the turtle will switch direction at the end of the map and move back and forth between the left end and the right end Select File gt Save As and save the model as prog03 model As a practice exercise try adding a variable DIRY which represents the direction for the Y coordinate and creating an agent which moves diagonally The correct answer for the agent rules is as follows Prog04 model Turtle agent rules Agt Init My DIRX 1 My DIRY 1 Agt Step If ForwardX My DIRX lt gt 1 Then My DIRX My DIRX 1 Ena IT If ForwardY My DIRY lt gt 1 Then My DIRY My DIRY 1 End If Select File gt Save As and save the model as prog04 model artisoc User Manual 19 1 3 10 Increasing the Number of Turtle Agents 1 Create multiple agents When you have successfully created an agent which moves diagonally let s
65. point on a planar surface and can store one value However this makes it inconvenient to handle a large amount of the same type of values By increasing the number of dimensions you can increase the number of values which can be stored A one dimensional variable can store n 1 values from 0 to the value n specified for Array Elements Count of N Dimension A two dimensional variable with an array elements count of m for the first dimension and n for the second dimension can store m 1 x n 1 values which is expressed as variable m ny The array element starts from 0 so be sure to add one to the elements count The maximum number of dimensions and maximum array elements count are 10 000 4 Click the OK button The dialog closes and the new variable appears in the tree Universe E Spacet Q Direction Note When an agent is created in a space variables ID X Y Layer and Direction are automatically created ID variables indicate the number 0 or more applied to distinguish agent s each one by each agent type Other variables indicate the coordinates 46 artisoc User Manual of the agent and therefore are not created if the agent is not in a space We have successfully created the new variable Variable1 under the agent The creating process is the same even when creating directly under Universe or when creating directly under a space 2 2 Simulation Configuration 2 2 1 Initial Values Dialogs
66. r False if false String String Character count is 0 to no limit Integer Integer Integer from 2 147 483 648 to 2 147 483 647 Long integer Long Integer from 9 223 372 036 854 775 808 to 9 223 372 036 854 775 807 Real number Double If negative 1 79769313486232x10 4 94065645841247x10 If positive 4 94065645841247x10 1 79769313486232x10 Space Space Name of space defined in model tree Space height and width 1 10 000 Agent type AgtType Type of agent defined in the model tree artisoc User Manual 45 Agent Agt An agent itself Actual value of agent Agent set AgtSet Set of agents Basically we recommend choosing the String for characters the Integer for integers and the Double for values with a decimal part The Boolean is a somewhat special type and its values are either True or False The Agt is used when you want to use an agent itself as an argument to a function and the AgtSet is a collection of that agent History size In the artisoc past states values of variables can be recorded Using this field you can specify the number of steps to be recorded Past states can be retrieved using the GetHistory function The maximum history size is 10 000 steps Dimensions A variable is like a box into which data is placed As a general rule only a single value can be placed into a single variable A newly created variable has 0 dimensions in other words it corresponds to a
67. r variable changed in a stepwise manner then enter the variable name here For instance if you want to execute a total of 10 types of simulations with the initial value of a particular variable varied from 1 to 5 in steps of 1 ordinarily you would have to redo the setting of the initial value ten times and run a simulation for each one By using this setting however you can make the setting once and perform simulations while varying the initial value automatically until the conditions are fulfilled Start Value End Value Range of Change These set the start value end value and range of change for the variable to be changed Number of Executions with Same Initial Value This sets the number of times to execute the same simulation before changing the initial value artisoc User Manual 6 Run Continuously Tab When Initial Values Change Setting Is Set to Random Run Preferences Simulation Run Type Multi Type Initial value change setting None O Linear Random Changing Yar Mame Universe abe Min 2 Maxa Repeat Number in Same Initia Number Repeat Number in Qetferent Initia Number 2 _ Set Different Number in Same War Initial Value Change Variable Name When you want to perform a simulation with the initial value of a particular variable changed randomly then enter the variable name here For instance if you want to execute a total of 6 types of simulations with random numbers in the
68. rdinate of the upper left point on the local space artisoc User Manual 83 Y coordinate of the space Specifies the Y coordinate of the upper left point on the local space Space width Defines the width of the local space Space height Defines the height of the local space Space color Defines the color of the local space When you click the Show Space Map in the Remote Settings dialog the space in this color will be displayed in the Global Space Info dialog 84 artisoc User Manual 2 10 Capturing Output Screen You can get the screenshot of a specific output screen Stop the simulation if running activate the target output screen and select File gt Capture Output Screen mouth com e model artisoc Filet EditfE View M Insert New h Ctrl N Open Oy Ctrl 0 Ctri 5 F Exit Capture Output Screenai The screenshot is copied in the clipboard You can paste it on your application software such as Word and Power Point artisoc User Manual 85 Chapter 3 Agent Rule Syntax artisoc User Manual 73 This chapter presents the specifications for the language in which agent rules are expressed in the artisoc If you have no programming experience the learning may be a bit steep but try studying this in conjunction with a commercially available book on syntax The syntax in artiSoc basically follows that of Microsoft Visual Basic 3 1 Overall Structure of Agent Rules Agent rules for every agent are written as follows
69. re However in the rules for agents it is impractical or more accurately is structurally unnatural to define global information for multiple agents although local information about such as an agent itself and its surroundings can be set In such cases we can use Universe at the top of the tree Since the Universe is an agent rules can be declared for it Rules for Universe are often used to survey the agents under Universe and then perform batch processing on them Rules for Universe are often used to perform batch processing on the agents under it Now let s consider the case in which the turtle agents are to be placed on every third location along the X axis What we need in rules for Universe is to know the number of turtle agents created and to assign values to the X variables of the respective agents We will write this into the initial rule of Universe Prog06 model Universe rules Univ Init Dim 1 As Integer For 1 0 To CountAgt Universe Spacel Turtle 1 Universe Spacel Turtle i X 1 3 Next 1 The statements in this code are explained in the following subsections Select File gt artisoc User Manual 25 Save As and save the model as prog06 model 1 5 3 Initially Declaring Variables Used Only Within the Rule The first item to appear is a Dim statement This is called a declaration statement and is used to declare name and type of temporary variables which are used only within that rule When the
70. rse Agent color Selects the color of agents You can select either Fixed color which specifies a single arbitrary color or Variable Specifying Color which specifies a variable to determine the color The latter can change the color dynamically The default agent colors are in the order added red gt blue gt green purple gt light blue gt yellow grey Agent variable information If the Show Information is checked the value of the specified variable will be displayed over the agent on the map Draw lines If the output target agent has an agent set variable then the output target agent and the respective elements in the agent set can be connected with a line The line type arrow etc for the line can be selected 2 Time Series Graph Settings You can display specific components in a time series line graph In the Output Item List dialog select the Time Series Graph from the Type of Output to Add list and click the Add button artisoc User Manual 57 58 Time Series Graph Settings Graph name Time Serios graph 1 Graph title Show legend v Background Color x axis Y axis Axis label l _ Axis label Maximum steps to display 1000 Minimum Oo Step interval 100 Maximum 100 0 Step interwal 10 0 Time series graph element list Edit Delete Cancel Graph name Is the name to reference
71. rule has finished executing these variables are deleted These are called local variables and their use is distinct from that of variables in the component tree 66599 1 which hold values at all times Here an Integer variable 1 is defined in order to specify individual agents Dim statement is used to declare temporary local variables used only within in a rule 1 5 4 Repetition Control The next item to appear is a For Next statement called a repetition control statement This repeats the statements contained in it the specified number of times The number of times to perform the repetition is defined as follows For lt variable name gt lt initial value gt To lt final value gt Step lt increment gt lt items to repeat gt Next lt variable name gt 66599 1 Since the repetition statement s variable 1 is usually increased by 1 each time if Step is omitted then increment is treated as 1 If the Step value is 1 the variable will be decreased by 1 each time To make the structure easy to read indent the items to be repeated by Tab 1 5 5 Determining the Number of Agents Created To determine the number of agents which have been created CountAgt a function provided in artisoc is used Functions are roughly equivalent to those in mathematics When data is supplied to a function the function returns a specific return value result There are built in functions pre defined i
72. s vy Run and Debug O Did you actually configure the artisoc models while following along with this manual And did the simulations run as you expected artisoc User Manual 1 5 Creating a Slightly Complicated Model In this section we will further modify the rules for the back and forth turtle we worked with in Section 1 3 while adding gradually more complicated elements In terms of programming concepts we will learn variable declaration repetition control random numbers functions arrays etc Thus far the atmosphere has been somewhat mechanical but when we incorporate randomness into the rules the agents will be able to move randomly which will result in more agent based model like behavior In addition tips for use in artisoc appear in a variety of places so be careful not to miss them 1 5 1 Resetting the Initial Values for X and Y In ProgO5 model we have set the initial values of the X and Y variables so now clear them Select the variable X from the tree and right click to display the context menu Select Initial Values and return the values to which the X variable has been set 5 10 and 15 back to 0 Also return the initial values for the variable Y to 0 1 5 2 Using the Universe If there are a large number of agents for instance 100 or 200 how can we assign them with initial values in an efficient manner If the agents are to be placed in a regular fashion it would seem effective to write a rule somewhe
73. sed as stand alone statements Functions which are defined as not returning a return value can only be used as stand alone statements They are expressed in the following format artisoc User Manual 83 lt function name gt lt argument 1 gt lt argument2 gt lt argument gt The number of arguments and the type of each argument must match those which have been defined Only variable specifiers can be specified as arguments 3 6 5 Conditional Statements These are statements used to branch processing based on conditions e Ifthe value of the expression is true the block statement will be executed If lt expression gt Then lt block gt End If e Ifthe value of the expression is true then the block 1 will be executed if it is false then the block 2 will be executed If lt expression gt Then lt block 1 gt Else lt block 2 gt End If e Ifthe value of an expression is true the corresponding block will be executed If the values of the expressions are all false block n will be executed If lt expression 1 gt Then lt block 1 gt ElseIf lt expression 2 gt Then lt block 2 gt ElseIf lt expression 3 gt Then lt block 3 gt Else lt block n gt End If 3 6 6 Iteration Statements These are statements for performing processing repeatedly 1 For To Next For Each In Next This is used to perform processing a specific number of times For lt loop variable gt lt initial value gt
74. ssfully configured a simple model but at this point if you click the Start button in the Run Panel only the Console screen is displayed To display something while the simulation is running output settings must be added If you have clicked Start button click the Stop button To run a simulation output settings must be added Select Settings gt Outputs to open Output Item List Output options include Map Time Series Graph Bar Graph Values Screen and Data File Output ltem List Type of output to add Wap Time series Graph Bar Graph values Screen Data File Select Map from the pulldown menu and then click the Add button The Map Settings dialog is displayed Set the Map Name to Two dimensional map_ 1 and set the map title to Spacel artisoc User Manual 13 Map Settings Space name Space Layer Map name Two dimentional_map_1 Map title Space1 Show legend Show ruled lines LJ Background image Background Color Origin loca Upperleft Lower left View Type chess x axis Y axis Axis label Axis label Minimum Minimum 0 Maximum Maximum Map element list Click Add in the Map Element List area The Element Settings dialog is displayed Input Turtle for the Element Name and click OK to close the dialog You have now added Turtle to the Map Element List Element Settings Select 3 Filenam
75. t Link Agent All variables data to file File is output with complying with format as explained in Input File artisoc User Manual Settings Space Variable Run variable tab to arrange Space Variable pace Map Y Layer1 Origin Position Left Top ransparen uled Line S M E 1 Origin Position Lett T lal T t Ruled Li ID 10 1000 HAR K Sows 2 day Akan Point and Link Variable tacne Lommeceals L Aitium du Paks 25 des Congr s Pu al ae oy iy z Mallet Ferio Mailot Z S 2 Setting Object Value x r At af 3 s Minimum Value Maximum Value Setting Value Appoint Method Not Selected Clink Square Line Display List y Point Vv Value a 4 SAAR Select Background Image Delete Background Image Input File Output File Ok Cancel Variable Set the Setting Object Type of Marker color of minimum value and maximum value Settings Value Input the Settings Value in the Space Variables How to specify Specify the operation in a display screen Four methods as unselect click rectangle line are available unselect It doesn t run the Point Agent Placement and Link Agent Connection click rectangle The Settings Value is The Settings Value is Draw line and the input in the Space input in
76. tle Rules Consider Schelling s Segregation Model KKEKKKKKKKK KKK KKK KKK KKK KK KKK KKK KKK KKK KKKKKKKKKEKSK oF 3 10 Error Prevention Measures If a syntactically incorrect rule is entered in the Rule Editor an error will be displayed at the bottom of the window Correct the erroneous rule taking the error message as a hint Moreover you can start simulation line by line by using the debugging function When the value of the variable under debugging describes Print and the PrintLn function on the debug screen while a step in and step over are being started and inputs the Return key the value can be displayed on the console screen For instance on the debug screen when you want to display the value of the variable value of Universe abc under debugging PrintLn Universe abc The value can be confirmed by making it on the console screen Moreover Universe abc 100 Then it is possible to update it for the variable In addition the value can be confirmed by defining an arbitrary variable value by the value screen output of the output setting and debugging it artisoc User Manual
77. to output Write at every steps Specifies the simulation step interval to output Delimiter Selects the delimiter character for the output data Data file element list Lists the target elements When the Add button in the Data File Element List is clicked the following dialog is displayed to set the element of this output If you want to extract the data of multiple elements to the file each of them e g Agentl artisoc User Manual Agent2 Variablel etc must be added to the Data File Element List Using the Edit button in the Data File Element List area any existing element can be edited Also using the Delete button any existing element can be deleted Element Settings Element name Output values Show decimal a digits Element name Is the name of this output element You can enter an arbitrary name Output values Specifies the variables that you want to extract Show decimal digits Specifies the number of digits after the decimal point artisoc User Manual 63 2 2 4 Run Preferences Dialog 64 In this dialog the various settings for running a simulation are defined Select Settings gt Run Preferences to display the Run Preferences dialog There are two tabs Simulation tab Rule Execution tab and Multi Execution tab in this dialog 1 Simulation Tab Run Preferences i Simulation Run Type Multi Type Simulation exit condition Run for steps Run for
78. tton The Font Settings dialog is displayed artisoc User Manual 43 Font Settings Font name Font size _ Bold lia Italic Preview Sample This is sample style Keep output screen open after simulation This setting is not for the Rule Editor If this checkbox is unchecked the output windows will be deleted when the simulation stops The auto indent font etc which have been specified here are immediately reflected in the display of the Rule Editor 2 1 6 Agent Deletion To delete a agent select the agent that you want to delete and either select Edit gt Delete or right click the agent and select Delete 44 artisoc User Manual 2 1 7 New Variable Creation We will next create a new variable in the agent Variables can be created anywhere under an agent Procedure 1 Select the agent here Agent1 to which to add the variable 2 Select Insert gt Add Variable 3 Variable Properties dialog such as the following opens Variable name Variable Properties Variable name Variablet Variable type Integer v History size Dimensions Array elements count of N dimension Cancel Is the name of this variable You can enter an arbitrary name for example Variable1 Variable type A type must be selected which conforms to the data stored in this variable The types are as follows Type Type Name Value Range Boolean Boolean Returns True if true o
79. ual 37 38 Space Properties Space name Space Space type Grid model v Space dimensions Space size x s50 Space size Y Layer End of space C Loop connect with opposite end Don tloop fdead end Space name Is the name of this space You can enter an arbitrary name for example Space1 Space type Selects a space type You can select either Grid model or Hexagon model Space dimensions Is set to 2 to signify two dimensional space Space size Layer Sets the size of the space Space size can be regarded as the number of cells in the grid on which agents occupy or move Specify the maximum X cells in the horizontal direction and Y cells in the vertical direction coordinate and layer count The default values are 50 x 50 x 1 End of space If Loop is checked then when a component reaches a end of the space it will appear on the opposite end If Don t Loop is checked the component will stop at the end of the space 4 Click the OK button The dialog closes and the new space appears in the tree artisoc User Manual Thus we have successfully configured a space directly under Universe Note A space can only be created directly under Universe This specification serves to make the environment conceptually easy to understand 2 1 4 New Agent Creation We will next create a new agent Unlike spaces agents can be created under Universe spaces or other agents in the tree The fol
80. uilding multi agent models completely from scratch Creation process is as follows Component Placement and Settings M Outputs Settings M Agent Rule Declarations M Run and Debug This flow chart will appear many times during the creation process It is good to have a general understanding of what work you are doing at any given time In this section we will also learn conditional branching If statements initial value assignment methods and debugging in terms of important programming concepts Although they are in the early stages as a rule if you are a beginner you should try to familiarize yourself with the programming s distinctive expression and writing methods If you are somewhat experienced you can probably get away with scanning over this section quickly Now let s create a model in which a number of turtles move about Moving Turtle 8 artisoc User Manual Model 1 3 1 About the artisoc Programming Environment Start up artisoc and select File gt New A screen such as the following is displayed New File artisoc File F Edit E View Inserti Settings S Debug D RunfR Logi Window Help H i gt Tree In artisoc the various elements used in simulations are called components The component tree in the Tree window shows hierarchical structure of components in the form of a tree diagram A single Universe always exists at the top of tree Spaces Agents Variables etc wil
81. unfamiliar GetWidthSpace and GetHeightSpace are functions used to obtain the width and height respectively of the space Using these will allow us for example to change the size of the space at any time without having to change the rules Setting program up such you use functions to obtain values even constant values which are supplied once and do not change which might be changed via properties will serve to increase the generality of your rules and also decrease errors GetWidthSpace obtains the width of the space GetHeightSpace obtains the height of the space As an application of these try rewriting the code from Subsection 1 6 1 for randomly arranging agents using GetWidthSpace and GetHeightSpace 1 8 Summary of Section 1 4 1 7 In this section let s review the things you have learned through Section 1 4 1 7 1 8 1 Terminology and Methodology L Using Universe rules Dim statement Repetition control For Next statement Functions CountAgt Specifying a component hierarchically Agent s array number Array variables RandomPutAgt Obtaining random integers from 0 to a Branching with a probability of 1 in A Looping the end of space User defined functions Function GetWidthSpace GetHeightSpace peal ee SP Ded Tels ES fT cP fey eft Pe sft si artisoc User Manual 33 1 8 2 Checklist O Were you able to read and comprehend what sorts of processing will be perfor
82. up this output 60 artisoc User Manual Values title Is displayed in the values window Values element list Lists the target elements When the Add button in the Values Element List area is clicked the following dialog is displayed to set the element of this output If you want to display multiple elements on the screen each of them e g Agent Agent2 Variablel etc must be added to the Values Element List Using the Edit button in the Values Element List area any existing element can be edited Also using the Delete button any existing element can be deleted Element Settings Element name Output values Show decimal a digits Element name Is the name of this output element You can enter an arbitrary name Output values Specifies the elements variables formulas etc that you want to watch Show decimal digits Specifies the number of digits after the decimal point 5 Data File Settings You can extract the simulation data of the specified components to a file In the Output Item List dialog select the Data File from the Type of Output to Add list and click the Add button artisoc User Manual 61 62 Data File Settings Output name Filename Write at every steps Delimiter Tab O Comma Space G Other Data file element list Output name Is the name to reference when calling up this output Filename Specifies the name of the file to which
83. y running a model and got one result Now let s try to elicit different results by changing the settings 1 2 1 Reconfiguring Components Let s try changing the space size In the previous simulation the walkers were moving around on two dimensional space consisting of a 50x50 square grid Now let s try changing this to a 100x25 grid The procedure is as follows 4 artisoc User Manual Select and right click TwoDimensionalSpace in the tree and select Properties from the menu The following screen is displayed Space Properties Space name TwobimensionalSpace Space type Grid model ha Space dimensions Space size x Space size Y Layer End of space Loop fconnect with opposite end 2 Don t loop fdead end Change the Space Size X field from 50 to 100 and the Space Size Y field from 50 to 25 artisoc User Manual 5 1 2 2 Reconfiguring Output Next let s try changing two settings for the time series graph Make the lines thicker and add markers Select Settings gt Outputs The following screen is displayed Output Item List Elspace Map ca Time Series Graph of Red Walkers Add gA Edit E Copy iC Delete Di Tyne ofoutputtoads Wap O O Make the red walker count graph easier to read by adding markers to the vertices of the lines and by making the lines thicker Select Time Series Graph of Red Walkers from the list and click the Edit button The following Time Series Graph S
84. y step So the turtle which started in the left hand corner will move to the right hand corner and stop moving due to the dead end of the space The simulation itself appears to be stopped but the turtle repeats the attempt to move at every step of the simulation Click the Stop button to stop the simulation Select File gt Save As on the menu bar and save the model as prog02 model artisoc User Manual 17 1 3 9 Creating an Agent which Moves Back and Forth on the Map 18 1 Add a Variable in the Agent Let s try modifying the bullet turtle to move back and forth on the two dimensional map Think for a moment about how the rule should be changed Basically what we want is If a end of map is reached change direction however with just the agent s X and Y coordinates we cannot ascertain its direction and here we don t use the Direction variable to control direction In light of this we will add to the turtle agent a new variable which uses positive and negative values to indicate the direction in which the turtle is advancing Select the Turtle in the component tree and right click to display the context menu Select Add Variable from the menu to display Variable Properties dialog Set the Variable Name to DIRX Variable Type to Integer and Dimensions to 0 Click OK 2 Add a Conditional Branching Rule Let s try writing out the rules before expressing them in code e Initial rule Set DIRX to 1
Download Pdf Manuals
Related Search
Related Contents
CRF 450X / 2006 - Motorock SC443 取扱説明書 Samsung WB250F Kasutusjuhend User Manual Interface lipido-colloïde non occlusive Digital Recorder Copyright © All rights reserved.
Failed to retrieve file