Changeset 78c6ae6 in observatorio for simulacion
- Timestamp:
- Oct 22, 2014, 6:00:54 PM (10 years ago)
- Branches:
- simulacion
- Children:
- 18610a4
- Parents:
- 512ad64
- Location:
- simulacion/SimEscenariosEconomicos
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
simulacion/SimEscenariosEconomicos/common.C
r7941763 r78c6ae6 213 213 std::string numtostrRec(const real & num, const char & thousandSep) { 214 214 215 if (num < 1000 ) {215 if (num < 1000.0) { 216 216 217 217 std::stringstream sstr; … … 222 222 } 223 223 224 real aux = num / 1000 ;224 real aux = num / 1000.0; 225 225 226 226 long long intPart = (long long) aux; … … 236 236 std::string str = sstr.str(); 237 237 238 if (aux < 100.0L) 238 if (aux < 100.0L) { 239 239 str = "0" + str; 240 241 if (aux < 10.0L) 240 } 241 242 if (aux < 10.0L) { 242 243 str = "0" + str; 244 } 243 245 244 246 return numtostrRec(intPart, thousandSep) + thousandSep + str; … … 276 278 277 279 if (strDec.size() > 2) 278 ret += decSep + strDec.substr(2, strDec.size() - 2);280 ret += decSep + strDec.substr(2, strDec.size() - 2); 279 281 280 282 return sign + ret; -
simulacion/SimEscenariosEconomicos/ioManager.H
r512ad64 r78c6ae6 437 437 scode << input.id; 438 438 439 if (productInfo. nationality == "V")439 if (productInfo.companyRif.size() > 0) 440 440 scode << productInfo.companyRif; 441 441 else … … 1428 1428 c1.levels.for_each(AddLevelToStr(str1)); 1429 1429 1430 str1.append(c1.rif); 1430 if (c1.nationality == "E") { 1431 str1.append(c1.companyName); 1432 } else { 1433 str1.append(c1.rif); 1434 } 1431 1435 } 1432 1436 … … 1441 1445 c2.levels.for_each(AddLevelToStr(str2)); 1442 1446 1443 str2.append(c2.rif); 1447 if (c2.nationality == "E") { 1448 str2.append(c2.companyName); 1449 } else { 1450 str2.append(c2.rif); 1451 } 1444 1452 } 1445 1453 … … 1451 1459 1452 1460 typedef Map <ClusterByPlantInfo, NodeSet, 1453 1461 ClusterByPlantInfoCmp> ClusterMap; 1454 1462 1455 1463 /// Functor para escribir información completa de un nodo en un dot. -
simulacion/SimEscenariosEconomicos/productionNetwork.H
r7941763 r78c6ae6 132 132 133 133 bool operator () (const Company & c1, const Company & c2) { 134 return c1.getRif() < c2.getRif(); 134 135 const std::string & str1 = c1.getNationality() == "E" 136 ? c1.getName() : c1.getRif(); 137 138 const std::string & str2 = c2.getNationality() == "E" 139 ? c2.getName() : c2.getRif(); 140 141 return str1 < str2; 135 142 } 136 143 }; -
simulacion/SimEscenariosEconomicos/queries.C
r7941763 r78c6ae6 495 495 496 496 real computeInputProportionFromSupplier(const std::string & supplierRif, 497 const size_t & inputId, 498 const std::string & year) { 499 500 AutoConnection conn; 501 502 DBQuery query(conn); 503 504 StrQuery strQuery; 505 506 strQuery.addSelect(concatas(DB::SUPPLIER_TABLE_NAME, DB::RIF)); 497 const std::string & supplierName, 498 const std::string & nationality, 499 const size_t & inputId, 500 const std::string & year) { 501 502 AutoConnection conn; 503 504 DBQuery query(conn); 505 506 StrQuery strQuery; 507 508 const std::string & to_compare = nationality == "E" ? 509 supplierName : supplierRif; 510 511 if (nationality == "E") { 512 strQuery.addSelect(concatas(DB::SUPPLIER_TABLE_NAME, DB::NAME)); 513 } else { 514 strQuery.addSelect(concatas(DB::SUPPLIER_TABLE_NAME, DB::RIF)); 515 } 507 516 strQuery.addSelect(concatas(DB::INPUT_SUPPLIER_TABLE_NAME, 508 517 DB::BOUGHT_QUANTITY)); … … 531 540 while (query.next()) { 532 541 533 if ( supplierRif == query.getValue(0))542 if (to_compare == query.getValue(0)) { 534 543 suppliedQuantity = std::atof(query.getValue(1)); 544 } 535 545 536 546 sum += std::atof(query.getValue(1)); … … 541 551 542 552 real computeProportionByTariffCode(const std::string & tariffCode, 543 544 545 553 const std::string & rif, 554 const size_t & productId, 555 const std::string & year) { 546 556 547 557 AutoConnection conn; … … 605 615 606 616 std::string rif; 617 std::string companyName; 618 std::string nationality; 607 619 608 620 if (src->getType() == PRODUCT_GOOD) { … … 611 623 612 624 rif = product->getProducerPlant()->getOwnerCompany()->getRif(); 625 companyName = product->getProducerPlant()->getOwnerCompany()->getName(); 626 nationality = 627 product->getProducerPlant()->getOwnerCompany()->getNationality(); 613 628 614 629 } else { … … 617 632 618 633 rif = input->getProviderCompany()->getRif(); 634 companyName = input->getProviderCompany()->getName(); 635 nationality = input->getProviderCompany()->getNationality(); 619 636 } 620 637 621 638 real proportionFromSupplier = 622 computeInputProportionFromSupplier(rif, info.inputId, year); 639 computeInputProportionFromSupplier(rif, companyName, nationality, 640 info.inputId, year); 623 641 624 642 real proportionByTariffCode =
Note: See TracChangeset
for help on using the changeset viewer.