Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/nimble/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Collate:
filtering_liuwest.R
filtering_enkf.R
filtering_bootstrap.R
optimTools.R
NF_utils.R
miscFunctions.R
makevars.R
Expand Down
13 changes: 0 additions & 13 deletions packages/nimble/R/cppDefs_nimbleFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,6 @@ cppNimbleClassClass <- setRefClass('cppNimbleClassClass',
}
next
}
if(inherits(neededType, 'symbolOptimReadyFunction')){
typeName <- neededType$genName
thisCppDef <- nimbleProject$getNimbleFunctionCppDef(generatorName = typeName)
if(is.null(thisCppDef)){
thisCppDef <- cppOptimObject(name = typeName, nfSym = neededType)
neededTypeDefs[[ typeName ]] <<- thisCppDef
} else {
Hincludes <<- c(Hincludes, thisCppDef)
CPPincludes <<- c(CPPincludes, thisCppDef)
}

}

if(inherits(neededType, 'symbolNimbleFunctionList')) {

baseClassName <- environment(neededType$baseClass)$name
Expand Down
1 change: 0 additions & 1 deletion packages/nimble/R/cppInterfaces_nimbleFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ makeNFBindingFields <- function(symTab, cppNames) {
ptrName = paste0(".", vn, "_Ptr")
fieldList[[ptrName]] <- "ANY" ## "ANY"
## Model variables:
if(inherits(thisSymbol, 'symbolOptimReadyFunction')) next
if(inherits(thisSymbol,'symbolNimArrDoublePtr')) { ## copy type 'modelVar'
fieldList[[vn]] <- eval(substitute(
function(x) {
Expand Down
14 changes: 0 additions & 14 deletions packages/nimble/R/nimbleFunction_compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,20 +436,6 @@ nfProcessing$methods(makeTypeObject = function(name, instances, firstOnly = FALS
}
return(newSym)
}
if(inherits(instances[[1]][[name]], 'OptimReadyFunction')){

thisObj <- instances[[1]][[name]]
nfName <- thisObj$getOriginalName()
funList <- lapply(instances, `[[`, nfName)
nfp <- nimbleProject$compileNimbleFunction(funList, initialTypeInferenceOnly = TRUE) ## will return existing nfProc if it exists
newSym <- symbolOptimReadyFunction(name = name, type = 'OptimReadyFunction', nfName = nfName, nfProc = nfp, genName = thisObj$getGeneratorName())

baseClassName <- class(nf_getRefClassObject(funList[[1]]))
optReadyClassName <- paste0('OPTIMREADY_', baseClassName)

if(!(optReadyClassName %in% names(neededTypes))) neededTypes[[optReadyClassName]] <<- newSym
return(NULL)
}
if(is.nf(instances[[1]][[name]])) { ## nimbleFunction
funList <- lapply(instances, `[[`, name)
nfp <- nimbleProject$compileNimbleFunction(funList, initialTypeInferenceOnly = TRUE) ## will return existing nfProc if it exists
Expand Down
66 changes: 0 additions & 66 deletions packages/nimble/R/nimbleFunction_keywordProcessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ setupCodeTemplateClass <- setRefClass('setupCodeTemplateClass',
# rgamma_keywordInfo
# d_dist_keywordInfo
# qp_dist_keywordInfo
# nimOptim_keywordInfo
# values_keywordInfo
# calculate_keywordInfo
# simulate_keywordInfo
Expand Down Expand Up @@ -161,57 +160,6 @@ nimbleListReturningFunction_keywordInfo <- keywordInfoClass(
}
)

nimOptim_keywordInfo <- keywordInfoClass(
keyword = 'nimOptim',
processor = function(code, nfProc){


rawFunName <- as.character(code$optFun) #grabs the run code name of the function to be optimized
optimFunSym <- nfProc$setupSymTab$symbols[[rawFunName]] #gets the symbol associated with this function

optimFunName <- funName2OptimFunName(optimFunSym$nfProc$name) #makes the name of the C++ function
argInfo <- getArgInfoFromNFSym(optimFunSym) #extracts the information about the function to be optimized from it's symbol

voidPointerNFName <- makeVoidPointerName_fromObjName(rawFunName) #Makes the name for the void* that will ultimately be passed to nimble_optim
voidPointerForNFLine <- paste0(voidPointerNFName, ' <- voidPtr(', rawFunName, ', nimbleFunction)') #line of run code for making the void pointer

argPointInfo <- makeDSLCallforVoidPtr_fromArgInfAndCall(code, argInfo) #Makes the lines of code that create the void*'s for the arguments to be passed to optimized function
argPointerRunCode <- argPointInfo$newRunCode #run code for void pointers to arguments
argVPtrNames <- as.character(argPointInfo$pointerNames) #names of pointers

allNewBuildCode <- c(voidPointerForNFLine, argPointerRunCode) #combining all the code for wrapping the void pointers
code$optFun <- parse(text = optimFunName)[[1]] #replacing the optFun argument with the name of the new wrapper


cNimCall_to_use <- parse(text = 'bareBonesOptim')[[1]] #As we update the flexbility of optim, we are going to be
#changing the cNimCall_to_use
#this is currently in place to bypass issues such as
#getting the optimAns and optimControl into the DSL

#When we get those working, the C++ function we will use (i.e. no longer bareBonesOptim)
#will need different arguments, and so the next few lines of code will probably need expanding

code[[1]] <-cNimCall_to_use
code[[4]] <- parse(text = voidPointerNFName)[[1]]
names(code)[4] <- 'voidNimFunPtr'
code[[5]] <- parse(text = length(argPointInfo$pointerNames))[[1]]
names(code)[5] <- 'numAdditionalArgs'

for(argName in names(argPointInfo$pointerNames) )
code[[argName]] <- parse(text = argPointInfo$pointerNames[[argName]])[[1]]

newRunCode <- quote({})
for(i in seq_along(allNewBuildCode))
newRunCode[[i+1]] <- parse(text = allNewBuildCode[[i]])[[1]]
newRunCode[[length(newRunCode) + 1]] <- code


setupArgList <- list(name = optimFunName, nimbleFunctionName = rawFunName)
addNecessarySetupCode(optimFunName, setupArgList, optimReadyFun_setupCodeTemplate, nfProc)
return(newRunCode)
}
)

nimSeq_keywordInfo <- keywordInfoClass(
keyword = 'nimSeq',
processor = function(code, nfProc) {
Expand Down Expand Up @@ -848,7 +796,6 @@ keywordList[['$']] <- dollarSign_keywordInfo
keywordList[['[']] <- singleBracket_keywordInfo
keywordList[['nimEigen']] <- nimbleListReturningFunction_keywordInfo
keywordList[['nimSvd']] <- nimbleListReturningFunction_keywordInfo
keywordList[['nimOptim']] <- nimOptim_keywordInfo
keywordList[['dgamma']] <- d_gamma_keywordInfo
keywordList[['pgamma']] <- pq_gamma_keywordInfo
keywordList[['qgamma']] <- pq_gamma_keywordInfo
Expand Down Expand Up @@ -916,7 +863,6 @@ matchFunctions[['getLogProb']] <- getLogProb #function(model, nodes, nodeFunctio
matchFunctions[['nimCopy']] <- function(from, to, nodes, nodesTo, row, rowTo, logProb = FALSE){}
matchFunctions[['double']] <- function(nDim, dim, default, ...){}
matchFunctions[['int']] <- function(nDim, dim, default, ...){}
matchFunctions[['nimOptim']] <- function(initPar, optFun, ...){}
matchFunctions[['nimEigen']] <- function(squareMat, only.values = FALSE){}
matchFunctions[['nimSvd']] <- function(mat, vectors = 'full'){}
matchFunctions[['dgamma']] <- function(x, shape, rate = 1, scale, log = FALSE){}
Expand Down Expand Up @@ -1085,7 +1031,6 @@ processKeywords_recurse <- function(code, nfProc = NULL) {
##### SETUPCODE TEMPLATES

# Current Available Templates:
# optimReadyFun_setupCodeTemplate
# modelVariableAccessorVector_setupCodeTemplate
# modelValuesAccessorVector_setupCodeTemplate
# accessorVectorLength_setupCodeTemplate
Expand All @@ -1106,17 +1051,6 @@ length_char_SetupTemplate <- setupCodeTemplateClass(
CODE = argList$code)
})

optimReadyFun_setupCodeTemplate <- setupCodeTemplateClass(
makeName = function(argList){Rname2CppName(deparse(argList$name))},
codeTemplate = quote(OPTIM_FUN <- OptimReadyFunction(name = OPTIM_FUN_INQUOTES, nimbleFunction = NFNAME, localNimbleFunctionName = LOCALORGNAME)),
makeCodeSubList = function(resultName, argList){
list(OPTIM_FUN = as.name(argList$name),
OPTIM_FUN_INQUOTES = argList$name,
NFNAME = as.name(argList$nimbleFunctionName),
LOCALORGNAME = argList$nimbleFunctionName)
})


modelVariableAccessorVector_setupCodeTemplate <- setupCodeTemplateClass(
#Note to programmer: required fields of argList are model, nodes and logProb
makeName = function(argList) {Rname2CppName(paste(deparse(argList$model), deparse(argList$nodes), 'access_logProb', deparse(argList$logProb), sep = '_'))},
Expand Down
209 changes: 0 additions & 209 deletions packages/nimble/R/optimTools.R

This file was deleted.

14 changes: 0 additions & 14 deletions packages/nimble/R/types_symbolTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,6 @@ symbolNimbleFunction <-
}
))

symbolOptimReadyFunction <-
setRefClass(Class = 'symbolOptimReadyFunction',
contains = 'symbolBase',
fields = list(nfName = 'ANY', nfProc = 'ANY', genName = 'ANY'),
methods = list(
initialize = function(...){callSuper(...)},
show = function() writeLines(paste('symbolOptimObject', name)),
genCppVar = function(...){
cat('note: in genCppVar for symbolOptimReadyFunction, need to figure out how to get unique names\n')
return(cppVarFull(name = name, baseType = genName, ptr = 0))
}
)
)


symbolVoidPtr <- setRefClass(Class = 'symbolVoidPtr',
contains = 'symbolBase',
Expand Down
Loading