Changeset a4fcb39 in tol


Ignore:
Timestamp:
Feb 24, 2011, 11:34:47 AM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
aaaf752
Parents:
eb1a00c
Message:

Fixes #1110

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

Location:
tol/stdlib/math
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/R/Rapi.tol

    reb1a00c ra4fcb39  
    203203
    204204    Text R.out = Replace(_tmp.R.out, "%S", rndID);
     205    Real OSFilRemove(R.out);
    205206
    206207    Text oscmd = _R.cmd+" \""+in.R+"\" \""+R.out+"\"";
    … …  
    208209        WriteLn(_MID+"Executing :\n<"+oscmd));
    209210    Real OSCmdWait(oscmd);
    210     If (verbose,
    211         WriteLn(_MID+"R output was :\n<"+ReadFile(R.out)));
    212 
    213     // Remove remporaly results
    214    
    215     Set EvalSet(tmps.bbm, Real(Text bbm) {
    216         Real If(bbm=="", 0, OSFilRemove(bbm))
    217       });
    218 
    219     Real OSFilRemove(in.R);
    220     Real OSFilRemove(args.R);
    221     Real OSFilRemove(R.out);
    222    
    223     // Collect results
    224     Set result = EvalSet(result.names, Matrix(Text result) {
    225         Text res.bbm = Replace(result, "%S", rndID);
    226         Matrix matres = MatReadFile(res.bbm);
    227         Real OSFilRemove(res.bbm);
    228         Matrix matres
    229       })
     211    If(!OSFilExist(R.out),
     212    {
     213      WriteLn("R or a required package seems to be not instaled. Please, "
     214      "follow instructions at https://www.tol-project.org/wiki/DownloadTol","E");
     215      Real Stop;
     216      Copy(Empty)
     217    },
     218    {
     219      If (verbose,
     220          WriteLn(_MID+"R output was :\n<"+ReadFile(R.out)));
     221
     222      // Remove remporaly results
     223     
     224      Set EvalSet(tmps.bbm, Real(Text bbm) {
     225          Real If(bbm=="", 0, OSFilRemove(bbm))
     226        });
     227
     228      Real OSFilRemove(in.R);
     229      Real OSFilRemove(args.R);
     230      Real OSFilRemove(R.out);
     231     
     232      // Collect results
     233      Set result = EvalSet(result.names, Matrix(Text result) {
     234          Text res.bbm = Replace(result, "%S", rndID);
     235          Matrix matres = MatReadFile(res.bbm);
     236          Real OSFilRemove(res.bbm);
     237          Matrix matres
     238        })
     239    })
    230240  }
    231 
    232241]]
    233242
  • tol/stdlib/math/optim/LP/Rglpk.tol

    reb1a00c ra4fcb39  
    184184      "Rglpk_solve_LP.TOL('"+_om.bbm+"','"+_rhs.bbm+"','%A')";
    185185
    186     Set result = Rapi::RunRScript(script, args.bbm, argList, result.names,
    187                                   verbose);
    188     Set [[
    189           Real status     = MatDat(result[1],1,1),
    190           Real objval     = MatDat(result[1],1,2),
    191           Matrix solution = Sub(result[1],1,3,1,Columns(result[1])-2)]]
     186    Set rrs = Rapi::RunRScript(script,args.bbm,argList,result.names,verbose);
     187    If(Card(rrs),
     188    {[[
     189      Real status     = MatDat(result[1],1,1),
     190      Real objval     = MatDat(result[1],1,2),
     191      Matrix solution = Sub(result[1],1,3,1,Columns(result[1])-2)
     192    ]]},
     193    {
     194      WriteLn("[solveLP] Cannot run R script");
     195      Copy(Empty)
     196    })
    192197  };
    193198
  • tol/stdlib/math/optim/QP/Rquadprog.tol

    reb1a00c ra4fcb39  
    102102                                 _A.bbm+"','"+_b0.bbm+"','%A')";
    103103
    104     Set result = Rapi::RunRScript(script, args.bbm, argList, result.names,
     104    Set rrs = Rapi::RunRScript(script, args.bbm, argList, result.names,
    105105                                  verbose);
    106     [[
    107       Matrix solution = result[1]
    108     ]]
     106    If(Card(rrs),
     107    {[[
     108      Matrix solution = rrs[1]
     109    ]]},
     110    {
     111      WriteLn("[solveQP] Cannot run R script");
     112      Copy(Empty)
     113    })
     114
     115   
    109116  }
    110117
  • tol/stdlib/math/stat/kde/_rkde.tol

    reb1a00c ra4fcb39  
    102102      "Rkde_density.TOL('"+_sample.bbm+"','%A')";
    103103
    104     Set result = Rapi::RunRScript(script, args.bbm, argList, result.names,
     104    Set rrs = Rapi::RunRScript(script, args.bbm, argList, result.names,
    105105                                  verbose);
    106     result[1] | result[2]
     106    If(Card(rrs),
     107    {
     108      result[1] | result[2]
     109    },
     110    {
     111      WriteLn("[density] Cannot run R script");
     112      Rand(0,0,0,0)
     113    })
     114
     115   
    107116  }
    108117
  • tol/stdlib/math/stat/models/bayesian/diagnosis/_rcoda.tol

    reb1a00c ra4fcb39  
    195195      <<FormatReal(eps,"%.15lg")
    196196      <<")";
    197     Rapi::RunRScript(script, args.bbm, "",
    198                      result.names,
    199                      verbose)[1]
     197    Set rrs = Rapi::RunRScript(script, args.bbm, "",result.names,verbose);
     198    If(Card(rrs), rrs[1],
     199    {
     200      WriteLn("[raftery.diag] Cannot run R script");
     201      Rand(0,0,0,0)
     202    })
    200203  };
    201204 
    … …  
    282285      <<FormatReal(autoburnin,  "%.0lg")
    283286      <<")";
    284     Set aux = Rapi::RunRScript(script, args.bbm, "",
     287    Set rrs = Rapi::RunRScript(script, args.bbm, "",
    285288                     result.names,
    286289                     verbose);
    287     [[
    288       Matrix psrf=aux[1];
    289       Real mpsrf = MatDat(aux[2],1,1)
    290     ]]
     290    If(Card(rrs),
     291    {[[
     292      Matrix psrf=rrs[1];
     293      Real mpsrf = MatDat(rrs[2],1,1)
     294    ]]},
     295    {
     296      WriteLn("[gelman.diag] Cannot run R script");
     297      Copy(Empty)
     298    })
    291299  };
    292300   
    … …  
    354362       <<qTxt
    355363       <<")";
    356     Set Rapi::RunRScript(script, args.bbm, "", result.names, verbose)
     364    Set rrs= Rapi::RunRScript(script, args.bbm, "", result.names, verbose);
     365    If(Card(rrs),
     366    {
     367      rrs
     368    },
     369    {
     370      WriteLn("[summary] Cannot run R script");
     371      Copy(Empty)
     372    })
     373
    357374  }
    358375
Note: See TracChangeset for help on using the changeset viewer.