LLNL_2

No preview image

1 collaborator

Default-person Michelle Saksena (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 175 times • Downloaded 36 times • Run 0 times
Download the 'LLNL_2' 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 [n data cumulative_hazard]
breed[ nodes node]
nodes-own [h_i t_0 replacement replacement_cost lambda eta theta cost priority xi1 xi2 xi3 xi4 xi5 xi6 xi7 c1 c2 c3 c4 c5 c6 c7 ]; x's are covariates between the ith component and the jth component

links-own []

to setup
  ca
  ask patches [ set pcolor white ]
  load-data
  setup-nodes
  ask nodes 
  [
    assign-component-data
    create-network
  ]
   
  reset-ticks
end 

to go
  tick
  ask nodes
  [
    update-hazards
    ;replace-nodes
    
  ]
  if ticks = 5000
  [stop]
end 

to load-data

  ifelse ( file-exists? "data.txt" )
  [
    
    set data []
    file-open "data.txt"
    set n 0
    while [ not file-at-end? ]
    [
      set data sentence data (list (list file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read n ) )
      set n n + 1
    ]    
    user-message "File read. Please wait. A message will let you know when the data are loaded."
    ; done reading - close
    file-close
  ] 
  [ user-message "File not found" ]
  show n
end 

to setup-nodes
  create-nodes n
  layout-circle sort nodes n
  ask nodes
  [
  set label-color black
  if  who = 0
  [set label "electrical" ]
  if who = 1
  [set label "HVAC"]
  if who = 2
  [set label "Fire"]
  if who = 3
  [set label "Plumbing"]
  if who = 4
  [set label "Roof"]
  set shape "dot"
  set color [255 0 0 125]
  ]
end 

to assign-component-data
  ifelse ( is-list? data )
   [ foreach data 
       [ ask nodes with [ who = last ? ]
        [ 
        set lambda first ?
        set eta item 1 ?
        set theta item 2 ?
        set xi1 item 3 ?
        set xi2 item 4 ?
        set xi3 item 5 ?
        set xi4 item 6 ?
        set xi5 item 7 ? 
        
        set c1 item 8 ?
        set c2 item 9 ?
        set c3 item 10 ?
        set c4 item 11 ?
        set c5 item 12 ?
        set cost item 13 ?
        set priority item 14 ?
        ]
       ]
   ]
   [user-message "You need to load in data first" ]
end 

to create-network
  if c1 != 0
  [ create-links-to other nodes with [c1 = 1]]
    if c2 != 0
  [ create-links-to other nodes with [c2 = 2]]
    if c3 != 0
  [ create-links-to other nodes with [c3 = 3]]
    if c4 != 0
  [ create-links-to other nodes with [c4 = 4]]
    if c5 != 0
  [ create-links-to other nodes with [c5 = 5]]
    if c6 != 0
  [ create-links-to other nodes with [c6 = 6]]
    if c7 != 0
  [ create-links-to other nodes with [c7 = 7]]
  
  ask links [set color blue - 2 + random 7]
end 

to update-hazards
    
    set h_i (lambda * exp ( (- lambda * eta )) * (ticks - t_0 ) ^ (lambda - 1))  
    set size h_i
      
    if [size > risk-tolerance + priority ] of self
    [
    set t_0 [ticks] of self 
    set replacement [replacement + 1] of self
    set replacement_cost replacement * cost
    ]
end 

;to replace-nodes
; set t_0 [ticks] of self 
; set replacement [replacement + 1] of self
; set replacement_cost replacement * cost
;end


  
  

There is only one version of this model, created about 12 years ago by Michelle Saksena.

Attached files

File Type Description Last updated
data.txt data data file about 12 years ago, by Michelle Saksena Download

This model does not have any ancestors.

This model does not have any descendants.