ShoeFactory - StigmergyApproach

ShoeFactory - StigmergyApproach preview image

1 collaborator

Default-person Rotimi Ogunsakin (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0 • Viewed 254 times • Downloaded 24 times • Run 0 times
Download the 'ShoeFactory - StigmergyApproach' modelDownload this modelEmbed this model

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 shortest agent-list resource-board active-r-agent updated-resource status-position
  direction mylist something required-update active-agent new-update required-update-index
sole-makers-bb shoe-head-makers-bb shoe-finishings-bb design-makers-bb dispatches-bb a-agent
resource-stat f-resource-index  f-index any-r-agent second-r-agent resource-index third-r-agent
first-r-agent resource-to-release reset-resource r-index shipping-val negotiation action sm sh sf dm utility total-orders text-color]

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]

shoe-orders-own [shoe-orders-direction]
sole-makers-own [sole-makers-direction]
shoe-head-makers-own [shoe-head-makers-direction]
design-makers-own [design-makers-direction]
shoe-finishings-own [shoe-finishings-direction]
dispatches-own [dispatches-direction]
new-orders-own [task sub-task]

to setup
  clear-all
  setup-patches
  create-resources
  create-orders
  create-resource-blackboard
  ;create-factory-layout
  ;agent-direction
  reset-ticks
  ;set direction 1
  write-up
end 

to write-up
  ask patch 14 19 [set plabel "Mass Customization - Coordination Model | Shoe Production Secenarion" set plabel-color text-color]
  ask patch -11 15 [set plabel (word "Shoe Sole Makers") set plabel-color text-color]
  ask patch -11 -15 [set plabel (word "Shoe Head Makers") set plabel-color text-color]
  ask patch 16 -15 [set plabel (word "Shoe Gumming") set plabel-color text-color]
  ask patch 16 15 [set plabel (word "Design Makers") set plabel-color text-color]
  ask patch -19 0 [set plabel (word "Order Generators") set plabel-color text-color]
  ask patch 25 0 [set plabel (word "Dispatchers") set plabel-color text-color]
  ask patch 24 18 [set plabel (word "Shipping") set plabel-color text-color]
  ask patch 24 -18 [set plabel (word "Shipping") set plabel-color text-color]
end 

to go
  if ( total-orders = ceiling (shipping-val * 12)) [stop]
  move-orders
  procedure-caller
  tick
end 

to setup-patches
  ifelse background? [ask patches [set pcolor blue + 1 set text-color white]][ask patches [set pcolor white set text-color black]]
end 

