Changeset e7bf535 in tol
- Timestamp:
- Oct 26, 2008, 10:34:31 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 52582cf
- Parents:
- 231d038
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/_import.tol
r231d038 re7bf535 85 85 /////////////////////////////////////////////////////////////////////////// 86 86 { 87 Real f = fileHandler;88 87 Text model.name = model::Get.Doc.Model.Name(0); 89 88 Text model.desc = model::Get.Doc.Model.Description(0); … … 92 91 Text session.authors = model::Get.Doc.Session.Authors(0); 93 92 WriteLn(_MID+"Writing header ..."); 94 Real FPutText(f ,93 Real FPutText(fileHandler, 95 94 _comment+ 96 95 "// Bayesian Sparse Regression \n"+ 97 96 _comment+ 97 "\n"+ 98 "$BEGIN\n" 98 99 "\n"+ 99 100 "Model.Name = \""+model.name+"\";\n" … … 107 108 108 109 /////////////////////////////////////////////////////////////////////////// 109 Real Write.MainLinearBlock(NameBlock model, Real fileHandler) 110 /////////////////////////////////////////////////////////////////////////// 111 { 112 Real f = fileHandler; 113 //Escribo valores iniciales de los parametros. Se asume que cada 114 //segmento es "owner" de los parametros que solo aparecen en el y que 115 //cada parametro aparece en algun segmento que lo posee. 116 WriteLn(_MID+"Writing definition of main linear block parameters"); 117 Real FPutText(f, 118 "\n\n"+_comment+ 119 "// Defining Regression Variables\n"+ 120 _comment+ 121 "\n"); 122 123 Real iB = 1; 124 Real numSegment = model::Get.LinReg.Size(0); 125 Real While(iB<=numSegment, Real 126 { 127 NameBlock segment = model::Get.LinReg.Segment(iB); 128 Set For(1,segment::Get.Param.Size(0), Real(Real k) 110 Real Write.Data.MainLinearBlock(NameBlock segment, 111 Real fileHandler) 112 /////////////////////////////////////////////////////////////////////////// 113 { 114 WriteLn(_MID+" segment "+segment::Get.Name(0)); 115 Set For(1,segment::Get.Param.Size(0), Real(Real k) 116 { 117 Set P = segment::Get.Param(k); 118 Real iv = If(IsUnknown(P->InitValue), 119 Rand(P->LowerBound, P->UpperBound), 120 P->InitValue); 121 FPutText(fileHandler, P->Name+" <- "+ RealTextS(iv)+";\n"); 122 Real 0 123 }); 124 0 125 }; 126 127 /////////////////////////////////////////////////////////////////////////// 128 Real Write.Data.MissingBlock(NameBlock segment, 129 Real fileHandler) 130 /////////////////////////////////////////////////////////////////////////// 131 { 132 Set For(1,segment::Get.Missing.Size(0), Real(Real k) 133 { 134 Set P = segment::Get.Missing(k); 135 Real nr = LT(P->Prior.Sigma,+1/0); 136 Real lb = GT(P->Prior.LowerBound,-1/0); 137 Real ub = LT(P->Prior.UpperBound,+1/0); 138 Case(!nr & !lb & !ub, 129 139 { 130 Set P = segment::Get.Param(k); 131 Real iv = If(IsUnknown(P->InitValue), 132 Rand(P->LowerBound, P->UpperBound), 133 P->InitValue); 134 FPutText(f, P->Name+" <- "+ RealTextS(iv)+";\n"); 135 Real 0 140 FPutText(fileHandler, 141 P->Name+" ? <- "+RealTextS(P->Prior.Average)+";\n") 142 }, 143 !lb & !ub, 144 { 145 FPutText(fileHandler, P->Name+" ? ~ Normal("+ 146 RealTextS(P->Prior.Average)+","+ 147 RealTextS(P->Prior.Sigma)+");\n") 148 }, 149 1==1, 150 { 151 FPutText(fileHandler, P->Name+" ? ~ TruncatedNormal("+ 152 RealTextS(P->Prior.Average)+","+ 153 RealTextS(P->Prior.Sigma)+","+ 154 RealTextS(P->Prior.LowerBound)+","+ 155 RealTextS(P->Prior.UpperBound)+");\n") 136 156 }); 137 Real iB := iB+1 138 }); 139 0 140 }; 141 142 /////////////////////////////////////////////////////////////////////////// 143 Real Write.MissingBlock(NameBlock model, Real fileHandler) 144 /////////////////////////////////////////////////////////////////////////// 145 { 146 Real f = fileHandler; 147 WriteLn(_MID+"Writing definition of missing block parameters"); 148 Real FPutText(f, 149 "\n\n"+_comment+ 150 "// Defining Regression Missing Values\n"+ 151 _comment+ 152 "\n"); 153 Real numSegment = model::Get.LinReg.Size(0); 154 Real iB = 1; 155 Real While(iB<=numSegment, Real 156 { 157 NameBlock segment = model::Get.LinReg.Segment(iB); 158 Set For(1,segment::Get.Missing.Size(0), Real(Real k) 157 Real 0 158 }); 159 0 160 }; 161 162 /////////////////////////////////////////////////////////////////////////// 163 Real Write.Data.NoiseDistribution(NameBlock segment, 164 Real fileHandler) 165 /////////////////////////////////////////////////////////////////////////// 166 { 167 Set timeInfo = segment::Get.TimeInfo(0); 168 Text timeExpr = If(!Card(timeInfo),"", 169 { 170 " dating "+Identify(timeInfo->Dating) + 171 " from "+FormatDate(timeInfo->FirstDate,"%cy%Ym%md%dh%hi%is%s") + 172 " until "+FormatDate(timeInfo->LastDate,"%cy%Ym%md%dh%hi%is%s") 173 }); 174 FPutText(fileHandler, segment::Get.Name(0)+"::Noise" 175 "["+IntText(segment::Get.Equation.Size(0))+timeExpr+"]"+ 176 " ~ Normal(0,"<<segment::Get.Sigma2(0)); 177 Real arima.size = segment::Get.ARIMA.Size(0); 178 Real If(arima.size, 179 { 180 FPutText(fileHandler, "*ARIMA.COV([["); 181 Set For(1, arima.size, Real(Real af) 159 182 { 160 Set P = segment::Get.Missing(k); 161 Real nr = LT(P->Prior.Sigma,+1/0); 162 Real lb = GT(P->Prior.LowerBound,-1/0); 163 Real ub = LT(P->Prior.UpperBound,+1/0); 164 Case(!nr & !lb & !ub, 183 Set fac = segment::Get.ARIMA.Factor(af); 184 FPutText(fileHandler, If(af>1,",","")+"\n ARIMAStruct("<< 185 fac->Periodicity+","<< 186 fac->AR+","<< 187 fac->MA+","<< 188 fac->DIF+")") 189 }); 190 FPutText(fileHandler, "]])") 191 }); 192 FPutText(fileHandler, ");\n"); 193 0 194 }; 195 196 /////////////////////////////////////////////////////////////////////////// 197 Real Write.Data.RegressionEquations(NameBlock segment, 198 Real fileHandler) 199 /////////////////////////////////////////////////////////////////////////// 200 { 201 Text ResName = segment::Get.Name(0)+"::Noise"; 202 Real nEqu = segment::Get.Equation.Size(0); 203 WriteLn(_MID+"Escribiendo ecuaciones para el segmento "<< 204 ResName<<"["<<nEqu<<"]"); 205 Real iE = 1; 206 Real fefz = FunctionExist("Real", "segment::Get.Param.ForceZero"); 207 Real While(iE<=nEqu, Real 208 { 209 Real inpSiz = segment::Get.Equation.Input.Size(iE); 210 Text txt = "" << 211 segment::Get.Equation.Output(iE) + 212 " == " + 213 ResName+"["+IntText(iE)+"]" + 214 If(!inpSiz,"", SetSum(For(1, inpSiz, Text(Real term) 165 215 { 166 FPutText(f, P->Name+" ? <- "+RealTextS(P->Prior.Average)+";\n") 167 }, 168 !lb & !ub, 169 { 170 FPutText(f, P->Name+" ? ~ Normal("+ 171 RealTextS(P->Prior.Average)+","+ 172 RealTextS(P->Prior.Sigma)+");\n") 173 }, 174 1==1, 175 { 176 FPutText(f, P->Name+" ? ~ TruncatedNormal("+ 177 RealTextS(P->Prior.Average)+","+ 178 RealTextS(P->Prior.Sigma)+","+ 179 RealTextS(P->Prior.LowerBound)+","+ 180 RealTextS(P->Prior.UpperBound)+");\n") 181 }); 182 Real 0 183 }); 184 Real iB := iB+1 185 }); 186 0 187 }; 188 189 /////////////////////////////////////////////////////////////////////////// 190 Real Write.NoiseDistribution(NameBlock model, Real fileHandler) 191 /////////////////////////////////////////////////////////////////////////// 192 { 193 Real f = fileHandler; 194 WriteLn(_MID+"Writing noise distribution"); 195 Real FPutText(f, 196 "\n\n"+_comment+ 197 "// Defining noise distribution\n"+ 198 _comment+ 199 "\n" 200 ); 201 Real numSegment = model::Get.LinReg.Size(0); 202 Real iB = 1; 203 Real While(iB<=numSegment, Real 204 { 205 NameBlock segment = model::Get.LinReg.Segment(iB); 206 Set timeInfo = segment::Get.TimeInfo(0); 207 Text timeExpr = If(!Card(timeInfo),"", 208 { 209 " dating "+Identify(timeInfo->Dating) + 210 " from "+FormatDate(timeInfo->FirstDate,"%cy%Ym%md%dh%hi%is%s") + 211 " until "+FormatDate(timeInfo->LastDate,"%cy%Ym%md%dh%hi%is%s") 212 }); 213 FPutText(f, segment::Get.Name(0)+"::Noise" 214 "["+IntText(segment::Get.Equation.Size(0))+timeExpr+"]"+ 215 " ~ Normal(0,"<<segment::Get.Sigma2(0)); 216 Real arima.size = segment::Get.ARIMA.Size(0); 217 Real If(arima.size, 218 { 219 FPutText(f, "*ARIMA.COV([["); 220 Set For(1, arima.size, Real(Real af) 221 { 222 Set fac = segment::Get.ARIMA.Factor(af); 223 FPutText(f, If(af>1,",","")+"\n ARIMAStruct("<< 224 fac->Periodicity+","<< 225 fac->AR+","<< 226 fac->MA+","<< 227 fac->DIF+")") 228 }); 229 FPutText(f, "]])") 230 }); 231 FPutText(f, ");\n"); 232 Real iB := iB + 1 233 }); 234 0 235 }; 236 237 /////////////////////////////////////////////////////////////////////////// 238 Real Write.RegressionEquations(NameBlock model, Real fileHandler) 239 /////////////////////////////////////////////////////////////////////////// 240 { 241 Real f = fileHandler; 242 //Escribo las ecuaciones que aporta cada segmento. 243 WriteLn(_MID+"Writing regression equations"); 244 Real FPutText(f, 245 "\n\n"+_comment+ 246 "// Defining regression equations\n"+ 247 _comment+ 248 "\n" 249 ); 250 Real iB = 1; 251 Real numSegment = model::Get.LinReg.Size(0); 252 Real While(iB<=numSegment, Real 253 { 254 NameBlock segment = model::Get.LinReg.Segment(iB); 255 Text ResName = segment::Get.Name(0)+"::Noise"; 256 Real nEqu = segment::Get.Equation.Size(0); 257 WriteLn(_MID+"Escribiendo ecuaciones para el segmento "<< 258 ResName<<"["<<nEqu<<"]"); 259 Real iE = 1; 260 Real fefz = FunctionExist("Real", "segment::Get.Param.ForceZero"); 261 Real While(iE<=nEqu, Real 262 { 263 Real inpSiz = segment::Get.Equation.Input.Size(iE); 264 Text txt = "" << 265 segment::Get.Equation.Output(iE) + 266 " == " + 267 ResName+"["+IntText(iE)+"]" + 268 If(!inpSiz,"", SetSum(For(1, inpSiz, Text(Real term) 269 { 270 Anything x = segment::Get.Equation.Input.Coef(iE,term); 271 Text g = Grammar(x); 272 Real forceZero = If(!fefz,0, segment::Get.Param.ForceZero(term)); 273 Text v = If(g=="Real", If(And(!forceZero,!x), Text "", RealTextS(x)), 274 If(And(!forceZero,Or(x=="+0",x=="0",x=="-0")),"",x)); 275 Text txt = If(v=="","", v+"*"+segment::Get.Equation.Input.Param(iE,term)); 276 txt 277 })))+";\n"; 278 FPutText(f,txt); 279 Real iE := iE + 1 280 }); 281 Real iB := iB+1 282 }); 283 0 284 }; 285 286 /////////////////////////////////////////////////////////////////////////// 287 Real Write.Constraints(NameBlock segmentOrFullModel, Real fileHandler) 288 /////////////////////////////////////////////////////////////////////////// 289 { 290 Real f = fileHandler; 216 Anything x = segment::Get.Equation.Input.Coef(iE,term); 217 Text g = Grammar(x); 218 Real forceZero = If(!fefz,0, segment::Get.Param.ForceZero(term)); 219 Text v = If(g=="Real", If(And(!forceZero,!x), Text "", RealTextS(x)), 220 If(And(!forceZero,Or(x=="+0",x=="0",x=="-0")),"",x)); 221 Text txt = If(v=="","", v+"*"+segment::Get.Equation.Input.Param(iE,term)); 222 txt 223 })))+";\n"; 224 FPutText(fileHandler,txt); 225 Real iE := iE + 1 226 }); 227 0 228 }; 229 230 /////////////////////////////////////////////////////////////////////////// 231 Real Write.Data.Constraints(NameBlock segmentOrFullModel, 232 Real fileHandler) 233 /////////////////////////////////////////////////////////////////////////// 234 { 291 235 NameBlock handler = segmentOrFullModel::Get.Constraints.Handler(0); 292 236 WriteLn(_MID+"Escribiendo restricciones de orden "); … … 294 238 { 295 239 Set or = handler::Get.OrderRelation(r); 296 Real FPutText(f , "0>=+1.0*"+or->Lower+"-1.0*"+or->Upper+";\n");240 Real FPutText(fileHandler, "0>=+1.0*"+or->Lower+"-1.0*"+or->Upper+";\n"); 297 241 Real 0 298 242 }); … … 312 256 RealTextS(term->Coefficient)+"*"<<term->Parameter) 313 257 }))); 314 If(lb, FPutText(f, RealTextS(gc->LowerBound)+"<="+expr+";\n")); 315 If(ub, FPutText(f, RealTextS(gc->UpperBound)+">="+expr+";\n")); 258 If(lb, FPutText(fileHandler, 259 RealTextS(gc->LowerBound)+"<="+expr+";\n")); 260 If(ub, FPutText(fileHandler, 261 RealTextS(gc->UpperBound)+">="+expr+";\n")); 316 262 Real 0 317 263 }); … … 320 266 { 321 267 Text inequ = handler::Get.ExplicitConstraint(r); 322 FPutText(f , inequ + ";\n");268 FPutText(fileHandler, inequ + ";\n"); 323 269 Real 0 324 270 }); … … 327 273 328 274 /////////////////////////////////////////////////////////////////////////// 329 Real Write.AllConstraints(NameBlock model, Real fileHandler) 275 Real Write.Header.MainLinearBlock(NameBlock model, Real fileHandler) 276 /////////////////////////////////////////////////////////////////////////// 277 { 278 //Escribo valores iniciales de los parametros. Se asume que cada 279 //segmento es "owner" de los parametros que solo aparecen en el y que 280 //cada parametro aparece en algun segmento que lo posee. 281 WriteLn(_MID+"Writing definition of main linear block parameters"); 282 Real FPutText(fileHandler, 283 "\n\n"+_comment+ 284 "// Defining header of Regression Variables\n"+ 285 _comment+ 286 "\n"); 287 0 288 }; 289 290 /////////////////////////////////////////////////////////////////////////// 291 Real Write.Header.MissingBlock(NameBlock model, Real fileHandler) 292 /////////////////////////////////////////////////////////////////////////// 293 { 294 WriteLn(_MID+"Writing definition of missing block parameters"); 295 Real FPutText(fileHandler, 296 "\n\n"+_comment+ 297 "// Defining header of Regression Missing Values\n"+ 298 _comment+ 299 "\n"); 300 0 301 }; 302 303 /////////////////////////////////////////////////////////////////////////// 304 Real Write.Header.NoiseDistribution(NameBlock model, Real fileHandler) 305 /////////////////////////////////////////////////////////////////////////// 306 { 307 WriteLn(_MID+"Writing noise distribution"); 308 Real FPutText(fileHandler, 309 "\n\n"+_comment+ 310 "// Defining header of noise distribution\n"+ 311 _comment+ 312 "\n" 313 ); 314 0 315 }; 316 317 /////////////////////////////////////////////////////////////////////////// 318 Real Write.Header.RegressionEquations(NameBlock model, Real fileHandler) 319 /////////////////////////////////////////////////////////////////////////// 320 { 321 //Escribo las ecuaciones que aporta cada segmento. 322 WriteLn(_MID+"Writing header of regression equations"); 323 Real FPutText(fileHandler, 324 "\n\n"+_comment+ 325 "// Defining regression equations\n"+ 326 _comment+ 327 "\n" 328 ); 329 0 330 }; 331 332 /////////////////////////////////////////////////////////////////////////// 333 Real Write.Header.Constraints(NameBlock model, Real fileHandler) 330 334 /////////////////////////////////////////////////////////////////////////// 331 335 { … … 341 345 //a1*b1 + a2*b2 + ... + ak*bk <= c 342 346 343 WriteLn(_MID+"Escribiendo las restricciones de los parametros"); 344 Real FPutText(f, 345 "\n\n"+_comment+ 346 "// Defining Parameter Constraints\n"+ 347 _comment+ 348 "\n" 349 ); 350 Real iB = 1; 351 Real numSegment = model::Get.LinReg.Size(0); 352 Real While(iB<=numSegment, Real 353 { 354 NameBlock segment = model::Get.LinReg.Segment(iB); 355 WriteLn(_MID+"Escribiendo restricciones de intervalo para los parametros " 356 "del bloque "<<segment::Get.Name(0)); 357 //Uso los parametros del bloque para escribir los intervalos. 358 Set For(1,segment::Get.Param.Size(0), Real(Real k) 359 { 360 Set P = segment::Get.Param(k); 361 362 Real lb = GT(P->Prior.LowerBound,Real -1/0); 363 Real ub = LT(P->Prior.UpperBound,Real +1/0); 364 If(lb, FPutText(f, RealTextS(P->Prior.LowerBound)+"<=+"+P->Name+";\n")); 365 If(ub, FPutText(f, RealTextS(P->Prior.UpperBound)+">=+"+P->Name+";\n")); 366 Real 0 367 }); 368 Real Write.Constraints(segment, f); 369 Real iB := iB+1 370 }); 371 372 //Escribo las restricciones globales que involucran a parametros de 373 //diferentes bloques. Las restricciones pueden ser: 374 // 375 //- restricciones de orden, solo parametros del mismo bloque: b_i <= b_k 376 // 377 //- restricciones arbitrarias, solo para parametros del mismo bloque: 378 // 379 //a1*b1 + a2*b2 + ... + ak*bk <= c 380 Real Write.Constraints(model, f) 347 WriteLn(_MID+"Writing header of constrains"); 348 Real FPutText(fileHandler, 349 "\n\n"+_comment+ 350 "// Defining Parameter Constraints\n"+ 351 _comment+ 352 "\n" 353 ); 354 0 381 355 }; 382 356 … … 395 369 396 370 Text file.bsr = path+model.name+"."+session.name+".bsr"; 397 398 Real f = FOpen(file.bsr,"w"); 399 Real If(!f, Real{ 371 Real f.bsr = FOpen(file.bsr,"w"); 372 Real If(!f.bsr, Real{ 400 373 WriteLn(_MID+"Cannot open "+file.bsr+" for writing.","E"); 401 374 Real Stop 402 375 }); 403 376 WriteLn(_MID+"File "+file.bsr+" was open successfully."); 404 405 Real Write.Header(model, f); 406 Real Write.MainLinearBlock(model, f); 407 Real Write.MissingBlock(model, f); 408 Real Write.NoiseDistribution(model, f); 409 Real Write.RegressionEquations(model, f); 410 Real Write.AllConstraints(model, f); 411 412 Real FClose(f); 377 Real FClose(f.bsr); 378 Real f.head = FOpen(file.bsr+".head","w"); 379 Real f.lin = FOpen(file.bsr+".lin", "w"); 380 Real f.mis = FOpen(file.bsr+".mis", "w"); 381 Real f.dis = FOpen(file.bsr+".dis", "w"); 382 Real f.reg = FOpen(file.bsr+".reg", "w"); 383 Real f.con = FOpen(file.bsr+".con", "w"); 384 385 Real Write.Header (model, f.head); 386 Real Write.Header.MainLinearBlock (model, f.lin); 387 Real Write.Header.MissingBlock (model, f.mis); 388 Real Write.Header.NoiseDistribution (model, f.dis); 389 Real Write.Header.RegressionEquations(model, f.reg); 390 Real Write.Header.Constraints (model, f.con); 391 392 Real iB = 1; 393 Real numSegment = model::Get.LinReg.Size(0); 394 Real While(iB<=numSegment, Real 395 { 396 NameBlock segment = model::Get.LinReg.Segment(iB); 397 WriteLn(_MID+" Writing segment "+segment::Get.Name(0)); 398 Real Write.Data.MainLinearBlock (segment, f.lin); 399 Real Write.Data.MissingBlock (segment, f.mis); 400 Real Write.Data.NoiseDistribution (segment, f.dis); 401 Real Write.Data.RegressionEquations(segment, f.reg); 402 Real Write.Data.Constraints (segment, f.con); 403 Real iB := iB+1 404 }); 405 Real Write.Data.Constraints(model, f.con); 406 Real FPutText(f.con,"\n$END\n"); 407 Real FClose(f.head); 408 Real FClose(f.lin); 409 Real FClose(f.mis); 410 Real FClose(f.dis); 411 Real FClose(f.reg); 412 Real FClose(f.con); 413 Real OSFilCat([[ 414 file.bsr+".head", 415 file.bsr+".lin", 416 file.bsr+".mis", 417 file.bsr+".dis", 418 file.bsr+".reg", 419 file.bsr+".con"]], 420 file.bsr); 421 Real OSFilRemove(file.bsr+".head"); 422 Real OSFilRemove(file.bsr+".lin"); 423 Real OSFilRemove(file.bsr+".mis"); 424 Real OSFilRemove(file.bsr+".dis"); 425 Real OSFilRemove(file.bsr+".reg"); 426 Real OSFilRemove(file.bsr+".con"); 413 427 file.bsr 414 428 } … … 416 430 ]]; 417 431 418 419 420 /* * /421 422 /////////////////////////////////////////////////////////////////////////////423 // Template of BSR model definition used as argument of424 // BysMcmc::Bsr::Import425 /////////////////////////////////////////////////////////////////////////////426 NameBlock MyBsrModelDef =427 [[428 //Optional ad-hoc API.429 //Puts here all you will need use after in order to define mandatory430 //methods431 ...432 433 //Mandatory methods that will be used by BysMcmc::Bsr::Import434 //Order of methods definition is not mandatory but recommended435 436 437 ///////////////////////////////////////////////////////////////////////////438 // Documental Section439 440 //Returns model identifier to help in analysis organization441 Text Get.Doc.ModelName(Real unused) { ... };442 //e-mail or any identifier of authors separated by \n443 Text Get.Doc.Authors(Real unused) { ... };444 //Brief explanation of model445 Text Get.Doc.Description(Real unused) { ... };446 //The path where the BSR-ASCII formated file will be stored447 Text Get.Doc.Path(Real unused) { ... };448 ///////////////////////////////////////////////////////////////////////////449 450 451 ///////////////////////////////////////////////////////////////////////////452 // Linear Regression Section453 //454 // When statistical structure of noise is not homogeneous for all455 // regression equations, these must be organized in a set of segments.456 // Noise of each segment will be assumed independent of other ones.457 //458 // Nature of each segment can be also different for each one but the same459 // into each one. For example you cannot mix time series with other type460 // of data into a regression segment.461 462 //Returns the number of regressions segments that must be an integer463 //great or equal than 1464 Real Get.LinReg.Size(Real unused) { ... };465 466 //Returns the handler of each regression segment as a NameBlock467 NameBlock Get.LinReg.Segment(Real segmentNumber)468 {[[469 //Optional ad-hoc API.470 ...471 //Mandatory methods that will be used by BysMcmc::Bsr::Import472 473 //Returns the unique identifier of the regression segment474 Text Get.Name(Real unused) { ... };475 476 /////////////////////////////////////////////////////////////////////////477 // SIGMA BLOCK478 //Returns a Real fixed known sigma value as prior information or a479 //Text variable name to be simulated in the Sigma Gibbs block of BSR480 {Real|Text} Sigma(Real unused) { ... };481 /////////////////////////////////////////////////////////////////////////482 483 /////////////////////////////////////////////////////////////////////////484 // ARIMA BLOCK485 //Returns the number of ARIMA factors for a regression segment about486 //a discrete time process. If there is not a time process or is a487 //white noise process then returns 0488 Real Get.ARIMA.Size(Real unused) { ... };489 490 //Returns the f-th ARIMA factor with structure ARIMAStruct491 //In current version all AR or MA factors must have degrees 0, 1 or 2492 //In order to define higher degrees you will need to add more493 //ARIMAStruct items494 Set Get.ARIMA.Factor(Real f)495 {496 ...497 Struct ARIMAStruct498 (499 Real Periodicity,500 Polyn AR,501 Polyn MA,502 Polyn DIF503 )504 };505 /////////////////////////////////////////////////////////////////////////506 507 /////////////////////////////////////////////////////////////////////////508 // MAIN LINEAR BLOCK509 Real Get.Param.Size(Real unused) { ... };510 Set Get.Param(Real numParam)511 {512 ...513 Bsr.Param.Info(Text Name,514 Real InitialValue,515 Real LowerBound,516 Real UpperBound)517 };518 519 /////////////////////////////////////////////////////////////////////////520 // MISSING VALUES BLOCK521 Real Get.Missing.Size(Real unused) { ... };522 Set Get.Missing(Real numParam)523 {524 ...525 Bsr.Missing.Info(Text Name,526 Real Average,527 Real Sigma,528 Real LowerBound,529 Real UpperBound)530 };531 /////////////////////////////////////////////////////////////////////////532 533 Real Get.Equation.Size(Real unused) { ... };534 //Returns Real known output or Text missing name535 {Real|Text} Get.Equation.Output(Real numEqu)536 {537 ...538 };539 Real Get.Equation.Input.Size(Real numEq) { ... };540 //Returns Real known output or Text missing name of an input term541 {Real|Text} Get.Equation.Input.Coef(Real numEqu, Real term)542 {543 ...544 };545 //Returns the param name of an input term546 Text Get.Equation.Input.Param(Real numEqu, Real term)547 {548 ...549 }550 ]]};551 ///////////////////////////////////////////////////////////////////////////552 553 554 ///////////////////////////////////////////////////////////////////////////555 // Linear Constraints Section556 //557 // You can define a set of generic linear inequalities constraining558 // any subset of regression parameters with this generig shape559 //560 // lowerBound <= coef_1*param_1+...+coef_n*param_n <= upperBound561 //562 // A special type of constrain is the order relation563 //564 // lowerParam <= upperParam565 //566 // that will have an special API to define it in a easier way.567 //568 // Restrictions involving just one regression parameter should be defined569 // in the parameter definition with Bsr.Param.Info structure returned at570 //571 // Get.LinReg.Segment(s)::Get.Param572 //573 574 //Returns the total number of generic constraints upon on structure575 //Bsr.GenericConstraint.Info576 Real Get.Constraint.Size(Real unused) { ... };577 //Returns the r-th constraint as a Bsr.GenericConstraint.Info578 Set Get.Constraint(Real r) { ... };579 580 //Returns the total number of order relations upon on structure581 //Bsr.OrderRelation.Info582 Real Get.OrderRelation.Size(Real unused) { ... };583 //Returns the r-th order relation as a Bsr.OrderRelation.Info584 Set Get.OrderRelation(Real r)585 {586 ...587 Bsr.OrderRelation.Info(Text Lower, Text Upper)588 }589 ///////////////////////////////////////////////////////////////////////////590 591 ]];592 593 594 /* */
Note: See TracChangeset
for help on using the changeset viewer.
