Changeset fdefa21 in tol


Ignore:
Timestamp:
Sep 15, 2009, 1:43:38 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
81b4553
Parents:
2b098a4
Message:

Preparing for new modular parser

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1377 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/btol/vmatrix_type
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/vmatrix_type/tol_bvmat_bsr.h

    r2b098a4 rfdefa21  
    364364    BVMat&                  a,
    365365    BVMat&                  A);
     366  int Parse_Module_Joint(
     367    const BText& filePath,
     368    BSet& contens_);
    366369
    367370};
  • tol/btol/vmatrix_type/tol_bvmat_bsr_impl.h

    r2b098a4 rfdefa21  
    2929#include <tol/tol_bvmat_impl.h>
    3030#include <tol/tol_bvmatgra.h>
     31#include <tol/tol_bmatgra.h>
     32#include <tol/tol_bdatgra.h>
     33#include <tol/tol_btxtgra.h>
     34#include <tol/tol_bsetgra.h>
     35#include <tol/tol_bpolgra.h>
     36#include <tol/tol_bratgra.h>
     37#include <tol/tol_bdtegra.h>
     38#include <tol/tol_btmsgra.h>
     39#include <tol/tol_bcodgra.h>
    3140#include <tol/tol_blanguag.h>
    3241#include <tol/tol_bdir.h>
  • tol/btol/vmatrix_type/vmat_bsr.cpp

    r2b098a4 rfdefa21  
    10281028};
    10291029
     1030
     1031////////////////////////////////////////////////////////////////////////////////
     1032int Parse_Module_Joint(const BText& filePath, BSet& contens_)
     1033////////////////////////////////////////////////////////////////////////////////
     1034{
     1035  string fileName = filePath.String();
     1036  int k,h;
     1037  BVMat Y,X,a,A;
     1038  BArray<BVMat> VSArr;
     1039  BysSparseReg::doc_info                     docInfo;   
     1040  std::vector<BysSparseReg::variable_info>   linearInfo;
     1041  std::vector<BysSparseReg::missing_info>    inputMissingInfo;
     1042  std::vector<BysSparseReg::missing_info>    outputMissingInfo;
     1043  std::vector<BysSparseReg::noise_info>      noiseInfo;
     1044  BysSparseReg::Parse_Module_Joint
     1045  (
     1046    fileName, docInfo,
     1047    linearInfo,inputMissingInfo,outputMissingInfo,noiseInfo,
     1048    Y, X, a, A
     1049  );
     1050  BSet HD, LI, DI, MI, MO;
     1051  BGrammar::IncLevel();
     1052  LI.PrepareStore(linearInfo.size());
     1053  for(k=0; k<linearInfo.size(); k++)
     1054  {
     1055    BText name = linearInfo[k].name.c_str();
     1056    BSet aux;
     1057    aux.PrepareStore(2);
     1058    aux.AddElement(BContensText::New("",name, ""));
     1059    aux.AddElement(BContensDat ::New("",linearInfo[k].initValue,""));
     1060    aux.PutStruct(BysSparseReg::LinearBlockStr());
     1061    LI.AddElement(BContensSet::New(name,aux,""));
     1062  }
     1063  if(LI.Card()) { LI.SetIndexByName(); }
     1064  MI.PrepareStore(inputMissingInfo.size());
     1065  for(k=0; k<inputMissingInfo.size(); k++)
     1066  {
     1067    BText name = inputMissingInfo[k].name.c_str();
     1068    BSet aux;
     1069    aux.PrepareStore(9);
     1070    aux.AddElement(BContensText::New("",name,                              ""));
     1071    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].index,         ""));
     1072    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].row,           ""));
     1073    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].col,           ""));
     1074    aux.AddElement(BContensText::New("",inputMissingInfo[k].prior.c_str(), ""));
     1075    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].nu,            ""));
     1076    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].sigma2,        ""));
     1077    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].minBound,      ""));
     1078    aux.AddElement(BContensDat ::New("",inputMissingInfo[k].maxBound,      ""));
     1079    aux.PutStruct(BysSparseReg::MissingBlockStr());
     1080    MI.AddElement(BContensSet::New(name,aux,""));
     1081  }
     1082  if(MI.Card()) { MI.SetIndexByName(); }
     1083  MO.PrepareStore(outputMissingInfo.size());
     1084  for(k=0; k<outputMissingInfo.size(); k++)
     1085  {
     1086    BText name = outputMissingInfo[k].name.c_str();
     1087    BSet aux;
     1088    aux.PrepareStore(9);
     1089    aux.AddElement(BContensText::New("",name,                               ""));
     1090    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].index,         ""));
     1091    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].row,           ""));
     1092    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].col,           ""));
     1093    aux.AddElement(BContensText::New("",outputMissingInfo[k].prior.c_str(), ""));
     1094    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].nu,            ""));
     1095    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].sigma2,        ""));
     1096    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].minBound,      ""));
     1097    aux.AddElement(BContensDat ::New("",outputMissingInfo[k].maxBound,      ""));
     1098    aux.PutStruct(BysSparseReg::MissingBlockStr());
     1099    MO.AddElement(BContensSet::New(name,aux,""));
     1100  }
     1101  if(MO.Card()) { MO.SetIndexByName(); }
     1102  DI.PrepareStore(noiseInfo.size());
     1103  for(k=0; k<noiseInfo.size(); k++)
     1104  {
     1105    BText name = noiseInfo[k].name.c_str();
     1106    BGrammar::IncLevel();
     1107    BSet aux;
     1108    BSet aux2;
     1109    std::vector<int>& equIdx=noiseInfo[k].equIdx;
     1110    aux2.PrepareStore(equIdx.size());
     1111    for(h=0; h<equIdx.size(); h++)
     1112    {
     1113      aux2.AddElement(BContensDat::New("",equIdx[h],""));
     1114    }
     1115    aux.PrepareStore(10);
     1116    aux.AddElement(BContensText::New
     1117    (
     1118      "Name",     
     1119      name,     
     1120      ""
     1121    ));
     1122    aux.AddElement(BContensDat::New
     1123    (
     1124      "Nu",             
     1125      noiseInfo[k].nu,               
     1126      ""
     1127    ));
     1128    aux.AddElement(BContensText::New
     1129    (
     1130      "SigmaName",     
     1131      noiseInfo[k].sigmaName.c_str(),
     1132      ""
     1133    ));
     1134    aux.AddElement(BContensDat::New
     1135    (
     1136      "SigmaIndex",
     1137      noiseInfo[k].sigmaIdx,
     1138      ""
     1139    ));
     1140    BSyntaxObject* sigPri = NULL;
     1141    BText expr = noiseInfo[k].sigPriExpr.c_str();
     1142    if(expr=="")
     1143    {
     1144      sigPri = GraSet()->EvaluateExpr("Copy(Empty)");
     1145    }
     1146    else
     1147    {
     1148      sigPri = GraSet()->EvaluateExpr(expr);
     1149      if(!sigPri)
     1150      {
     1151        Error(I2("[BSR] Cannot evaluate SigmaPrior expression for ",
     1152                 "[BSR] No se puede evaluar la expresión del SigmaPrior para ")+
     1153              noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
     1154        sigPri = GraSet()->EvaluateExpr("Copy(Empty)");
     1155      }
     1156    }
     1157    sigPri->PutName("SigmaPrior");
     1158    aux.AddElement(sigPri);
     1159    BSyntaxObject* arima = NULL;
     1160    expr = noiseInfo[k].arimaExpr.c_str();
     1161    if(!expr.HasName())
     1162    {
     1163      arima = GraSet()->EvaluateExpr("Copy(Empty)");
     1164    }
     1165    else
     1166    {
     1167  //Std(BText("  ARIMA expression for ")+noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
     1168      arima = GraSet()->EvaluateExpr(expr);
     1169      if(!arima)
     1170      {
     1171        Error(I2("[BSR] Cannot evaluate ARIMA expression for ",
     1172                 "[BSR] No se puede evaluar la expresión ARIMA para ")+
     1173              noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
     1174        arima = GraSet()->EvaluateExpr("Copy(Empty)");
     1175      }
     1176    }
     1177    arima->PutName("Arima");
     1178    aux.AddElement(arima);
     1179    BSyntaxObject* arimaAuxInfo = GraSet()->EvaluateExpr("Copy(Empty)");
     1180    arimaAuxInfo->PutName("ArimaAuxInfo");
     1181    aux.AddElement(arimaAuxInfo);
     1182    aux.AddElement(BContensVMat::New
     1183    (
     1184      "COV",
     1185      noiseInfo[k].cov,
     1186      ""
     1187    ));
     1188    assert(noiseInfo[k].cov.Check());
     1189    aux.AddElement(BContensVMat::New
     1190    (
     1191      "L", 
     1192      noiseInfo[k].L,               
     1193      "COV=L'L"
     1194    ));
     1195    assert(noiseInfo[k].L.Check());
     1196    aux.AddElement(BContensVMat::New
     1197    (
     1198      "Li",
     1199      noiseInfo[k].Li,
     1200      "L*Li=I"
     1201    ));
     1202    assert(noiseInfo[k].Li.Check());
     1203    aux.AddElement(BContensSet::New
     1204    (
     1205      "EquationIndexes",
     1206      aux2,                               
     1207      ""
     1208    ));
     1209    BSyntaxObject* timeInfo  = NULL;
     1210    if(noiseInfo[k].dating != "")
     1211    {
     1212      BUserTimeSet* dating = (BUserTimeSet*)
     1213        GraTimeSet()->EvaluateExpr(noiseInfo[k].dating.c_str());
     1214      if(!dating)
     1215      {
     1216        Error(I2("[BSR] Cannot evaluate dating expression for ",
     1217                 "[BSR] No se puede evaluar la expresión de fechado para ")+
     1218              noiseInfo[k].dating.c_str()+"=\n"+expr+"\n");
     1219      }
     1220      else
     1221      {
     1222        BUserDate* firstDate = (BUserDate*)
     1223          GraDate()->EvaluateExpr(noiseInfo[k].firstDate.c_str());
     1224        if(!firstDate)
     1225        {
     1226          Error(I2("[BSR] Cannot evaluate first date expression for ",
     1227                   "[BSR] No se puede evaluar la expresión de fecha inicial para ")+
     1228                noiseInfo[k].firstDate.c_str()+"\n");
     1229          DESTROY(dating);
     1230        }
     1231        else if(!dating->Includes(firstDate->Contens()))
     1232        {
     1233          Error(I2("[BSR] First date ", "[BSR] La fecha inicial ")+
     1234                noiseInfo[k].firstDate.c_str()+
     1235                I2("doesn't match dating ", " no es del fechado ")+
     1236                noiseInfo[k].dating.c_str()+"\n");
     1237          DESTROY(dating);
     1238          DESTROY(firstDate);
     1239        }
     1240        else
     1241        {
     1242          BUserDate* lastDate  = (BUserDate*)
     1243            GraDate()->EvaluateExpr(noiseInfo[k].lastDate.c_str());
     1244          if(!lastDate)
     1245          {
     1246            Error(I2("[BSR] Cannot evaluate last date expression for ",
     1247                     "[BSR] No se puede evaluar la expresión de fecha final para ")+
     1248                  noiseInfo[k].firstDate.c_str()+"\n");
     1249            DESTROY(dating);
     1250            DESTROY(firstDate);
     1251          }
     1252          else
     1253          {
     1254            int length =
     1255              1+dating->Difference(firstDate->Contens(),lastDate->Contens());
     1256            if(length != equIdx.size())
     1257            {
     1258              Error(I2("[BSR] Interval between first and last dates ",
     1259                       "[BSR] El intervalo entre las fechas inicial y final ")+
     1260                    "["+noiseInfo[k].firstDate.c_str()+";"+
     1261                        noiseInfo[k].lastDate.c_str()+"]"+
     1262                    I2(" along dating ", " a lo largo del fechado ")+
     1263                      noiseInfo[k].dating.c_str()+
     1264                    I2(" has length "," tiene longitud ")+length+
     1265                    I2(" but noise ", " pero el ruido ")+name+
     1266                    I2(" was declared with length "," fue declarado de longitud ")+
     1267                    (int)equIdx.size()+"\n");
     1268              DESTROY(dating);
     1269              DESTROY(firstDate);
     1270              DESTROY(lastDate); 
     1271            }
     1272            else
     1273            {
     1274              BSet auxTimeInfo;
     1275              auxTimeInfo.PrepareStore(3);
     1276              auxTimeInfo.AddElement(dating);
     1277              auxTimeInfo.AddElement(firstDate);
     1278              auxTimeInfo.AddElement(lastDate);
     1279              auxTimeInfo.PutStruct(BysSparseReg::NoiseTimeInfo());
     1280              timeInfo = BContensSet::New("",auxTimeInfo,"TimeInfo");
     1281            }
     1282          }
     1283        }
     1284      }
     1285    }
     1286    if(!timeInfo)
     1287    {
     1288      timeInfo = GraSet()->EvaluateExpr("Copy(Empty)");
     1289    }
     1290    timeInfo->PutName("TimeInfo");
     1291    aux.AddElement(timeInfo);
     1292
     1293    aux.PutStruct(BysSparseReg::NoiseDistribStr());
     1294    DI.AddElement(BContensSet::New(name,aux,""));
     1295    BGrammar::DecLevel();
     1296  }
     1297  if(DI.Card()) { DI.SetIndexByName(); }
     1298  HD.PrepareStore(6);
     1299  HD.AddElement(BContensText::New
     1300  (
     1301    "Model.Name",
     1302    docInfo.model_name.c_str(),
     1303    "Model identifier"
     1304  ));
     1305  HD.AddElement(BContensText::New
     1306  (
     1307    "Model.Description",
     1308    docInfo.model_description.c_str(),
     1309    "Notes about the model"
     1310  ));
     1311  HD.AddElement(BContensText::New
     1312  (
     1313    "Session.Name",
     1314    docInfo.session_name.c_str(),
     1315    "Session identifier"
     1316  ));
     1317  HD.AddElement(BContensText::New
     1318  (
     1319    "Session.Description",
     1320    docInfo.session_description.c_str(),
     1321    "Notes about the session"
     1322  ));
     1323  HD.AddElement(BContensText::New
     1324  (
     1325    "Session.Authors",     
     1326    docInfo.session_authors.c_str(),
     1327    "Name, e-mail, url or any identifier of session authors separated by commas"
     1328  ));
     1329  HD.AddElement(BContensDate::New
     1330  (
     1331    "Session.Creation",     
     1332    DteNow(),
     1333    "Session creation date and time"
     1334  ));
     1335  HD.AddElement(BContensText::New
     1336  (
     1337    "Path",       
     1338    GetFilePath(filePath),
     1339    "The root path of directory used to store all information related to this model is the same of BSR ASCII file"
     1340  ));
     1341  HD.PutStruct(BysSparseReg::DocInfoStr());
     1342
     1343  contens_.PrepareStore(9);
     1344  contens_.AddElement(BContensSet::New
     1345  (
     1346    "DocInfo",
     1347    HD,
     1348    "Header documentary information"
     1349  ));
     1350  contens_.AddElement(BContensSet ::New
     1351  (
     1352    "LinearBlock",
     1353    LI, 
     1354    "Linear block information is a table with structure "
     1355    "BSR.LinearBlockStr"
     1356  ));
     1357  contens_.AddElement(BContensSet ::New
     1358  (
     1359    "MissingInputBlock",
     1360    MI, 
     1361    "Missing Input block information is a table with structure "
     1362    "BSR.MissingBlockStr"
     1363  ));
     1364  contens_.AddElement(BContensSet ::New
     1365  (
     1366    "MissingOutputBlock",
     1367    MO, 
     1368    "Missing Output block information is a table with structure "
     1369    "BSR.MissingBlockStr"
     1370  ));
     1371  contens_.AddElement(BContensSet ::New
     1372  (
     1373    "NoiseDistrib",
     1374    DI, 
     1375    "Noise distribution information is a table with structure "
     1376    "BSR.SigmaBlockStr"
     1377  ));
     1378  contens_.AddElement(BContensVMat::New
     1379  (
     1380    "Y",         
     1381    Y,   
     1382    "Regression output"
     1383  ));
     1384  contens_.AddElement(BContensVMat::New
     1385  (
     1386    "X",         
     1387    X,   
     1388    "Regression input"
     1389  ));
     1390  contens_.AddElement(BContensVMat::New
     1391  (
     1392    "a",         
     1393    a,   
     1394    "Restrictions border"
     1395  ));
     1396  contens_.AddElement(BContensVMat::New
     1397  (
     1398    "A",         
     1399    A,   
     1400    "Restrictions coefficients"
     1401  )); 
     1402  contens_.PutStruct(BysSparseReg::ModelDefStr());
     1403  BGrammar::DecLevel();
     1404  assert(Y.Check());
     1405  assert(X.Check());
     1406  assert(a.Check());
     1407  assert(A.Check());
     1408}
     1409
    10301410};
    10311411
  • tol/btol/vmatrix_type/vmatgra.cpp

    r2b098a4 rfdefa21  
    23462346//--------------------------------------------------------------------
    23472347{
    2348   int k,h;
    23492348  BText& filePath = Text(Arg(1));
    2350   string fileName = filePath.String();
    2351   BVMat Y,X,a,A;
    2352   BArray<BVMat> VSArr;
    2353   BysSparseReg::doc_info                     docInfo;   
    2354   std::vector<BysSparseReg::variable_info>   linearInfo;
    2355   std::vector<BysSparseReg::missing_info>    inputMissingInfo;
    2356   std::vector<BysSparseReg::missing_info>    outputMissingInfo;
    2357   std::vector<BysSparseReg::noise_info>      noiseInfo;
    2358   BysSparseReg::Parse_Module_Joint
    2359   (
    2360     fileName, docInfo,
    2361     linearInfo,inputMissingInfo,outputMissingInfo,noiseInfo,
    2362     Y, X, a, A
    2363   );
    2364   BSet HD, LI, DI, MI, MO;
    2365   BGrammar::IncLevel();
    2366   LI.PrepareStore(linearInfo.size());
    2367   for(k=0; k<linearInfo.size(); k++)
    2368   {
    2369     BText name = linearInfo[k].name.c_str();
    2370     BSet aux;
    2371     aux.PrepareStore(2);
    2372     aux.AddElement(BContensText::New("",name, ""));
    2373     aux.AddElement(BContensDat ::New("",linearInfo[k].initValue,""));
    2374     aux.PutStruct(BysSparseReg::LinearBlockStr());
    2375     LI.AddElement(BContensSet::New(name,aux,""));
    2376   }
    2377   if(LI.Card()) { LI.SetIndexByName(); }
    2378   MI.PrepareStore(inputMissingInfo.size());
    2379   for(k=0; k<inputMissingInfo.size(); k++)
    2380   {
    2381     BText name = inputMissingInfo[k].name.c_str();
    2382     BSet aux;
    2383     aux.PrepareStore(9);
    2384     aux.AddElement(BContensText::New("",name,                              ""));
    2385     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].index,         ""));
    2386     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].row,           ""));
    2387     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].col,           ""));
    2388     aux.AddElement(BContensText::New("",inputMissingInfo[k].prior.c_str(), ""));
    2389     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].nu,            ""));
    2390     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].sigma2,        ""));
    2391     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].minBound,      ""));
    2392     aux.AddElement(BContensDat ::New("",inputMissingInfo[k].maxBound,      ""));
    2393     aux.PutStruct(BysSparseReg::MissingBlockStr());
    2394     MI.AddElement(BContensSet::New(name,aux,""));
    2395   }
    2396   if(MI.Card()) { MI.SetIndexByName(); }
    2397   MO.PrepareStore(outputMissingInfo.size());
    2398   for(k=0; k<outputMissingInfo.size(); k++)
    2399   {
    2400     BText name = outputMissingInfo[k].name.c_str();
    2401     BSet aux;
    2402     aux.PrepareStore(9);
    2403     aux.AddElement(BContensText::New("",name,                               ""));
    2404     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].index,         ""));
    2405     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].row,           ""));
    2406     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].col,           ""));
    2407     aux.AddElement(BContensText::New("",outputMissingInfo[k].prior.c_str(), ""));
    2408     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].nu,            ""));
    2409     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].sigma2,        ""));
    2410     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].minBound,      ""));
    2411     aux.AddElement(BContensDat ::New("",outputMissingInfo[k].maxBound,      ""));
    2412     aux.PutStruct(BysSparseReg::MissingBlockStr());
    2413     MO.AddElement(BContensSet::New(name,aux,""));
    2414   }
    2415   if(MO.Card()) { MO.SetIndexByName(); }
    2416   DI.PrepareStore(noiseInfo.size());
    2417   for(k=0; k<noiseInfo.size(); k++)
    2418   {
    2419     BText name = noiseInfo[k].name.c_str();
    2420     BGrammar::IncLevel();
    2421     BSet aux;
    2422     BSet aux2;
    2423     std::vector<int>& equIdx=noiseInfo[k].equIdx;
    2424     aux2.PrepareStore(equIdx.size());
    2425     for(h=0; h<equIdx.size(); h++)
    2426     {
    2427       aux2.AddElement(BContensDat::New("",equIdx[h],""));
    2428     }
    2429     aux.PrepareStore(10);
    2430     aux.AddElement(BContensText::New
    2431     (
    2432       "Name",     
    2433       name,     
    2434       ""
    2435     ));
    2436     aux.AddElement(BContensDat::New
    2437     (
    2438       "Nu",             
    2439       noiseInfo[k].nu,               
    2440       ""
    2441     ));
    2442     aux.AddElement(BContensText::New
    2443     (
    2444       "SigmaName",     
    2445       noiseInfo[k].sigmaName.c_str(),
    2446       ""
    2447     ));
    2448     aux.AddElement(BContensDat::New
    2449     (
    2450       "SigmaIndex",
    2451       noiseInfo[k].sigmaIdx,
    2452       ""
    2453     ));
    2454     BSyntaxObject* sigPri = NULL;
    2455     BText expr = noiseInfo[k].sigPriExpr.c_str();
    2456     if(expr=="")
    2457     {
    2458       sigPri = GraSet()->EvaluateExpr("Copy(Empty)");
    2459     }
    2460     else
    2461     {
    2462       sigPri = GraSet()->EvaluateExpr(expr);
    2463       if(!sigPri)
    2464       {
    2465         Error(I2("[BSR] Cannot evaluate SigmaPrior expression for ",
    2466                  "[BSR] No se puede evaluar la expresión del SigmaPrior para ")+
    2467               noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
    2468         sigPri = GraSet()->EvaluateExpr("Copy(Empty)");
    2469       }
    2470     }
    2471     sigPri->PutName("SigmaPrior");
    2472     aux.AddElement(sigPri);
    2473     BSyntaxObject* arima = NULL;
    2474     expr = noiseInfo[k].arimaExpr.c_str();
    2475     if(!expr.HasName())
    2476     {
    2477       arima = GraSet()->EvaluateExpr("Copy(Empty)");
    2478     }
    2479     else
    2480     {
    2481   //Std(BText("  ARIMA expression for ")+noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
    2482       arima = GraSet()->EvaluateExpr(expr);
    2483       if(!arima)
    2484       {
    2485         Error(I2("[BSR] Cannot evaluate ARIMA expression for ",
    2486                  "[BSR] No se puede evaluar la expresión ARIMA para ")+
    2487               noiseInfo[k].name.c_str()+"=\n"+expr+"\n");
    2488         arima = GraSet()->EvaluateExpr("Copy(Empty)");
    2489       }
    2490     }
    2491     arima->PutName("Arima");
    2492     aux.AddElement(arima);
    2493     BSyntaxObject* arimaAuxInfo = GraSet()->EvaluateExpr("Copy(Empty)");
    2494     arimaAuxInfo->PutName("ArimaAuxInfo");
    2495     aux.AddElement(arimaAuxInfo);
    2496     aux.AddElement(BContensVMat::New
    2497     (
    2498       "COV",
    2499       noiseInfo[k].cov,
    2500       ""
    2501     ));
    2502     assert(noiseInfo[k].cov.Check());
    2503     aux.AddElement(BContensVMat::New
    2504     (
    2505       "L", 
    2506       noiseInfo[k].L,               
    2507       "COV=L'L"
    2508     ));
    2509     assert(noiseInfo[k].L.Check());
    2510     aux.AddElement(BContensVMat::New
    2511     (
    2512       "Li",
    2513       noiseInfo[k].Li,
    2514       "L*Li=I"
    2515     ));
    2516     assert(noiseInfo[k].Li.Check());
    2517     aux.AddElement(BContensSet::New
    2518     (
    2519       "EquationIndexes",
    2520       aux2,                               
    2521       ""
    2522     ));
    2523     BSyntaxObject* timeInfo  = NULL;
    2524     if(noiseInfo[k].dating != "")
    2525     {
    2526       BUserTimeSet* dating = (BUserTimeSet*)
    2527         GraTimeSet()->EvaluateExpr(noiseInfo[k].dating.c_str());
    2528       if(!dating)
    2529       {
    2530         Error(I2("[BSR] Cannot evaluate dating expression for ",
    2531                  "[BSR] No se puede evaluar la expresión de fechado para ")+
    2532               noiseInfo[k].dating.c_str()+"=\n"+expr+"\n");
    2533       }
    2534       else
    2535       {
    2536         BUserDate* firstDate = (BUserDate*)
    2537           GraDate()->EvaluateExpr(noiseInfo[k].firstDate.c_str());
    2538         if(!firstDate)
    2539         {
    2540           Error(I2("[BSR] Cannot evaluate first date expression for ",
    2541                    "[BSR] No se puede evaluar la expresión de fecha inicial para ")+
    2542                 noiseInfo[k].firstDate.c_str()+"\n");
    2543           DESTROY(dating);
    2544         }
    2545         else if(!dating->Includes(firstDate->Contens()))
    2546         {
    2547           Error(I2("[BSR] First date ", "[BSR] La fecha inicial ")+
    2548                 noiseInfo[k].firstDate.c_str()+
    2549                 I2("doesn't match dating ", " no es del fechado ")+
    2550                 noiseInfo[k].dating.c_str()+"\n");
    2551           DESTROY(dating);
    2552           DESTROY(firstDate);
    2553         }
    2554         else
    2555         {
    2556           BUserDate* lastDate  = (BUserDate*)
    2557             GraDate()->EvaluateExpr(noiseInfo[k].lastDate.c_str());
    2558           if(!lastDate)
    2559           {
    2560             Error(I2("[BSR] Cannot evaluate last date expression for ",
    2561                      "[BSR] No se puede evaluar la expresión de fecha final para ")+
    2562                   noiseInfo[k].firstDate.c_str()+"\n");
    2563             DESTROY(dating);
    2564             DESTROY(firstDate);
    2565           }
    2566           else
    2567           {
    2568             int length =
    2569               1+dating->Difference(firstDate->Contens(),lastDate->Contens());
    2570             if(length != equIdx.size())
    2571             {
    2572               Error(I2("[BSR] Interval between first and last dates ",
    2573                        "[BSR] El intervalo entre las fechas inicial y final ")+
    2574                     "["+noiseInfo[k].firstDate.c_str()+";"+
    2575                         noiseInfo[k].lastDate.c_str()+"]"+
    2576                     I2(" along dating ", " a lo largo del fechado ")+
    2577                       noiseInfo[k].dating.c_str()+
    2578                     I2(" has length "," tiene longitud ")+length+
    2579                     I2(" but noise ", " pero el ruido ")+name+
    2580                     I2(" was declared with length "," fue declarado de longitud ")+
    2581                     (int)equIdx.size()+"\n");
    2582               DESTROY(dating);
    2583               DESTROY(firstDate);
    2584               DESTROY(lastDate); 
    2585             }
    2586             else
    2587             {
    2588               BSet auxTimeInfo;
    2589               auxTimeInfo.PrepareStore(3);
    2590               auxTimeInfo.AddElement(dating);
    2591               auxTimeInfo.AddElement(firstDate);
    2592               auxTimeInfo.AddElement(lastDate);
    2593               auxTimeInfo.PutStruct(BysSparseReg::NoiseTimeInfo());
    2594               timeInfo = BContensSet::New("",auxTimeInfo,"TimeInfo");
    2595             }
    2596           }
    2597         }
    2598       }
    2599     }
    2600     if(!timeInfo)
    2601     {
    2602       timeInfo = GraSet()->EvaluateExpr("Copy(Empty)");
    2603     }
    2604     timeInfo->PutName("TimeInfo");
    2605     aux.AddElement(timeInfo);
    2606 
    2607     aux.PutStruct(BysSparseReg::NoiseDistribStr());
    2608     DI.AddElement(BContensSet::New(name,aux,""));
    2609     BGrammar::DecLevel();
    2610   }
    2611   if(DI.Card()) { DI.SetIndexByName(); }
    2612   HD.PrepareStore(6);
    2613   HD.AddElement(BContensText::New
    2614   (
    2615     "Model.Name",
    2616     docInfo.model_name.c_str(),
    2617     "Model identifier"
    2618   ));
    2619   HD.AddElement(BContensText::New
    2620   (
    2621     "Model.Description",
    2622     docInfo.model_description.c_str(),
    2623     "Notes about the model"
    2624   ));
    2625   HD.AddElement(BContensText::New
    2626   (
    2627     "Session.Name",
    2628     docInfo.session_name.c_str(),
    2629     "Session identifier"
    2630   ));
    2631   HD.AddElement(BContensText::New
    2632   (
    2633     "Session.Description",
    2634     docInfo.session_description.c_str(),
    2635     "Notes about the session"
    2636   ));
    2637   HD.AddElement(BContensText::New
    2638   (
    2639     "Session.Authors",     
    2640     docInfo.session_authors.c_str(),
    2641     "Name, e-mail, url or any identifier of session authors separated by commas"
    2642   ));
    2643   HD.AddElement(BContensDate::New
    2644   (
    2645     "Session.Creation",     
    2646     DteNow(),
    2647     "Session creation date and time"
    2648   ));
    2649   HD.AddElement(BContensText::New
    2650   (
    2651     "Path",       
    2652     GetFilePath(filePath),
    2653     "The root path of directory used to store all information related to this model is the same of BSR ASCII file"
    2654   ));
    2655   HD.PutStruct(BysSparseReg::DocInfoStr());
    2656 
    2657   contens_.PrepareStore(9);
    2658   contens_.AddElement(BContensSet::New
    2659   (
    2660     "DocInfo",
    2661     HD,
    2662     "Header documentary information"
    2663   ));
    2664   contens_.AddElement(BContensSet ::New
    2665   (
    2666     "LinearBlock",
    2667     LI, 
    2668     "Linear block information is a table with structure "
    2669     "BSR.LinearBlockStr"
    2670   ));
    2671   contens_.AddElement(BContensSet ::New
    2672   (
    2673     "MissingInputBlock",
    2674     MI, 
    2675     "Missing Input block information is a table with structure "
    2676     "BSR.MissingBlockStr"
    2677   ));
    2678   contens_.AddElement(BContensSet ::New
    2679   (
    2680     "MissingOutputBlock",
    2681     MO, 
    2682     "Missing Output block information is a table with structure "
    2683     "BSR.MissingBlockStr"
    2684   ));
    2685   contens_.AddElement(BContensSet ::New
    2686   (
    2687     "NoiseDistrib",
    2688     DI, 
    2689     "Noise distribution information is a table with structure "
    2690     "BSR.SigmaBlockStr"
    2691   ));
    2692   contens_.AddElement(BContensVMat::New
    2693   (
    2694     "Y",         
    2695     Y,   
    2696     "Regression output"
    2697   ));
    2698   contens_.AddElement(BContensVMat::New
    2699   (
    2700     "X",         
    2701     X,   
    2702     "Regression input"
    2703   ));
    2704   contens_.AddElement(BContensVMat::New
    2705   (
    2706     "a",         
    2707     a,   
    2708     "Restrictions border"
    2709   ));
    2710   contens_.AddElement(BContensVMat::New
    2711   (
    2712     "A",         
    2713     A,   
    2714     "Restrictions coefficients"
    2715   )); 
    2716   contens_.PutStruct(BysSparseReg::ModelDefStr());
    2717   BGrammar::DecLevel();
    2718   assert(Y.Check());
    2719   assert(X.Check());
    2720   assert(a.Check());
    2721   assert(A.Check());
    2722 }
    2723 
    2724 
     2349  BysSparseReg::Parse_Module_Joint(filePath, contens_);
     2350}
     2351
     2352
Note: See TracChangeset for help on using the changeset viewer.