Task-Switching
Model was written in NetLogo 5.2.0
•
Viewed 383 times
•
Downloaded 24 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
breed [tasks a-task] breed [astronauts astronaut] tasks-own [ duration ;; how many ticks it takes to complete a task complete? ;; whether or not the task is completed ;Task Factors difficulty ;; difficulty of a task between 0 (easiest) and 1 (most difficult) priority ;; importance of a task between 0 (unimportant) and 1 (extremely important) salience ;; salience of a task between 0 (not salient) and 1 (very salient) interest ;; interest level of a task between 0 (boring) and 1 (super interesting) ;Task Factors influence Task Attractiveness attractiveness ;; overall task attractiveness based on difficulty, priority, salience and interest ] astronauts-own [ ongoing-task ;; WHO number of the task currently being worked on alternate-tasks ;; WHO number(s) of all other tasks num-switches ;; how many times an astronaut has switched tasks target ] globals [ switch-count ;; total count of every time an astronaut has switched tasks num-tasks ;; total number of mission tasks num-astronauts ;; total number of astronauts on the mission ] to reset-mission ;; "setup" procedure clear-all reset-ticks end to add-task ;; task setup procedure (must be done before adding astronauts) if num-tasks = world-width [ user-message (word "You've created the maximum number of tasks allowed for this mission!") stop ] create-tasks 1 [set color blue ;; TO DO - create color scheme based on task attractiveness set shape "computer workstation" set xcor random-pxcor set duration task-duration set difficulty task-difficulty set salience task-salience set priority task-priority set interest task-interest set complete? false set heading 90 set label duration calculate-attractiveness] separate-tasks set num-tasks num-tasks + 1 ask astronauts [ refresh-my-tasks ] ;; in case the user adds more tasks after creating astronauts end to calculate-attractiveness set attractiveness ((difficulty + salience + priority + interest) / 4) end to separate-tasks ;; spaces out the tasks for better visualization ask tasks [if any? other tasks-here [ fd 1 separate-tasks ] ] end to add-astronaut ;; astronaut setup procedure (cannot be done until at least one task is created) if not any? tasks [ user-message (word "You must add at least one task before adding astronauts!") stop ] if num-astronauts = 6 [ user-message (word "You've assigned the maximum number of astronauts allowed to this mission!") stop ] create-astronauts number-of-astronauts [ set color white set shape "person" set size 1.5 setxy random-pxcor random-pycor set num-switches 0 create-link-to one-of tasks ;; link to any task set num-astronauts num-astronauts + 1 refresh-my-tasks] ask astronauts [ if count tasks with [complete? = false] > 1 [ set target one-of tasks with [not member? WHO [ongoing-task] of myself and complete? = false] ] ] ask links [ set color ([color] of end2) ] ;; for better visualization end to refresh-my-tasks ;; determines an astronaut's ongoing and alternate tasks set ongoing-task [WHO] of out-link-neighbors ask out-link-neighbors [ let nauts-on-task [WHO] of in-link-neighbors ask in-link-neighbors [ set alternate-tasks [WHO] of tasks with [nauts-on-task != [WHO] of in-link-neighbors] ] ] end to start-mission ;; "go" procedure if num-tasks = 0 [ user-message (word "You haven't created any tasks yet!") stop ] if num-tasks > 0 and num-astronauts = 0 [ user-message (word "You haven't created any astronauts yet!") stop ] if all? tasks [complete? = true] ;; once all tasks are complete, stop simulation [stop] ask astronauts [ ;; ensures astronauts are working on an incomplete task if [complete?] of one-of out-link-neighbors = true [ ask my-out-links [die] create-link-to one-of other tasks with [complete? = false] set num-switches num-switches + 1 ] ] task-switch ;; KEY PROCEDURE ask tasks with [ any? in-link-neighbors ] [ ;; any task with an astronaut working on it reduces its duration by 1 set duration duration - 1 set label duration ] update-tasks ;; check whether or not a task is complete ask astronauts [ refresh-my-tasks ] set switch-count sum [num-switches] of astronauts ;;BROKEN tick end to task-switch ask astronauts [ if count tasks with [complete? = false] > 1 [ set target one-of tasks with [not member? WHO [ongoing-task] of myself and complete? = false] ;; choose a hypothetical alternate task to consider switching to ifelse [difficulty] of one-of out-link-neighbors > .5 ;; .51 represents a task that is more difficult than 51% of other tasks [ask astronauts [ if random-float 100 > ( ((((( [difficulty] of one-of out-link-neighbors) * 100) - 50) * .68) + 66) ) [ ;; the more difficult the task, the less likely an astronaut is to consider a switch if [attractiveness] of target > [attractiveness] of one-of out-link-neighbors ;; 1st: attractiveness of the alternate task must be higher than ongoing task to induce a switch and random-float 1 < ([attractiveness] of target) [ ;; 2nd: even if the alternate task is more attractive, there is still a chance a switch will not happen ask my-out-links [die] create-link-to target ;; start working on alternate task (alternate task becomes ongoing task) set num-switches num-switches + 1] ;;BROKEN ] ] ] [ask astronauts [ if random-float 100 > 66 [ ;; tasks with a difficulty below .5 are classified as "easy" and are treated equal regardless of level if [attractiveness] of target > [attractiveness] of one-of out-link-neighbors ;; 1st: attractiveness of the alternate task must be higher than ongoing task to induce a switch and random-float 1 < ([attractiveness] of target) [ ;; 2nd: even if the alternate task is more attractive, there is still a chance a switch will not happen ask my-out-links [die] create-link-to target ;; start working on alternate task (alternate task becomes ongoing task) set num-switches num-switches + 1] ;;BROKEN ] ] ] ] ] ask links [ set color ([color] of end2) ;; for better visualization ] end to update-tasks ask tasks with [complete? = false] [ if duration <= 0 [ set complete? true set color color - 3 ] ] end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Task-Switching.png | preview | Preview for 'Task-Switching' | almost 10 years ago, by Eric Forbush | Download |
This model does not have any ancestors.
This model does not have any descendants.