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 [ customers customer ] ;; customers the main target of Microfinance. breed [mfis mfi] ;; Microfinance institution, which give a loan to the customer. breed [ partners partner ] ;; partners who evaluate the loan amount according to the purpose of the loan. breed [donors donor] ;; donors who finance MFI. globals [ periods ;; the time span we consider. number represents the year after the starting time. ;custom_solvab? fund credit_amount ;; the limit of each microcredit interestrate ;; interest rate for the microcredit charged by the MFI. wealth_mfi ;; profits of the mfi amount_purposeloan? efficiency profitability productivity credit_risk average_loan_balance_per_borrower nb_customers performance_achieved? ;; if true, the IMF achieved social and financial performance funds_Offer? ;; the donors offer funds to mfi profit_loss_amount ;; the amount of the profit or the loss of the activity financing_cost wealth_funds ] patches-own [ ] customers-own [ wealth_cust ;; each individual's wealth level sex ;; each individual sex, either male or female8 marital_status ;; Married, single, divorced or widow customer_activity ;; the activity of the customer, either agriculture, trade or cruft level_education ;; the level of education of the customer: bad, medium or high level of education insured_customer ;; the customer is insured or not customer_residence ;; Rural or Urban area purpose_loan ;; Creation or Devlopment of the activity customer_type ;; Old or new customer nb_loan ;; the number of loan contracted by the customer cross_indebteness ;; if the customer 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 poors get a loan from mfi ;wealth_sufficient? ;; if true, customer can reimburse his loan. repay_amount? ;; if true, customer reimubrse his loan. borrower-mfi? ;; if true, the turtle has got a microcredit from mfi. customer_score ] ;;; ;;; SETUP PROCEDURES (initialisation) ;;; to-report VARY [#low #high] ;; reports a random integer in given range, inclusive report #low + random(#high - #low + 1) end to SETUP ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) clear-all reset-ticks setup-patches setup-customers 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. mfi-setup partners-setup end to mfi-setup ask patches [ ask patch 0 0 [set pcolor red] ;; the color for the patch of MFI is yellow. sprout-mfis 1 [ ;; for visual impact, the mfi has the shape of yellow house. set size 3 set shape "house" set color red setxy 0 0 set fund microcredit-available ;; microcredits available from mfi is set using the slider of microcredit-available. set credit_amount vary 1 20 ;; the loan limit from the MFI is set using the slider -> need to make credit-limit slider set wealth_mfi fund set performance_achieved? random 2 set funds_Offer? random 2 set wealth_funds wealth-funds ] ] end to partners-setup ask patches [ ask patch 0 10 [set pcolor grey] ;; the suppliers of raw materials are on the grey patch ask patch 0 -10 [set pcolor grey] ask patch 10 0 [set pcolor grey] ask patch -10 0 [set pcolor grey] sprout-partners 1 [ ;; for visual impact, the raw material suppliers have the shapes of grey trucks. set size 2 set shape "circle" set color grey setxy 0 10 set amount_purposeloan? true ;; if true, the amount applied by customer is accepted. ] sprout-partners 1 [ set size 2 set shape "circle" set color grey setxy 0 -10 set amount_purposeloan? true ;; if true, the amount applied by customer is accepted. ] sprout-partners 1 [ set size 2 set shape "circle" set color grey setxy 10 0 set amount_purposeloan? true ;; if true, the amount applied by customer is accepted. ] sprout-partners 1 [ set size 2 set shape "circle" set color grey setxy -10 0 set amount_purposeloan? true ;; if true, the amount applied by customer is accepted. ] ] end to setup-customers create-customers customers-number ;; uses the value of the customers-number slider to set the number of customers. ask customers [ set shape "person" set color green ;; the color for the customer is green. setxy random-xcor random-ycor set wealth_cust random-normal 50 15 ;; wealth level each custumers start with come from N(50, 15) set sex random 2 ;; sex for each custumers is either o (female) or 1 (male) set customer_type random 2 ;; statut for each custumer is either old (0) or new (1). set marital_status random 2 ;; either Married (0) or single (1). set customer_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_customer random 2 ;; the customer is insured (1) or not (0) set customer_residence random 2 ;; Rural (1) or Urban area (0) set purpose_loan random 2 ;; Creation (0) or Devlopment (1) of the activity ;set custom_solvab? FALSE ;; if true, customer is accepted. ;set wealth_sufficient? false set borrower-mfi? random 2 ;; if true, the turtle has got a microcredit from mfi. 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 customer_score vary -5.0 5.0 set profit_loss_amount profit-loss-amount set financing_cost financ-cost ] end ;;; ;;; GO PROCEDURES ;;; to go if ticks >= 365 * periods [ stop ] ;; the time span is restricted to periods (year). * ask customers [ move-customers ;; this procedure makes customers move. microcredit_application ;; this procedure makes customer ask for a microcredit. reimburse-mfi ;; this procedure makes customers reimburse their loans towards mfi. ;donors_mfi ;; this procedure makes mfi get funds from donors. ] tick ;; one tick stands for one day. update-plot end to move-customers right random 360 forward random 4 set wealth_cust ( wealth_cust - 0.05 ) end ;;; ;;; granting microcredit from mfi ;;; to-report custom_solvab? ifelse (customer_type = 0 and customer_score > -0.58) or (customer_type = 1 and customer_score > 1.8) [ report true ] [ report false ] end to-report mfi_performance report ((efficiency + profitability + productivity + credit_risk + average_loan_balance_per_borrower + nb_customers) / 6 ) end to microcredit_application if (fund >= credit_amount) and wealth_cust < 20 and wealth_cust > 5 [ ;; microcredit is possible only when the MFI have money enough to loan and customers is located in the same patch as MFI, which reflects ;if (wealth_mfi >= credit_amount) [ ;; microcredit is possible only when the MFI have money enough to loan and customers is located in the same patch as MFI, which reflects ; ask customers with [ (credit_amount <= 20 and amount_purposeloan? = true) or (amount_purposeloan? = false or credit_amount > 20) ] [ ;; the amout of loan applied by customer. ;; ifelse ((customer_type = 0 and customer_score > -0.58) or (customer_type = 1 and customer_score > 1.8)) ;; [set custom_solvab? true][set custom_solvab? false] ask customers with [custom_solvab? = true ] [ set wealth_cust (wealth_cust + credit_amount ) set color yellow ;; those with microcredit turn yellow. set wealth_mfi (fund - credit_amount) ;; available fund to loan will decreases as the loan increases. ;;set custom_Solvab? true set borrower-mfi? 1 ;; if true, the turtle has got a microcredit from mfi. set borrowingdate ticks ] ; ] ask customers with [custom_solvab? = false] [ set wealth_cust ( wealth_cust) set color orange ;; those with microcredit turn orange. ;;set custom_Solvab? false set borrower-mfi? 0 ;; if true, the turtle has got a microcredit from mfi set wealth_mfi (wealth_mfi) ;; available fund . ] ] end to-report wealth_sufficient? ;; 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)) ifelse ( (wealth_cust + profit_loss_amount ) >= ( 1 + financing_cost) * credit_amount) [ report true ] [ report false ] end to reimburse-mfi if ( borrower-mfi? = 1 and color = yellow and wealth_sufficient? = true) [ ;; customers can repay their debts only if he has contracted loan from mfi. ;if (color = yellow and wealth_sufficient? = true ) [ ;; customers can repay their debts only if he has contracted loan from mfi. ask customers with [ repay_amount? = 1 ][ set wealth_cust ((wealth_cust + 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 color violet ;; after repay, the color turn into violet set wealth_mfi ( wealth_mfi + (( 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 customers with [ repay_amount? = 0][ set wealth_cust (wealth_cust + profit_loss_amount) ;; the amount of repayment is the summation of pricipal and interest (annual interest rate -> daily interest rate) set color pink ;; after repay, the color turn into pink if ( wealth_funds + wealth_mfi >= (1 + financing_cost)* credit_amount) [set wealth_mfi ( wealth_mfi + (( 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) ] SET wealth_funds wealth_funds - (( 1 + financing_cost / 100 / 365 * ( ticks - borrowingdate) ) * credit_amount) ]] ] end ;to donors_mfi ;ask customers with [(( efficiency + profitability + productivity + credit_risk + average_loan_balance_per_borrower + nb_customers) / 6 >= 3) and count customers with [custom_Solvab? = true] >= 0.7 * customers-number] [ ; set wealth_mfi (wealth_mfi + 100 + 50) ; set performance_achieved? 1 ; set funds_Offer? 1 ; ] ;end ;;; ;;; reports ;;; to-report average-wealth-customer report ( sum [ wealth_cust ] of customers / count customers ) end to-report sum-wealth-mfi report ( sum [ wealth_mfi] of mfis) end to-report customer-solvability report ( count customers with [ custom_Solvab? = true] ) end To-report customer-reimburse-loan report ( count customers with [ repay_amount? = 1 and custom_solvab? = true ] ) end to-report solvability-ratio report (count customers with [ custom_Solvab? = true] / count customers ) end to-report PAR30 report ( sum [ credit_amount ] of customers with [ ticks - borrowingdate >= 30 ] / sum [ credit_amount ] of customers ) end to-report PAR90 report ( sum [ credit_amount ] of customers with [ ticks - borrowingdate >= 90 ] / sum [ credit_amount ] of customers ) end to-report PAR180 report ( sum [ credit_amount ] of customers with [ ticks - borrowingdate >= 180 ] / sum [ credit_amount ] of customers ) end ;;; ;;; PLOTS ;;; to update-plot set-current-plot "Average Wealth-customer" set-current-plot-pen "customers" plot sum [ wealth_cust ] of customers / count customers set-current-plot "Wealth-mfi" set-current-plot-pen "mfi" plot sum [ wealth_mfi ] of mfis set-current-plot "Average Loan" set-current-plot-pen "customers" plot sum [ credit_amount ] of customers / count customers set-current-plot "Number of Payment" set-current-plot-pen "customers" plot sum [ nb_paid_installments ] of customers 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.