to create-resources

  set tsize 2
  (foreach [3 -3] [ [x] -> create-shoe-orders 1[
    set shape "circle"
    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 [ -16 -12 -8 ][9 12 15] [ [x y] -> create-sole-makers 1[
    set shape "square"
    set xcor x
    set ycor y
    set label "free"
    set pcolor black
    set size tsize
    ask neighbors [set pcolor black]
  ]])

(foreach [ 8 12 16 ] [15 12 9] [ [x y] -> create-design-makers 1[
    set shape "triangle"
    set xcor x
    set ycor y
    set label "free"
    set pcolor black
    set size tsize
    ask neighbors [set pcolor black]
  ]])

(foreach [ -16 -12 -8 ] [-9 -12 -15] [ [x y] -> create-shoe-head-makers 1[
    set shape "star"
    set xcor x
    set ycor y
    set label "free"
    set pcolor black
    set size tsize
    ask neighbors [set pcolor black]
  ]])

(foreach [ 8 12 16 ] [-15 -12 -9] [ [x y] -> create-shoe-finishings 1[
    set shape "pentagon"
    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 create-factory-layout
  ;ask patches [if pycor < 6 and pycor > -6 [ set pcolor 93 ]]
end 

to create-resource-blackboard
  ;set resource-board [[0 0 0][1 0 0][2 0 0][3 0 0][4 0 0]]
  set sole-makers-bb [1 0 0 0]
  set shoe-head-makers-bb [2 0 0 0]
  set shoe-finishings-bb [3 0 0 0]
  set design-makers-bb [4 0 0 0]
  ;set dispatches-bb [5 0 0 0]
  set required-update [0 0 0 0]
  set resource-index [0 0 0 0]
  set shipping-val 0
  set negotiation 1
  set action 0
  set sm 0
  set sh 0
  set dm 0
  set dm 0
  set utility 1
  set total-orders 1
end 

to-report resource-status [resource-agent-name]
  ifelse (resource-agent-name = sole-makers)[report sole-makers-bb][
    ifelse (resource-agent-name = shoe-head-makers)[report shoe-head-makers-bb][
      ifelse (resource-agent-name = shoe-finishings)[report shoe-finishings-bb ][
        ifelse (resource-agent-name = design-makers)[report design-makers-bb][report dispatches-bb]]]]
end 

to procedure-caller
  set resource-stat update-resource-status (a-agent)
  final-update
  resource-status-update
  ;set reset-resource resource-status-update(a-agent)
end 

to-report get-index [resource]
  ;set resource-index sort (resource)
  set f-resource-index position resource resource-index
  if f-resource-index != false [
  set f-index f-resource-index + 1
  report f-index]
  report f-index
end 

to-report update-resource-status [resource-to-update]
  set required-update resource-status (a-agent)
  set active-agent [who] of active-r-agent
  set required-update-index get-index(active-r-agent)
  set required-update replace-item required-update-index required-update active-agent
  ;ask active-r-agent [show required-update]
  ;set action action + 1
  report required-update
end 

to resource-status-update ;[resource-to-update] ; £££££££££££££££
  ask a-agent [if label = "free" and any? new-orders in-radius 3 [
    set resource-to-release required-update ; resource-status(a-agent)
  ;set r-index 1
  if item 1 resource-to-release > 0 [set resource-to-release replace-item 1 resource-to-release 0]
  if item 2 resource-to-release > 0 [set resource-to-release replace-item 2 resource-to-release 0]
  if item 3 resource-to-release > 0 [set resource-to-release replace-item 3 resource-to-release 0]
  set required-update resource-to-release
  show resource-to-release
  ;report resource-to-release
  final-update]]
end 

to final-update
  ask active-r-agent[ if any? new-orders in-radius 3 [
      set action action + 1 / 12
  ifelse (first required-update = 1)[set sole-makers-bb required-update show required-update set sm sm + 1 / 12][
    ifelse (first required-update = 2)[set shoe-head-makers-bb required-update show required-update set sh sh + 1 / 12 ][
      ifelse (first required-update = 3)[set shoe-finishings-bb required-update show required-update set sf sf + 1 / 12][
        ifelse (first required-update = 4)[set design-makers-bb required-update show required-update set dm dm + 1 / 12][
          if (first required-update = 5)[set dispatches-bb required-update show required-update]]]]]]]
end 

to-report show-update [update-to-show]
  set update-to-show required-update
  show update-to-show
end 

to-report get-resource-arrays [resource-type]
end 

to test
  ;let new-active-r-agent active-r-agent
  ;show resource-status (new-active-r-agent)
  ;set something  update-resource-status (a-agent)
  ;show something
  ;set resource-to-release required-update
  ;show resource-to-release
  resource-status-update
end 

to create-orders
  ;set agent-list ["sole-makers"]
  ask  one-of shoe-orders [hatch-new-orders 1 [
  set task random 50 + 50
  set sub-task random 10
  set shape "sole_1"
  set size 5
  set label (word sub-task "|" task)
  set label-color black
  set color green + random 5
  let ndirection 1 + random 4
  if ndirection = 1 [ face one-of sole-makers ]
  if ndirection = 2 [ face one-of shoe-head-makers ]
  if ndirection = 3 [ face one-of shoe-finishings ]
  if ndirection = 4 [ face one-of design-makers ]
  fd 0.5]
  ]
end 

;to-report solemakers
;  report sole-makers
;end

to move-orders
  let num-shoe-orders count new-orders
  ask one-of shoe-orders [if num-shoe-orders < product-agent and max-orders > total-orders [create-orders set total-orders total-orders + 1]]
   ask new-orders [if pcolor != black [fd 0.5]
    ifelse any? dispatches-on neighbors[
      set shape "shoe_box"
      face min-one-of shoe-shippings  [distance myself]
      labelling
      fd 0.5][
      if pcolor = black[
        set sub-task sub-task + random 10
        set label (word sub-task "|" task)
        labelling
        get-direction
        fd 0.5]]]
end 

;to move-orders
;  ;let num-shoe-orders ;count new-orders
;  set utility log (negotiation - action) 10
;  ask one-of shoe-orders [if product-agent > (utility) [create-orders]]
;   ask new-orders [if pcolor != black [fd 0.5]
;    ifelse any? dispatches-on neighbors[
;      face min-one-of shoe-shippings  [distance myself]
;      labelling
;      fd 0.5][
;      if pcolor = black[
;        set sub-task sub-task + random 10
;        set label (word task "|" sub-task)
;        labelling
;        get-direction
;        fd 0.5]]]
;end

to labelling
  ask sole-makers-on neighbors [set label "free"]
  ask shoe-head-makers-on neighbors [set label "free"]
  ask shoe-finishings-on neighbors [set label "free"]
  ask design-makers-on neighbors [set label "free"]
  ask dispatches-on neighbors [set label "free"]
  ;ask shoe-shippings-on neighbors [set label "free"]
  ;resource-status-update
end 

to get-direction
  if any? shoe-shippings-on neighbors[set shipping-val shipping-val + 1 / 12  die]
  set direction 1 + random 4
  ifelse (sub-task >= task)[set shape "shoe_3" face min-one-of dispatches [distance myself]][
  ifelse direction = 1 and not any? sole-makers-on neighbors [ face shortest-distance (sole-makers) ][
  ifelse direction = 2 and not any? shoe-head-makers-on neighbors [ face shortest-distance (shoe-head-makers) ][
  ifelse direction = 3 and not any? shoe-finishings-on neighbors[ face shortest-distance (shoe-finishings) ][
    ifelse direction = 4 and not any? design-makers-on neighbors [ face shortest-distance (design-makers)][get-direction]]
  ]]]
end 

to-report shortest-distance [distance-agent]
  if (sub-task >= task / 2) [set shape "shoe_2"]
  ;set any-r-agent one-of distance-agent
  set negotiation negotiation + 1 / 12
  set f-index 1
  set resource-index sort (distance-agent)
  set first-r-agent item 0 resource-index
  set second-r-agent item 1 resource-index
  set third-r-agent item 2 resource-index
  set a-agent distance-agent
  ifelse (item f-index required-update = 0) [set active-r-agent first-r-agent][
  ifelse (item (f-index + 1) required-update = 0) [set active-r-agent second-r-agent][
  if (item (f-index + 2) required-update = 0) [set active-r-agent third-r-agent]]]
  ;ifelse (item (f-index + 2) required-update = 0) [set active-r-agent third-r-agent][set active-r-agent first-r-agent]]]
  ifelse active-r-agent != false [ask active-r-agent [set label "busy"] report active-r-agent][get-direction]


  ;set updated-resource update-resource-status (distance-agent)
  ;update-resource-status (distance-agent)
end 

There are 7 versions of this model.

Uploaded by When Description Download
Rotimi Ogunsakin almost 7 years ago New update Download this version
Rotimi Ogunsakin about 7 years ago New update Download this version
Rotimi Ogunsakin about 7 years ago New update Download this version
Rotimi Ogunsakin about 7 years ago New update Download this version
Rotimi Ogunsakin about 7 years ago Updated Version Download this version
Rotimi Ogunsakin about 7 years ago update Download this version
Rotimi Ogunsakin about 7 years ago Initial upload Download this version

Attached files

File Type Description Last updated
ShoeFactory - StigmergyApproach.png preview Preview for 'ShoeFactory - StigmergyApproach' about 7 years ago, by Rotimi Ogunsakin Download

This model does not have any ancestors.

This model does not have any descendants.