/*----------------------------------------------------------*\ * File name: fi.c * * * * Created by: Zivinas Binisevicius * * Zaneta Vaisvilaite * * * * Date: 20/10/97 * * * * Description: Calculating the best investment * * * \*----------------------------------------------------------*/ #include #include #include #include "fi.h" const int size = 7; const int count = 6; #define maximum 32768.0 const int number_of_usefulness = 5; int number_of_tests = 500; int number_of_variables = 6; static int isReliability; double bank_reliability[size]; /*-- The Data Section --------------------------------------*/ /* Amount of all loans */ double bank_loans[count] = {361633000.0, /*Hermis */ 49480000.0, /*Siauliu*/ 120054000.0, /*Ukio */ 477184000.0, /*Vilnius*/ 564608000.0, /*LTB */ 808263000.0}; /*LZUB */ /* All other data is given respectively*/ /* Amount of bad loans */ double bank_badln[count] = { 41682800.0, 696800.0, 6841000.0, 35402800.0, 47817000.0, 85431000.0}; /* Amount of capital */ double bank_capital[count]= {741614000.0, 95093000.0, 216860000.0, 1121016000.0, 1428075000.0, 1336420000.0 }; /* Amount of deposits */ double bank_deposits[count]= {542408000.0, 40603000.0, 168497000.0, 777898000.0, 1300958000.0, 1163036000.0 }; /* Amount of secured deposits */ double bank_securdep[count]= {1245600.0, 624500.0, 1150100.0, 1711000.0, 1265400.0, 1078000.0 }; /* Amount of shares in LTL */ double bank_shares[count]= {1087350.0, 680420.0, 3500000.0, 2038000.0, 600000.0, 732546.0 }; /* Amount of operation costs */ double bank_costs[count]= {9366000.0, 1814000.0, 5852000.0, 13161000.0, 23318000.0, 19572000.0 }; /* Income from operation */ double bank_income[count]= {32985000.0, 4262000.0, 7945000.0, 48513000.0, 54164000.0, 71260000.0 }; /* Amount of percents paid */ /* 6 - mounths deposits */ double percents_paid[size]= {.075, /*Hermis */ .105, /*Siauliai*/ .100, /*Ukio */ .072, /*Vilnius */ .060, /*LTB */ .057, /*LZUB */ .000 }; /* Home */ /* Usefulness */ /* { cash, usefulness } */ double usefulness[number_of_usefulness][2] = {{0. ,0. }, {500. ,0.4}, {1000. ,0.7}, {1500. ,0.9}, {2000. ,1. }}; /* */ double weight[5] = {.25, /* credit risk */ .35, /* liquidity risk */ .30, /* loan norm risk */ .05, /* income risk */ .10}; /* solvency risk */ /*-- End of Data Section -----------------------------------*/ /*-- Risk calculation functions ----------------------------*/ /* Credit Risk */ double creditRisk(const double bad_loans, const double all_loans) { return ( 1 - (bad_loans / all_loans)); }; /* Liquidity Risk */ double liquidRisk(const double all_loans, const double all_capital) { return ( 1 - (all_loans / all_capital)); }; /* Loan N Risk */ double loanNrRisk(const double sec_deposits, const double all_deposits) { return (sec_deposits / all_deposits); }; /* Income Risk */ double IncomeRisk(const double operation_income, const double operation_cost) { return (1-(operation_income / operation_cost)); }; /* Solvency Risk */ double SolvncRisk(const double shares, const double all_capital) { return (shares/all_capital); }; /* Reliability of the Bank */ double reliability(const double crdR, const double liqR, const double lnNR, const double IncR, const double slvR) { return ( crdR * weight[1] + liqR * weight[2] + lnNR * weight[3] + IncR * weight[4] + slvR * weight[5]) * 1.65; }; /* Reliability of Home */ double reliabilityH(const double robberys, const population) { return (1-(robberys/population)); }; /* Fill Reliability vector */ void fillReliabilityVector(void) { int i; for (i = 0; i < 6; i++ ) bank_reliability[i] = reliability(creditRisk(bank_badln[i],bank_loans[i]), liquidRisk(bank_loans[i],bank_capital[i]), loanNrRisk(bank_securdep[i],bank_deposits[i]), IncomeRisk(bank_income[i],bank_costs[i]), SolvncRisk(bank_shares[i],bank_capital[i])); bank_reliability[6] = 1 - reliabilityH(8000,300000); } /* printing the vector x */ void printVector(const double *x, int size) { int i; for(i=0;iusefulness[l][0])&(dWins 0 - calculates all constrains ng < 0 - calculates only constrain with number (-ng) */ double x1 = x [0]; double x2 = x [1]; double x3 = x1 * x1; double x4 = x2 * x2; if (ng > 0) { g [0] = 25. - x3 - x4; g [1] = 10. * x1 - x3 + 10. * x2 - x4 - 34.; g [2] = x1; g [3] = x2; } else { ng = -ng; switch (ng) { case 1: g [0] = 25. - x3 - x4; break; case 2: g [1] = 10. * x1 - x3 + 10. * x2 - x4 - 34.; break; case 3: g [2] = x1; break; case 4: g [3] = x2; break; } } } /*-- End of file -------------------------------------------*/