How law decrees influence the world of restaurants
Model was written in NetLogo 6.2.0
•
Viewed 198 times
•
Downloaded 12 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Click to Run Model
breed [healthies healthy] ;;Different breeds of turtles to show heatlh state. breed [infecteds infected] breed [sicks sick] breed [immunes immune] breed [deads dead] breed [restaurants rest] breed [hospitals hosp] globals [ ;; Global variables. total-healthy total-sick total-infected total-immune total-dead total-wealth total-cost Cost rti check-seats total-income seats0 seats1 seats2 seats3 flag immune-chance-after immune-chance-before ] turtles-own [ ;; Turtle variables. incubate sickness terminal-check immune-check money x y turn-check ] restaurants-own [ ;; patches variables. max-people fixed-cost1 fixed-cost2 fixed-cost3 fixed-cost4 income0 income1 income2 income3 ] to setup ;; Initialize the model. clear-all clear-turtles reset-ticks set immune-chance-after 83 set immune-chance-before random 10 create-restaurants 1 [setxy -12 14 set size 3 set shape "house" set color magenta set fixed-cost1 random-float 200 set seats0 22] create-restaurants 1 [setxy -13 -8 set size 3 set shape "house" set color turquoise set fixed-cost2 random-float 450 set seats1 38 ] create-restaurants 1 [setxy 12 14 set size 3 set shape "house" set color brown set fixed-cost3 random-float 300 set seats2 22] create-restaurants 1 [setxy 15 -10 set size 3 set shape "house" set color red set fixed-cost4 random-float 675 set seats3 52 ] create-hospitals 1 [setxy 1 -14 set size 8 set shape "hospital" set color white ] set w-par 50 set y-par 150 set o-par 250 update-plot1 setup-agents set Cost total-cost update-globals first-plot end to go ;; Run the model. disease-check repeat 7 [ ask healthies [ fd 1 ] display ] repeat 7 [ ask infecteds [ fd 1 ] display ] repeat 7 [ ask immunes [ fd 1 ] display ] goal update-plot1 rt-index places tick update-globals first-plot randomize end to-report tot report sum [fixed-cost1 + fixed-cost2 + fixed-cost3 + fixed-cost4] of restaurants end to update-plot1 set total-cost tot end to places ask rest 0 [ show "number of clients " show count turtles-here - 1 show "available seats" show seats0 set check-seats count turtles-here - 1 ifelse check-seats > seats0 [show "available seats limit exceeded, calculating the maximum possible profit ..." set income0 seats0 * 20 show "income of restaurant is -->" show income0 ] [show "seats still available" set income0 check-seats * 20 show "income of restaurant is -->" show income0] stop] ask rest 1 [ show "number of clients " show count turtles-here - 1 show "available seats" show seats1 set check-seats count turtles-here - 1 ifelse check-seats > seats1 [show "available seats limit exceeded, calculating the maximum possible profit ..." set income1 seats1 * 20 show "income of restaurant is -->" show income1 ] [show "seats still available" set income1 check-seats * 20 show "income of restaurant is -->" show income1] stop] ask rest 2 [ show "number of clients " show count turtles-here - 1 show "available seats" show seats2 set check-seats count turtles-here - 1 ifelse check-seats > seats2 [show "available seats limit exceeded, calculating the maximum possible profit ..." set income2 seats2 * 20 show "income of restaurant is -->" show income2 ] [show "seats still available" set income2 check-seats * 20 show "income of restaurant is -->" show income2] stop] ask rest 3 [ show "number of clients " show count turtles-here - 1 show "available seats" show seats3 set check-seats count turtles-here - 1 ifelse check-seats > seats3 [show "available seats limit exceeded, calculating the maximum possible profit ..." set income3 seats3 * 20 show "income of restaurant is -->" show income3 ] [show "seats still available" set income3 check-seats * 20 show "income of restaurant is -->" show income3] stop] set total-income sum [income0 + income1 + income2 + income3 ] of restaurants show total-income end to setup-agents ;; Setup the begining number of agents and their initial states. set-default-shape healthies "person" set-default-shape infecteds "person" set-default-shape sicks "person" set-default-shape immunes "person" set-default-shape deads "person" ask n-of initial-healthy patches [ sprout-healthies 1 [ set color blue set money 20] ] ask n-of initial-infecteds patches [ sprout-infecteds 1 [ set color red set incubate random 14 set money 20] ] ask n-of vaccinated patches [ sprout-immunes 1 [ set color green set money 20] ] end to disease-check ;; Check to see if an infected or sick turtle occupies the same patch. ask healthies [ if any? other turtles-here with [color = yellow] [infect] if any? other turtles-here with [color = red] [infect] wander ] ask sicks [ if any? other turtles-here with [color = blue] [infect] set sickness sickness - 1 if sickness < 1 [live-or-die] ] ask infecteds [ if any? other turtles-here with [color = blue] [infect] wander set incubate incubate - 1 if incubate = 0 [get-sick] ] ask immunes [wander] end to goal ask turtles with[ shape = "person" and color != grey and color != yellow][ set x max-one-of turtles with [shape = "house" and color != white ][distance myself] face x set y distance x while [y > 1] [ fd 1 display set y y - 1 ] if y < 1 [ eat ] ] ask turtles with [ shape = "person" and color = yellow][ set x max-one-of turtles with [shape = "hospital" and color = white ][distance myself] face x set y distance x while [y > 1] [ fd 1 display set y y - 1 ] ] end to rt-index set rti((count sicks + count infecteds) / (count healthies + count immunes + count sicks + count infecteds)) let q (count healthies + count immunes + count sicks + count infecteds) * w-par / 100000 let w (count healthies + count immunes + count sicks + count infecteds) * y-par / 100000 let r (count healthies + count immunes + count sicks + count infecteds) * o-par / 100000 if rti >= 0 and rti < q [ show "WHITE ZONE" ask rest 0 [ set seats0 22] ask rest 1 [set seats1 38] ask rest 2 [set seats2 22] ask rest 3 [set seats3 52] set flag 1] if rti >= q and rti <= w [ ask rest 0 [ set seats0 22] ask rest 1 [set seats1 38] ask rest 2 [set seats2 22] ask rest 3 [set seats3 52] set seats0 seats0 / 2 set seats1 seats1 / 2 set seats2 seats2 / 2 set seats3 seats3 / 2 if flag < 2 [ show "YELLOW ZONE" ask rest 0 [ set seats0 22] ask rest 1 [set seats1 38] ask rest 2 [set seats2 22] ask rest 3 [set seats3 52] set seats0 seats0 / 2 set seats1 seats1 / 2 set seats2 seats2 / 2 set seats3 seats3 / 2 set flag 2] show "YELLOW ZONE" ] if rti > w and rti <= r [ if flag < 3 [ show "ORANGE ZONE" show "only take away." set seats0 seats0 / 2 set seats1 seats1 / 2 set seats2 seats2 / 2 set seats3 seats3 / 2 set flag 3] show "ORANGE ZONE" show "only take away." ] if rti > r [ show "INDEX GREATER THAN MAX " show "---->" show "RED ZONE" show "only take away"] show ((count sicks + count infecteds) / (count healthies + count immunes + count sicks + count infecteds)) end to randomize ask turtles with[ shape = "person" and color != grey and color != yellow][ face patch 0 0 repeat 2 [ ask healthies [ fd 0.2 ] display ] repeat 2 [ ask infecteds [ fd 0.2 ] display ] repeat 2 [ ask immunes [ fd 0.2 ] display ] fd random-float 20 rt random-float 20 lt random-float 20 restore ] end to eat while [money > 0][ show " at the restaurant" set money money - 1 ] end to restore set money 20 end to infect ;; Infect a healthy turtle, test if it is immune and set the incubation timer if it isn't. set immune-check random 100 ifelse immune-check < immune-chance-before [recover] [ask healthies-on patch-here[ set breed infecteds set incubate random 14] ask infecteds-on patch-here [set color red]] end to get-sick ;; Change an infected turtle into an sick turtle and set the disease progression timer. set breed sicks set color yellow set sickness disease-period end to terminate ;; Kill a sick turtle who reaches the end of the disease progression and fails the terminal check. set breed deads set color grey fd -1 end to live-or-die ;; Test if the turtle dies from the disease. set terminal-check random 100 ifelse terminal-check < terminal-chance [terminate] [recover] end to recover ;; Change turtle breed to immune. set immune-check random 100 if immune-chance-after > immune-check [set breed immunes set color green] if immune-chance-after < immune-check [set breed healthies set color blue] end to update-globals ;;Set globals to current values for reporters. set total-healthy (count healthies) set total-infected (count infecteds) set total-sick (count sicks) set total-immune (count immunes) set total-dead (count deads) end to wander ;; Random movement for agents. set turn-check random 20 if turn-check > 15 [right-turn] if turn-check < 5 [left-turn] end to right-turn ;;Generate a random degree of turn for the wander sub-routine. rt random-float 20 fd random-float 20 end to left-turn ;;Generate a random degree of turn for the wander sub-routine. lt random-float 20 fd random-float 20 end to first-plot ;; Update graph. set-current-plot "Population Totals" set-current-plot-pen "Healthy" plot total-healthy set-current-plot-pen "Infected" plot total-infected set-current-plot-pen "Sick" plot total-sick set-current-plot-pen "Immune" plot total-immune set-current-plot-pen "Dead" plot total-dead end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
How law decrees influence the world of restaurants.png | preview | Preview for 'How law decrees influence the world of restaurants' | almost 3 years ago, by alberto gavazzi | Download |
how the law decrees influence the world of restaurants.pdf | Description of the work | almost 3 years ago, by alberto gavazzi | Download |
This model does not have any ancestors.
This model does not have any descendants.