Opened 10 years ago
Last modified 9 years ago
#1812 accepted task
API de acceso nativo a R
Reported by: | Jorge | Owned by: | Jorge |
---|---|---|---|
Priority: | highest | Milestone: | TOL Packages |
Component: | R API | Version: | 3.1 |
Severity: | critical | Keywords: | |
Cc: | Pedro Gea, César Pérez Álvarez, Víctor de Buen Remiro |
Description
Crear un paquete basado en RInside para facilitar la evaluación de código R desde TOL.
Se debe facilitar el pase de parámetros de manera nativa.
Se debe facilitar la recuperación de objetos y resultados de manera nativa.
Attachments (1)
Change History (112)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
comment:5 Changed 10 years ago by
comment:6 Changed 10 years ago by
comment:7 Changed 10 years ago by
En windows los binarios de Rcpp y RInside no son compatibles con VisualStudio.
Hay que explorar si el binario de R lo es. En caso positivo el camino puede ser compilar Rcpp y RInside dentro del paquete TolR (TolRInside) de esa forma ya no habria que enlazar con binarios compilados desde C++ sino el binario R.dll compilado en C estandar.
comment:8 Changed 10 years ago by
Status: | new → accepted |
---|
comment:9 Changed 10 years ago by
En este enlace se decribe como usar R desde una aplicación compilada con VisualStudio
http://cos.name/wp-content/uploads/2009/12/Integrate-R-into-C.pdf
comment:10 Changed 10 years ago by
Con las siguientes instrucciones se puede generar el .lib de R, pexports es un ejecutable de mingw32
pexports R.dll > R.exp lib /def:R.exp /out:Rdll.lib /machine:X86
comment:12 Changed 10 years ago by
Hay que desabilitar "sugar" de Rcpp ya que usa caracteristicas avanzadas del compilador no implementadas en Visual C++ 2010
comment:13 Changed 10 years ago by
comment:14 Changed 10 years ago by
comment:15 Changed 10 years ago by
comment:16 Changed 10 years ago by
comment:17 Changed 10 years ago by
comment:18 Changed 10 years ago by
comment:19 Changed 10 years ago by
comment:20 Changed 10 years ago by
comment:22 Changed 10 years ago by
comment:23 Changed 10 years ago by
comment:24 Changed 10 years ago by
comment:27 Changed 10 years ago by
comment:28 Changed 10 years ago by
comment:29 Changed 10 years ago by
comment:30 Changed 10 years ago by
comment:31 Changed 10 years ago by
comment:32 Changed 10 years ago by
comment:33 Changed 10 years ago by
comment:34 Changed 10 years ago by
comment:35 Changed 10 years ago by
(In [6456]) refs #1812, refs #1818, compilación basada en CMake, eliminación de warnings, automatización de la regla install.
Configuración en Linux como:
cmake -DCMAKE_TOOLCHAIN_FILE=../linux-i686.toolchain.cmake -DTOL_PREFIX_PATH=/usr/local/tol32 -DCMAKE_BUILD_TYPE=Release -DTCL_LIBRARY=/usr/local/tcl8.5-i686/lib/libtcl8.5.so ..
comment:38 Changed 10 years ago by
comment:39 Changed 10 years ago by
comment:40 Changed 10 years ago by
comment:41 Changed 10 years ago by
comment:42 Changed 10 years ago by
comment:43 Changed 10 years ago by
comment:44 Changed 10 years ago by
comment:45 Changed 10 years ago by
comment:46 Changed 10 years ago by
comment:49 Changed 10 years ago by
comment:50 Changed 10 years ago by
comment:51 Changed 10 years ago by
comment:52 Changed 10 years ago by
comment:53 Changed 10 years ago by
comment:54 Changed 10 years ago by
comment:55 Changed 10 years ago by
comment:56 Changed 10 years ago by
comment:57 Changed 10 years ago by
comment:58 Changed 10 years ago by
comment:59 Changed 10 years ago by
comment:60 Changed 10 years ago by
comment:61 Changed 10 years ago by
comment:62 Changed 10 years ago by
comment:63 Changed 10 years ago by
comment:64 Changed 10 years ago by
comment:65 Changed 10 years ago by
comment:66 Changed 10 years ago by
comment:67 Changed 10 years ago by
comment:68 Changed 10 years ago by
comment:69 Changed 10 years ago by
comment:70 Changed 10 years ago by
comment:71 Changed 10 years ago by
comment:72 Changed 10 years ago by
comment:73 Changed 10 years ago by
comment:74 Changed 10 years ago by
comment:75 Changed 10 years ago by
comment:76 Changed 10 years ago by
comment:77 Changed 10 years ago by
comment:78 Changed 10 years ago by
comment:79 Changed 10 years ago by
comment:80 Changed 10 years ago by
comment:81 Changed 10 years ago by
comment:82 Changed 10 years ago by
comment:83 Changed 10 years ago by
comment:84 Changed 10 years ago by
comment:85 Changed 10 years ago by
comment:86 Changed 10 years ago by
comment:87 Changed 10 years ago by
comment:88 Changed 10 years ago by
comment:89 Changed 10 years ago by
comment:90 Changed 10 years ago by
comment:91 Changed 10 years ago by
Changed 10 years ago by
Attachment: | test_2015_05_10_15_22.zip added |
---|
Resultados de ejecutar tol_tests
comment:92 Changed 10 years ago by
comment:93 Changed 10 years ago by
comment:94 Changed 10 years ago by
comment:95 Changed 10 years ago by
comment:96 Changed 10 years ago by
comment:97 Changed 10 years ago by
(In [6744]) refs #1812, #1818, eliminamos dependencia de Rblas y Rlapack, hay que usar el nuevo contrib desde http://packages.tol-project.org/win32/development/toldevel-rtools-m32.exe
Luego hay que limpiar el cache de cmake para refrescar las nuevas libs de blas/lapack, para ello debemos ejecutar desde el directorio de compilacion la siguiente instruccion:
cmake -U BLAS -U LAPACK .
Reccompilar con:
mingw32-make
comment:98 follow-up: 99 Changed 10 years ago by
En https://www.dropbox.com/sh/gs0diwn3pthysrz/AAChNpPpZ71Z8RlC86zsQTmma?dl=0 he dejado un ejemplo de llamada a la librería de optimización NOMAD a través de R. Se trata de un ejemplo trivial de una regresión lineal que me sirve para evaluar la librería y aprender a usarla.
evaluator.tol : Evaluación de la función objetivo a minimizar optimice.R : Llama a la librería NOMAD para optimizar una función TOL run.tol : Ejecuta todo el programa desde TOL llamando a evaluator.tol y optimice.R run.R : Ejecuta todo el programa desde R llamando a evaluator.tol y optimice.R (Hay que cambiar el setwd!)
Si ejecuto desde R (run.R) funciona perfectamente pero cuando ejecuto desde TOL (run.tol) me está dando este error que soy incapaz de interpretar y que me impide seguir con la evaluación.
ERROR: [1] Exception caught: Error evaluating: assign("anything.0.1917802977841348", {library(tolLink) library(crs) numVar <- tolGet('n') x0 <- tolGet('x0') y0 = tolExecute('F::eval',x0, grammar='Real') eval.f <- function ( x ) { f = tolExecute('F::eval',matrix(x, nrow=numVar, ncol=1), grammar='Real') return ( as.double(f) ); } bbin <- rep(0,numVar) bbout <-c(0, 2, 1) lb <- rep(-2.0,numVar) ub <- rep(+2.0,numVar) opts <-list('MAX_BB_EVAL'=1000, 'MIN_MESH_SIZE'=0.00001, 'INITIAL_MESH_SIZE'=0.1, 'MIN_POLL_SIZE'=0.0001) result=snomadr(eval.f=eval.f,n=numVar, x0=x0, bbin=bbin, bbout=bbout, lb=lb, ub=ub, opts=opts) result[['solution']] }, envir=tolRI) 0 [Call stack] [2] Anything TolRInside::API::_.RGetAnything (Text expression) [1] Anything TolRInside::API::REval (Text expression)
comment:100 Changed 10 years ago by
comment:101 Changed 9 years ago by
comment:102 Changed 9 years ago by
comment:104 Changed 9 years ago by
comment:105 Changed 9 years ago by
comment:106 Changed 9 years ago by
comment:107 Changed 9 years ago by
comment:108 Changed 9 years ago by
comment:109 Changed 9 years ago by
comment:110 Changed 9 years ago by
(In [6916]) Refs #1842, #1812
tolLink:
Se incorporan llamadas especiales a TolRInside para permitir mantener los objetos compilados con tolDefine.
Se mantienen también los nameblocks obtenidos en R como referencias.
Se incorpora un nuevo método tolEval, para evaluar expresiones cualesquiera.
Se incorpora un nuevo método tolElement para acceder a elementos y miembros de conjuntos y nameblocks.
Se crea un Makevars específico para Windows.
En realidad hay que hacer dos cosas, llamar a R desde TOL y viceversa, pero gran parte del trabajo sería común, pues en ambos casos hace convertir los objetos en ambos sentidos.
En principio sólo hay que tratar con los tipos de datos comunes a ambos lenguajes