ShoeFactory - PheromoneApproach
Model was written in NetLogo 6.0
•
Viewed 190 times
•
Downloaded 15 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
globals [tsize all-resources mylist sole-link-set head-link-set design-link-set finishing-link-set task world-condition newlist num num-produced] breed [shoe-orders shoe-order] breed [sole-makers sole-maker] breed [shoe-head-makers shoe-head-maker] breed [design-makers design-maker] breed [shoe-finishings shoe-finishing] breed [dispatches dispatch] breed [shoe-shippings shoe-shipping] breed [new-orders new-order] undirected-link-breed [borders border] patches-own [task-color cx] shoe-orders-own [orders-set ] sole-makers-own [sole-set] shoe-head-makers-own [head-set] design-makers-own [design-set] shoe-finishings-own [finishing-set] dispatches-own [dispatch-set] new-orders-own [ new-order-set found-shoe order-plan next-plan plan plan-index exit prev-plan] borders-own [border-tikness] to set-parameters ask new-orders [set found-shoe 0] ask patches [set task-color 45 ] ask new-orders [set plan-index 0] ask new-orders [set exit 0] set num-produced 0 end to setup clear-all ;set-parameters write-up setup-patches create-resources setup-links create-orders ;set-default-shape borders "boundary" reset-ticks end to go move-orders sence-pheromone ;drop-pheromone shipping fade-signals terminate-production tick end to setup-patches ask patches [set pcolor white] end to write-up ask patch 14 20 [set plabel "Mass Customization - Coordination Model | Shoe Production Secenarion" set plabel-color black] ask patch -19 16 [set plabel (word "Shoe Sole Makers") set plabel-color black] ask patch -19 -17 [set plabel (word "Shoe Head Makers") set plabel-color black] ask patch 20 -17 [set plabel (word "Shoe Gumming") set plabel-color black] ask patch 20 17.5 [set plabel (word "Design Makers") set plabel-color black] ask patch -20 0 [set plabel (word "Order Generators") set plabel-color black] ask patch 25 0 [set plabel (word "Dispatchers") set plabel-color black] ask patch 24 18 [set plabel (word "Shipping") set plabel-color black] ask patch 24 -18 [set plabel (word "Shipping") set plabel-color black] end to create-resources set tsize 2 (foreach [3 -3] [ [x] -> create-shoe-orders 1[ set shape "circle" set color green set xcor -22 set ycor x ;set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) (foreach [3 -3 3] [ [x] -> create-dispatches 1[ set shape "letter sealed" set xcor 23 set ycor x set color white set label "free" set size 2 set pcolor black ask neighbors [set pcolor black] ]]) (foreach [ -19 -16 -13 ][13 15 17] [ [x y] -> create-sole-makers 1[ set shape "square" set color red set xcor x set ycor y set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) (foreach [ 13 16 19 ] [17 15 13] [ [x y] -> create-design-makers 1[ set shape "triangle" set color blue set xcor x set ycor y set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) (foreach [ -19 -16 -13 ] [-13 -15 -17] [ [x y] -> create-shoe-head-makers 1[ set shape "star" set color yellow set xcor x set ycor y set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) (foreach [ 13 16 19 ] [-17 -15 -13] [ [x y] -> create-shoe-finishings 1[ set shape "pentagon" set color magenta set xcor x set ycor y set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) (foreach [23 23] [ 15 -15] [ [x y] -> create-shoe-shippings 1[ set shape "truck" set xcor x set ycor y ;set label "free" set pcolor black set size tsize ask neighbors [set pcolor black] ]]) end to setup-links ; Creating link in-between turtles-breed set sole-link-set get-resource-list (sole-makers) ask item 0 sole-link-set [create-links-with other sole-makers] set head-link-set get-resource-list (shoe-head-makers) ask item 0 head-link-set [create-links-with other shoe-head-makers] set design-link-set get-resource-list (design-makers) ask item 0 design-link-set [create-links-with other design-makers] set finishing-link-set get-resource-list (shoe-finishings) ask item 0 finishing-link-set [create-links-with other shoe-finishings] ; Creating link between different turtles-breeds ask last sole-link-set [create-link-with first design-link-set] ask first sole-link-set [create-link-with first head-link-set] ask last head-link-set [create-link-with first finishing-link-set] ask last finishing-link-set [create-link-with last design-link-set] end to plan-assignment-1 ;set order-plan (list (random 4) (random 4) (random 4)) set plan item plan-index order-plan set next-plan get-plan(plan) set color [color] of one-of next-plan set task-color [color] of one-of next-plan ;set task-color plan-color(plan) ;face one-of next-plan ;show task-color set-shape get-random-direction ;show order-plan end to set-shape ask new-orders [ ifelse plan-index = 0 [set shape "shoe_1"][ ifelse plan-index = 1 [set shape "shoe_2"][ ifelse plan-index = 2 [set shape "shoe_3"][shipping]]]] end to-report get-plan [new-plan] ifelse (new-plan = 0 and not any? sole-makers-on neighbors ) [report sole-makers][ ifelse (new-plan = 1 and not any? shoe-head-makers-on neighbors ) [report shoe-head-makers][ ifelse (new-plan = 2 and not any? design-makers-on neighbors ) [report design-makers][ ifelse (new-plan = 3 and not any? shoe-finishings-on neighbors ) [report shoe-finishings][report shoe-finishings]]]] ;ifelse (new-plan = 3 and not any? shoe-finishings-on neighbors ) [report shoe-finishings][plan-assignment-1]]]] ;if (new-plan = 3 and not any? shoe-finishings-on neighbors ) [report shoe-finishings]]]] end ;to-report find-direction ;end to-report plan-color [resource-color] if (resource-color = 0 ) [report red] if (resource-color = 1 ) [report yellow] if (resource-color = 2 ) [report blue] if (resource-color = 3 ) [report magenta] end to create-orders ask one-of shoe-orders [ hatch-new-orders 1 [ set order-plan (list (random 4) (random 4) (random 4)) set color gray set size 5 set shape "default" set heading 90 fd 5 show order-plan ;get-random-direction-1 plan-assignment-1 ]] end to move-orders ; ask new-orders [ ; ifelse ([pcolor] of patch-ahead 1 != black) and (ycor <= 17 and ycor >= -17 and xcor <= 18 and xcor >= -18) [fd 0.2][ ; ifelse ([pcolor] of patch-ahead 1 = black and exit = 0)[if any? next-plan in-cone 3 90 [ set found-shoe found-shoe + 1 next-plan-execution]][ ; ifelse (exit = 1)[set found-shoe 0 fd 0.2] [get-random-direction set found-shoe 0]]]] ;ask new-orders [if (found-shoe = 1) [ask patch-at-heading-and-distance 0 0 [set pcolor task-color] next-plan-execution]] let num-shoe-orders count new-orders ask one-of shoe-orders [if order-number > num-shoe-orders + num-produced [create-orders]] ask new-orders [ if ([pcolor] of patch-ahead 1 = black)[if any? next-plan in-cone 5 120 [set found-shoe found-shoe + 1 set num found-shoe set prev-plan next-plan next-plan-execution]]] ask new-orders [ if (found-shoe >= 1) [drop-pheromone]] ask new-orders [ifelse ([pcolor] of patch-ahead 1 != black) and (ycor <= 17 and ycor >= -17 and xcor <= 18 and xcor >= -18) [fd 0.2][ ifelse (exit = 1)[set found-shoe 0 fd 0.2 set num found-shoe] [get-random-direction set found-shoe 0 set num found-shoe]]] ;sence-pheromone end to sence-pheromone if (sense-pheromone?)[ ;let color1 [pcolor] of patch-ahead 1 ;ask new-orders [if ([pcolor] of patch-ahead 1 >= task-color and [pcolor] of patch-ahead 1 <= task-color + 4.5 and exit = 0)[face one-of next-plan]] ask new-orders [if ([pcolor] of patch-ahead 1 >= [color] of self and [pcolor] of patch-ahead 1 <= [color] of self + 4.5 and exit = 0)[face one-of next-plan]] ] end to drop-pheromone set task-color [color] of one-of prev-plan set pcolor task-color end to execute-plan ask patch-at-heading-and-distance 0 0 [set pcolor grey] next-plan-execution end to next-plan-execution ifelse (plan-index < 2) [set plan-index plan-index + 1 plan-assignment-1][set color green set exit 1 face one-of dispatches fd 0.2 ] end to shipping ask new-orders [if any? dispatches-on neighbors[ set plan-index 3 set shape "shoe_box" face min-one-of shoe-shippings [distance myself] fd 0.1]] end to terminate-production ask new-orders [if any? shoe-shippings-on neighbors[ set num-produced num-produced + 1 die]] end to do-task set task yellow ask new-orders [ if any? shoe-head-makers-on neighbors[ set color yellow ask patch-at-heading-and-distance 0 1 [set pcolor yellow]] ] end to fade-signals ask patches [set cx task-color + 4.9] ask patches [if (pcolor <= precision cx 8 and pcolor >= precision task-color 8) [set pcolor pcolor + pheromone-difusion-rate]] end to get-random-direction ;do-task set heading heading + 180 fd 0.2 get-random-direction-1 fd 0.2 end to get-random-direction-1 set heading random 360 end to-report get-resource-list [resource-name] report sort (resource-name) end to test show get-resource-list (sole-makers) ;show sole-set end to setup-caller setup-links end
There are 4 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
ShoeFactory - PheromoneApproach.png | preview | Preview for 'ShoeFactory - PheromoneApproach' | almost 7 years ago, by Rotimi Ogunsakin | Download |
This model does not have any ancestors.
This model does not have any descendants.