0 [
let pct (female-count / total) * 100
ifelse pct < 50 [
set color 15 + (pct / 50) * 45
] [
set color 60 + ((pct - 50) / 50) * 95
]
] [
set color gray
]
end
to record-history
ask schools [
let total male-count + female-count
if total > 0 [
let pct (female-count / total) * 100
set female-history lput pct female-history
if length female-history > 40 [ set female-history but-first female-history ]
]
]
end
to calc-totals
set total-male-all sum [male-count] of schools
set total-female-all sum [female-count] of schools
end
;;;;;;;;;;;;;;;;;;;;;;;;
;;; ν(t) - ФУНКЦИЯ НОРМИРОВКИ
;;;;;;;;;;;;;;;;;;;;;;;;
to compute-nu
let avg-pct 0
let cnt 0
ask schools [
let total male-count + female-count
if total > 0 [
let pct (female-count / total) * 100
set avg-pct avg-pct + pct
set cnt cnt + 1
]
]
ifelse cnt > 0 [
set avg-pct avg-pct / cnt
let exponent exp(kappa * avg-pct / 100)
ifelse exponent > 0 [
set nu-value (0.5 / exponent)
] [
set nu-value 1
]
] [
set nu-value 1
]
if nu-value > 2 [ set nu-value 2 ]
if nu-value < 0.5 [ set nu-value 0.5 ]
end
;;;;;;;;;;;;;;;;;;;;;;;;
;;; НАЙМЫ
;;;;;;;;;;;;;;;;;;;;;;;;
to hire-prob [school-id need-total]
let target-school school school-id
let total-teachers ([male-count] of target-school + [female-count] of target-school)
let xi 0
if total-teachers > 0 [
set xi ([female-count] of target-school / total-teachers) * 100
]
let prob-female nu-value * delta * exp(kappa * xi / 100)
if prob-female > 1 [ set prob-female 1 ]
if prob-female < 0 [ set prob-female 0 ]
let need-female round (prob-female * need-total)
let need-male need-total - need-female
; Создаем нужное количество учителей
repeat need-male [ create-teacher-for-school school-id "male" ]
repeat need-female [ create-teacher-for-school school-id "female" ]
; Обновляем счетчики школы
ask school school-id [
set male-count male-count + need-male
set female-count female-count + need-female
]
end
;;;;;;;;;;;;;;;;;;;;;;;;
;;; ОСНОВНОЙ ЦИКЛ
;;;;;;;;;;;;;;;;;;;;;;;;
to go
if current-year >= 1989 [ stop ]
; УВОЛЬНЕНИЯ
ask teachers [
set years-left years-left - 1
if years-left <= 0 [
ifelse gender = "male" [
ask my-school [ set male-count male-count - 1 ]
] [
ask my-school [ set female-count female-count - 1 ]
]
die
]
]
compute-nu
; НАЙМЫ
let sid 0
while [sid < 3] [
let cur-male [male-count] of school sid
let cur-female [female-count] of school sid
let cur-total cur-male + cur-female
let need 50 - cur-total
if need > 0 [
hire-prob sid need
]
set sid sid + 1
]
ask schools [ school-color-update ]
record-history
calc-totals
refresh-graphs
set current-year current-year + 1
tick
end
;;;;;;;;;;;;;;;;;;;;;;;;
;;; ГРАФИКИ И СТАТИСТИКА
;;;;;;;;;;;;;;;;;;;;;;;;
to refresh-graphs
let all-pcts []
ask schools [
let total male-count + female-count
if total > 0 [
let pct (female-count / total) * 100
set all-pcts lput pct all-pcts
]
]
set-current-plot "Histogram"
clear-plot
if length all-pcts > 0 [
histogram all-pcts
set-plot-x-range 0 100
set-plot-y-range 0 5
]
set-current-plot "Time Series"
clear-plot
let idx 0
let hist-length length [female-history] of school 0
while [idx < hist-length] [
let year 1950 + idx
let pct-val item idx [female-history] of school 0
plotxy year pct-val
set idx idx + 1
]
set-plot-x-range 1950 1989
set-plot-y-range 0 100
end
to show-stats
print "========================================="
print (word "ГОД: " current-year)
print (word "ν = " nu-value)
print (word "κ = " kappa " | δ = " delta)
print "-----------------------------------------"
ask schools [
let total male-count + female-count
let pct 0
if total > 0 [ set pct (female-count / total) * 100 ]
print (word school-name " - муж: " male-count " жен: " female-count " (" pct "%)")
]
print "-----------------------------------------"
print (word "ВСЕГО мужчин: " total-male-all)
print (word "ВСЕГО женщин: " total-female-all)
if (total-male-all + total-female-all) > 0 [
print (word "ОБЩИЙ % ЖЕНЩИН: " ((total-female-all / (total-male-all + total-female-all)) * 100) " %")
]
print "========================================="
end
to export-results
print "========== РЕЗУЛЬТАТЫ ЭКСПЕРИМЕНТА =========="
print (word "ГОД: " current-year)
ask schools [
let total male-count + female-count
let pct 0
if total > 0 [ set pct (female-count / total) * 100 ]
print (word school-name ", " male-count ", " female-count ", " pct)
]
print "=============================================="
end]]>plot count turtlesplot count turtlesplot count turtles## WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
## HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
## HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
## THINGS TO NOTICE
(suggested things for the user to notice while running the model)
## THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
## EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
## NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
## RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
## CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
setup repeat 75 [ go ]