model
Model was written in NetLogo 5.1.0
•
Viewed 66 times
•
Downloaded 3 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
extensions [matrix] Globals [capacity_hiring total_sales Sales Hiring com_sales com_hiring direct_com_sales direct_com_hiring indirect_com_sales indirect_com_hiring hiring_rate sales_rate i j k temp_nb_ante temp_level temp_period alpha ante gini-index-reserve lorenz-points temp turnover missed_sales nb_agents_lag] breed [agts agt] agts-own [perf_sales perf_hiring new nb_ante sharing_ratio level period agent_sales agent_hiring agent_dircom_sales agent_indcom_sales agent_dircom_hiring agent_indcom_hiring income agent_sales_acc agent_dircom_sales_acc agent_dircom_hiring_acc agent_indcom_sales_acc agent_indcom_hiring_acc income_acc agent_hiring_acc] To setup clear-all reset-ticks set capacity_hiring labor_supply let nb 400000 set sales matrix:make-constant nb 30 0 set hiring matrix:make-constant nb 30 0 set direct_com_hiring matrix:make-constant nb 30 0 set direct_com_sales matrix:make-constant nb 30 0 set indirect_com_sales matrix:make-constant nb 30 0 set indirect_com_hiring matrix:make-constant nb 30 0 set ante matrix:make-constant nb 30 0 if MLM = 1 [ set hiring_rate matrix:from-column-list [[1.2 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 level set sales_rate matrix:from-column-list [[0.6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 level ] if MLM = 2 [ set hiring_rate matrix:from-column-list [[1.2 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 level set sales_rate matrix:from-column-list [[0.4 0.2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 level ] if MLM = 3 [ set hiring_rate matrix:from-column-list [[1.2 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 levels set sales_rate matrix:from-column-list [[0.3 0.2 0.1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 3 levels ] if MLM = 6 [ set hiring_rate matrix:from-column-list [[1.2 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 1 levels set sales_rate matrix:from-column-list [[0.24 0.17 0.08 0.05 0.04 0.02 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]] ;; 6 levels ] ;;update-lorenz-and-gini end To go while [ ticks <= duration] [ ifelse ticks = 0 ;; 1st period [ create-agts 1 ;; creates the first agent [ setxy random-pxcor random-pycor Set nb_ante 0 Set level 1 Set period 1 set alpha who + 1 ;;set sharing_ratio random-float 1 ;; part of the effort allocated to sales set sharing_ratio sharing_ratio_initial set agent_sales round (sharing_ratio * 10) ;; 10 number of sold items set agent_hiring round ((1 - sharing_ratio) * 4) ;; 4 number of hired salesmen maximum set temp agent_hiring ;; temp variable set agent_hiring_acc agent_hiring set agent_sales_acc agent_sales set agent_dircom_sales agent_sales * (matrix:get Sales_rate 0 0) set agent_dircom_hiring agent_hiring * (matrix:get hiring_rate 0 0) set agent_dircom_sales_acc agent_sales * (matrix:get Sales_rate 0 0) set agent_dircom_hiring_acc agent_hiring * (matrix:get hiring_rate 0 0) set income agent_dircom_sales + agent_dircom_hiring set income_acc income_acc + income set total_sales agent_sales set new 0 ;;set color white ;;set shape "dot" ;;Hide-turtle matrix:set sales alpha 0 agent_sales matrix:set hiring alpha 0 agent_hiring matrix:set direct_com_sales alpha 0 ((matrix:get Sales alpha 0) * (matrix:get Sales_rate 0 0)) matrix:set direct_com_hiring alpha 0 ((matrix:get hiring alpha 0) * (matrix:get hiring_rate 0 0)) ] create-agts temp ;; creates the sons of the first agent [ setxy random-pxcor random-pycor Set nb_ante 1 Set level 2 Set period 2 matrix:set ante (who + 1) 0 alpha set new 1 ;; for the first time activities allocation is random Hide-turtle ;;set color white ;;set shape "dot" ] ] [ ;; ticks > 0 set total_sales 0 set turnover 0 set nb_agents_lag count agts Leave let G random-float growth set capacity_hiring capacity_hiring + labor_supply * (1 + G) ^ (ticks - 1) * G - Turnover ;;set capacity_hiring capacity_hiring + growth - Turnover ask agts [ set k 0 set agent_sales 0 set agent_hiring 0 set income 0 set agent_dircom_sales 0 set agent_indcom_sales 0 set agent_dircom_hiring 0 set agent_indcom_hiring 0 set temp_level level set temp_period period set temp_nb_ante nb_ante set alpha who + 1 ifelse new = 1 ;; if new agent then random allocation [ set sharing_ratio sharing_ratio_initial set new 0 ] [ set sharing_ratio 1 - ( 1 / (perf_sales + 1 - min list perf_sales perf_hiring) / (( 1 / (perf_sales + 1 - min list perf_sales perf_hiring)) + ( 1 / (perf_hiring + 1 - min list perf_sales perf_hiring)))) ] ifelse total_sales <= capacity_sales ;; haven't reached market saturation yet (from a sales perspective) [ set agent_sales round (sharing_ratio * 10) set total_sales total_sales + agent_sales set agent_sales_acc agent_sales_acc + agent_sales matrix:set sales alpha ticks agent_sales ] [ ;; market saturation (from a sales perspective) _ first in / first served logic set agent_sales 0 set total_sales total_sales + agent_sales matrix:set sales alpha ticks agent_sales set agent_sales_acc agent_sales_acc + agent_sales ] ifelse count (agts) <= capacity_hiring ;; it is intersting for a salesman to join the MLM company [ set agent_hiring round ((1 - sharing_ratio) * 4) ;; 4 is the max hiring per period matrix:set hiring alpha ticks agent_hiring set agent_hiring_acc agent_hiring_acc + agent_hiring ] [ ;; it is not intersting to join the MLM company matrix:set hiring alpha ticks 0 ;;set agent_hiring_acc agent_hiring_acc + 0 set agent_hiring 0 ] matrix:set direct_com_sales alpha ticks ((matrix:get Sales alpha ticks) * (0.5 * 2 * matrix:get Sales_rate 0 0)) matrix:set direct_com_hiring alpha ticks ((matrix:get hiring alpha ticks) * (matrix:get hiring_rate 0 0)) set agent_dircom_sales_acc agent_dircom_sales_acc + (matrix:get sales alpha ticks) * (0.5 * 2 * matrix:get Sales_rate 0 0) set agent_dircom_hiring_acc agent_dircom_hiring_acc + (matrix:get hiring alpha ticks) * (matrix:get hiring_rate 0 0) set agent_dircom_sales ( (matrix:get sales alpha ticks) * (0.5 * 2 * matrix:get Sales_rate 0 0)) set agent_dircom_hiring ( (matrix:get hiring alpha ticks) * (matrix:get hiring_rate 0 0)) set income_acc income_acc + agent_dircom_sales + agent_dircom_hiring set income agent_dircom_sales + agent_dircom_hiring hatch-agts agent_hiring ;; n agents créés [ setxy random-pxcor random-pycor Set nb_ante temp_nb_ante + 1 Set level temp_level + 1 Set period ticks + 2 matrix:set ante (who + 1) 0 alpha set agent_sales 0 set agent_hiring 0 set agent_sales_acc 0 set agent_hiring_acc 0 set agent_dircom_sales 0 set agent_dircom_hiring 0 set agent_dircom_sales_acc 0 set agent_dircom_hiring_acc 0 set agent_indcom_sales_acc 0 set agent_indcom_hiring_acc 0 set sharing_ratio 0 set perf_sales 0 set perf_hiring 0 set income_acc 0 set income 0 set new 1 ;; newly created agent set color white set shape "dot" hide-turtle ] ;;while [ k <= ticks] ;; indirect commissions' computation ;;[ ;;let teta matrix:get ante alpha k ;;if teta != 0 ;;[ ;;matrix:set indirect_com_sales teta ticks (matrix:get indirect_com_sales teta ticks + ( (matrix:get sales alpha ticks) * matrix:get sales_rate (k + 1) 0)) ;; cummul ;;] ;;set k k + 1 ;;] Let teta matrix:get ante alpha 0 ;; indirect commissions' computation while [teta != 0] [ matrix:set indirect_com_sales teta ticks (matrix:get indirect_com_sales teta ticks + ( (matrix:get sales alpha ticks) * matrix:get sales_rate (k + 1) 0)) ;; cummul set teta matrix:get ante teta 0 set k k + 1 ] ] ] ask agts [ set agent_indcom_sales_acc agent_indcom_sales_acc + matrix:get indirect_com_sales (who + 1) ticks ;; from matrix to agents accumulated set agent_indcom_sales matrix:get indirect_com_sales (who + 1) ticks ;; from matrix to agents set income_acc income_acc + agent_indcom_sales set income income + agent_indcom_sales if new = 0 [ set perf_sales agent_dircom_sales / sharing_ratio set perf_hiring (agent_dircom_hiring + agent_indcom_sales) / (1 - sharing_ratio) ] ] ask agts with [who < 5000 ] [ if sharing_ratio = 0.5 [ set color white show-turtle ] ifelse sharing_ratio > 0.5 [ set color green show-turtle ] [ set color blue show-turtle ] ] ;;computing_missed_sales ;;update_ante ;;update-lorenz-and-gini tick ] end To update_ante set i count (agts) set j 0 while [ i <= count (agts)] ;; mettre à jour la matrice des antécédants [ set j 0 while [ j <= ticks + 1] [ if (matrix:get ante i j) != 0 [ let beta matrix:get ante i j matrix:set ante i (j + 1) (matrix:get ante beta 0) ] set j j + 1 ] set i i + 1 ] end ;; this procedure recomputes the value of gini-index-reserve ;; and the points in lorenz-points for the Lorenz and Gini-Index plots to update-lorenz-and-gini let sorted-wealths sort [income_acc] of agts with [new = 0] let total-wealth sum sorted-wealths let wealth-sum-so-far 0 let index 0 set gini-index-reserve 0 set lorenz-points [] ;; now actually plot the Lorenz curve -- along the way, we also ;; calculate the Gini index. ;; (see the Info tab for a description of the curve and measure) repeat (count agts with [new = 0]) [ set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths) set lorenz-points lput ((wealth-sum-so-far / total-wealth) * 100) lorenz-points set index (index + 1) set gini-index-reserve gini-index-reserve + (index / (count agts with [new = 0])) - (wealth-sum-so-far / total-wealth) ] end To leave ask agts with [ income < 3 and new = 0 and who != 0] ;; old agents with no income in the last period [ ;;set capacity_hiring capacity_hiring - 1 set turnover turnover + 1 die ] end To computing_missed_sales if (count (agts with [new = 0]) * 30 <= capacity_sales) [ set missed_sales missed_sales + count (agts with [new = 0]) * 30 - total_sales ] end
There is only one version of this model, created 9 months ago by ifelab lerma.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
model.png | preview | Preview for 'model' | 9 months ago, by ifelab lerma | Download |
This model does not have any ancestors.
This model does not have any descendants.