model
Model was written in NetLogo 5.1.0
•
Viewed 55 times
•
Downloaded 2 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
;;; ;;; Define Variables (declaration) ;;; breed [ firms firm ] breed [ banks bank ] ;; financial institution, which give a loan to the firm. breed [ households household ] ;; consumers globals [ periods ;; the time span we consider. number represents the year after the starting time. ;custom_solvab? fund credit_amount ;; the limit of each credit interestrate ;; when it is about conventional financing, this is the interest rate for the credit charged by the bank. loan_duration ;; the duration of the loan (months). wealth_bank ;; profits of the bank amount_purposeloan? efficiency profitability productivity credit_risk average_loan_balance_per_borrower performance_achieved? ;; if true, the bank achieved social and financial performance profit_loss_amount ;; the amount of the profit or the loss of the activity financing_cost zakat_fund ; tha zakat donation are gathered in this fund wealth_household base_wage ; the salary that the firm propose to the worker ] patches-own [ ] firms-own [ wealth_firm ;; each firm's wealth level firm_activity ;; the activity of the firm, either agriculture, trade or cruft insured_firm ;; the firm is insured or not purpose_loan ;; Creation or Devlopment of the activity nb_loan ;; the number of loan contracted by the firm cross_indebteness ;; if the firm has another loan with other institutions unpaid_amount ;; the unpaid amout of the loan nb_paid_installments ;; the number of paid installments nb_installments ;; the number of installments borrowingdate ;; the date when one of firms get a loan from bank ;wealth_sufficient? ;; if true, firm can reimburse his loan. repay_amount? ;; if true, firm reimubrse his loan. borrower-bank? ;; if true, the turtle has got a credit from bank. firm_score expected_demand ;base_wage actual_production desired_production desired_capital desired_employment actual_employment ] households-own [ income desired_wage ; the wage or the salary that household which to have average_consumption ; the average of consumption of all consumers expected_income ; the income that the household or the consumer expect to receive. previous_expected_income consumption ] ;************************************************ SETUP PROCEDURES *************************************************************** to-report VARY [#low #high] ;; reports a random integer in given range, inclusive report #low + random(#high - #low + 1) end to setup clear-all reset-ticks setup-patches setup-firms set periods time-span-years ;; the slider of time-span-years stands for the periods (years). reset-ticks end to setup-patches ask patches [ set pcolor black ] ;; set patche's color black. bank-setup households-setup end to bank-setup ask patches [ ask patch 0 0 [set pcolor red] ;; the color for the patch of bank is yellow. sprout-banks 1 [ ;; for visual impact, the bank has the shape of yellow house. set size 3 set shape "house" set color violet setxy 0 0 set fund credit-available ;; credits available from bank is set using the slider of credit-available. set interestrate interest-rate ;; when it is about conventional financing, the interest rate charged by the bank is set using the slider -> need to make interest-rate slider. set credit_amount vary 1 20 ;; the loan limit from the bank is set using the slider -> need to make credit-limit slider set loan_duration loan-duration ;; the duration of the loan. set wealth_bank 5000 set efficiency eff-iciency ;; efficiency of the bank set productivity prod-uctivity ;; productivity of the bank set profitability prof-itabilty ;; profitability of the bank set average_loan_balance_per_borrower loan-balance-borrow ;; average loan balance per borrower set credit_risk credit-risk ;; portfolio at risk ; set firms-number nb-fir ;; number of firm of the bank set performance_achieved? random 2 ] ] end to households-setup create-households n_households [ setxy random-pxcor random-pycor ] ; workers are randomly disposed... ask households [ set shape "person" set color white set income 0 set desired_wage random-normal 80 5 ; the wage or the salary that household which to have set zakat_fund 0 set wealth_household random-normal 100 10 set average_consumption random-normal 50 1 set expected_income random-normal 150 20 set previous_expected_income random-normal 100 50 ] ask n-of (n_households / 2 ) households [ set income desired_wage set color green ] end to setup-firms create-firms firms-number ;; uses the value of the firms-number slider to set the number of firms. ask firms [ set shape "square" set pcolor red ;; setxy random-xcor random-ycor set wealth_firm random-normal 1000 80 ;; wealth level each firms start with come from N(50, 15) set firm_activity random 4 ;; either agriculture or cruft (0), trade (1), industry (2) or others (3) ;set level_education random 3 ;; either bad (0), medium (1) or high (2) level of education set insured_firm random 2 ;; the firm is insured (1) or not (0) set purpose_loan random 2 ;; Creation (0) or Devlopment (1) of the activity ;set custom_solvab? FALSE ;; if true, firm is accepted. ;set wealth_sufficient? false set borrower-bank? random 2 ;; if true, the turtle has got a credit from bank. set repay_amount? random 2 set nb_loan 0 set cross_indebteness 0 set unpaid_amount 0 set nb_paid_installments 0 set nb_installments 0 set firm_score vary -5.0 5.0 set profit_loss_amount profit-loss-amount set financing_cost financ-cost set expected_demand random-normal 200 50 set base_wage random-normal 100 20 ] end ;;; ;;; GO PROCEDURES ;;; to go if ticks >= 365 * periods [ stop ] ;; the time span is restricted to periods (year). * ask firms [ move-households ;; this procedure makes firms move. funding_application ;; this procedure makes firm ask for a credit. recruit_licienciement produce reimburse-bank ;; this procedure makes firms reimburse their loans towards bank. ] ask households [ consume_give_zakat ] tick ;; one tick stands for one day. update-plot end to move-households right random 360 forward random 4 set wealth_household ( wealth_household - 0.05 ) end ;************************************************ funding_application *************************************************************** to-report firm_solvab? ; ifelse (firm_type = 0 and firm_score > -0.58) or (firm_type = 1 and firm_score > 1.8) ifelse firm_score > 1 [ report true ] [ report false ] end to-report bank_performance report ((efficiency + profitability + productivity + credit_risk + average_loan_balance_per_borrower + firms-number) / 6 ) end to funding_application if (fund >= credit_amount) and wealth_firm < 20 and wealth_firm > 5 [ ask firms with [firm_solvab? = true ] [ set wealth_firm (wealth_firm + credit_amount ) set pcolor yellow ;; those with credit turn yellow. set wealth_bank (fund - credit_amount) ;; available fund to loan will decreases as the loan increases. ;;set custom_Solvab? true set borrower-bank? 1 ;; if true, the turtle has got a credit from bank. set borrowingdate ticks ] ; ] ask firms with [firm_solvab? = false] [ set wealth_firm ( wealth_firm) set pcolor orange ;; those with credit turn orange. set borrower-bank? 0 ;; if true, the turtle has got a credit from bank set wealth_bank (wealth_bank) ;; available fund . ] ] end to-report wealth_sufficient? ifelse ( (wealth_firm + profit_loss_amount ) >= ( 1 + financing_cost) * credit_amount) ;Conventional scenario: ; when it is about conventional scenario, we disable the Islamic model above and activate the actions hereafter: ;;; ifelse ( wealth_cust >= ((credit_amount * interestrate / 100 / 365) / (1 - (1 + interestrate / 100 / 365)^(ticks - borrowingdate )) * ( ticks - borrowingdate ))) ;; ifelse ( wealth_cust >= ((credit_amount * interestrate / 100 / 365) / (1 - (1 + interestrate / 100 / 365)^(loan_duration * -30 )) * loan_duration * 30)) [ report true ] [ report false ] end ;************************************************ Produce *************************************************************** to produce ask firms [ set actual_production 0.32 * wealth_firm set desired_production actual_production + 0.000123 * (actual_production - expected_demand)] set wealth_firm wealth_firm + actual_production end to-report colorhous? ifelse ( color = white ) [ report true ] [ report false ] end ;************************************************ Recruit_licienciement *************************************************************** to recruit_licienciement ask firms [ set desired_capital 0.22 * desired_production - 65 set desired_employment min list ( 0.11 * desired_capital) ( 0.11 * wealth_firm) ] ifelse desired_employment > actual_employment [ ask households with [colorhous? = true] [ if desired_wage < base_wage ; the number of household must be equal to : (desired_employement - actual_employment) ) [ set color green set income base_wage set wealth_household wealth_household + base_wage ]]] [ ask households with [colorhous? = false] [ set color white ; the number of household must be equal to: (actual_employment - desired_employement) set income 0 set wealth_household wealth_household ]] end ;*********************************** CONSUMPTION and Give zakat *************************************************************** to-report wealth_poverty? ifelse ( wealth_household < poverty_limit) [ report true ] [ report false ] end to consume_Give_zakat ask households [ set expected_income (0.35 * previous_expected_income + ((1 - 0.35) * income)) ;dependent_scenario set consumption (0.58 * expected_income + 0.31 * wealth_household + (1 - 0.58) * average_consumption) ; This is the equation of consumption in the dependent_scenario. ;independent_scenario : When we want to test the independent scenario, we disable the fonction above and we activate the equation hereafter : ; set consumption (expected_income + 0.31 * wealth_household) ifelse wealth_household + income - consumption > reference_amount_zakat [ set zakat_fund ((wealth_household + income - consumption) * 0.025) set wealth_household ( wealth_household + income - consumption) * (1 - 0.025)] [set wealth_household ( wealth_household + income - consumption)] ] ask households with [wealth_poverty? = true][ set wealth_household ( wealth_household + ( sum [zakat_fund] of households with [wealth_poverty? = false ] / ( count households with [wealth_poverty? = true ]))) ] end ;*********************************** Reimburse-bank *************************************************************** to reimburse-bank if ( borrower-bank? = 1 and pcolor = yellow and wealth_sufficient? = true) [ ;; firms can repay their debts only if he has contracted loan from bank. ;if (color = yellow and wealth_sufficient? = true ) [ ;; firms can repay their debts only if he has contracted loan from bank. ask firms with [ repay_amount? = 1 ][ ; Islamic Model set wealth_firm ((wealth_firm + profit_loss_amount ) - (( 1 + financing_cost / 100 / 365 * ( ticks - borrowingdate ) ) * credit_amount)) ;; the amount of repayment is the summation of pricipal and interest (annual interest rate -> daily interest rate) set pcolor violet ;; after repay, the color turn into violet set wealth_bank ( wealth_bank + (( 1 + financing_cost / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount) - 20 ) ;; interest rate is rate for one year. if ticks - borrowingdate <= 365 [ set nb_paid_installments ( nb_paid_installments + 1 ) ] ;;maturity for the loan is assumed to be one year. ] ask firms with [ repay_amount? = 0][ set wealth_firm (wealth_firm + profit_loss_amount) ;; the amount of repayment is the summation of pricipal and interest (annual interest rate -> daily interest rate) set pcolor pink ;; after repay, the color turn into pink if ( financing_cost >= (1 + financing_cost)* credit_amount) [set wealth_bank ( wealth_bank + (( 1 + financing_cost / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount) - 20 ) ;; interest rate is rate for one year. set unpaid_amount (unpaid_amount + ((1 + financing_cost / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount)) if ticks - borrowingdate <= 365 [ set nb_paid_installments ( nb_paid_installments) ] ]] ; Conventional model ; when it is about conventional scenario, we disable the Islamic model above and activate the actions hereafter: ; set wealth_firm ((wealth_firm + profit_loss_amount ) - (( 1 + interestrate / 100 / 365 * ( ticks - borrowingdate ) ) * credit_amount)) ;; the amount of repayment is the summation of pricipal and interest (annual interest rate -> daily interest rate) ; set pcolor violet ;; after repay, the color turn into violet ; set wealth_bank ( wealth_bank + (( 1 + interestrate / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount) - 20 ) ;; interest rate is rate for one year. ; if ticks - borrowingdate <= 365 [ set nb_paid_installments ( nb_paid_installments + 1 ) ] ;;maturity for the loan is assumed to be one year. ; ] ; ask firms with [ repay_amount? = 0][ ; set wealth_firm (wealth_firm + profit_loss_amount) ;; the amount of repayment is the summation of pricipal and interest (annual interest rate -> daily interest rate) ; set pcolor pink ;; after repay, the color turn into pink ; set wealth_bank ( wealth_bank - (( ( 1 + interestrate / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount ))- 20 ) ;; interest rate is rate for one year. ; set unpaid_amount (unpaid_amount + ((1 + interestrate / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount)) ; if ticks - borrowingdate <= 365 [ set nb_paid_installments ( nb_paid_installments) ] ; ] ] end ;*********************************** reports ************************************ ;*********************************** reports ************************************ ;*********************************** reports ************************************* to-report average-wealth-firm report ( sum [ wealth_firm ] of firms / count firms ) end to-report zakat-fund report ( sum [zakat_fund] of households ) end to-report sum-wealth-bank report ( sum [ wealth_bank] of banks) end to-report average-wealth-household report ( sum [ wealth_household ] of households / count households ) end to-report stdv_consumption report ( standard-deviation [ consumption ] of households / count households ) end to-report consumption-household report ( sum [ consumption ] of households / count households ) end to-report firm-solvability report ( count firms with [ firm_Solvab? = true] ) end To-report firm-reimburse-loan report ( count firms with [ repay_amount? = 1 and firm_solvab? = true ] ) end to-report solvability-ratio report (count firms with [ firm_Solvab? = true] / count firms ) end to-report PAR30 report ( sum [ credit_amount ] of firms with [ ticks - borrowingdate >= 30 ] / sum [ credit_amount ] of firms ) end to-report PAR90 report ( sum [ credit_amount ] of firms with [ ticks - borrowingdate >= 90 ] / sum [ credit_amount ] of firms ) end to-report PAR180 report ( sum [ credit_amount ] of firms with [ ticks - borrowingdate >= 180 ] / sum [ credit_amount ] of firms ) end ;;; ;;; PLOTS ;;; to update-plot set-current-plot "Average Wealth-firm" set-current-plot-pen "firms" plot sum [ wealth_firm ] of firms / count firms set-current-plot "Average Wealth-household" set-current-plot-pen "households" plot sum [ wealth_household ] of households / count households set-current-plot "consumption_households" set-current-plot-pen "households" plot sum [ consumption ] of households / count households set-current-plot "stdv_consumption_households" set-current-plot-pen "households" plot standard-deviation [ consumption ] of households / count households set-current-plot "Wealth-bank" set-current-plot-pen "bank" plot sum [ wealth_bank ] of banks set-current-plot "Average Loan" set-current-plot-pen "firms" plot sum [ credit_amount ] of firms / count firms set-current-plot "Number of Payment" set-current-plot-pen "firms" plot sum [ nb_paid_installments ] of firms set-current-plot "firm-solvability" set-current-plot-pen "firms" plot count firms with [ firm_Solvab? = true] set-current-plot "firm-reimburse-loan" set-current-plot-pen "firms" plot count firms with [ repay_amount? = 1 ] ;export-plot "Wealth-bank" "Wealth-bank.csv" ;export-plot "Average Wealth-firm" "Average_Wealth-firm.csv" ;export-plot "Number of Payment" "Number_of_Payment.csv" 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.