File: DefaultComputePlanTest.R

package info (click to toggle)
r-cran-openmx 2.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,908 kB
  • sloc: cpp: 35,071; ansic: 13,690; fortran: 2,001; sh: 1,362; python: 350; perl: 21; makefile: 5
file content (41 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require(OpenMx)
library(testthat)

plan <- omxDefaultComputePlan()
omxCheckEquals(names(plan$steps),c("GD","ND","SE","HQ","RD","RE"))

plan <- omxDefaultComputePlan(useOptimizer=FALSE)
omxCheckEquals(names(plan$steps),c("CO","RE"))

plan <- omxDefaultComputePlan(intervals=TRUE)
omxCheckEquals(names(plan$steps),c("GD","CI","ND","SE","HQ","RD","RE"))

plan <- omxDefaultComputePlan(modelName="foo",intervals=TRUE)
omxCheckEquals(plan$steps$GD$fitfunction,"foo.fitfunction")
expect_equivalent(
  ifelse(test=mxOption(NULL,"Default optimizer")=="SLSQP",
         yes=plan$steps$CI$plan$plan$fitfunction,
         no=plan$steps$CI$plan$fitfunction),
	"foo.fitfunction")
omxCheckEquals(plan$steps$ND$fitfunction,"foo.fitfunction")

ol <- options()$mxOption
ol$"Gradient algorithm" <- "forward"
ol$"Gradient iterations" <- 2L
ol$"Gradient step size" <- 1e-3
ol$"Calculate Hessian" <- "No"
ol$"Standard Errors" <- "No"
plan <- omxDefaultComputePlan(intervals=TRUE,optionList=ol)
omxCheckEquals(names(plan$steps),c("GD","CI","RD","RE"))
omxCheckEquals(plan$steps$GD$gradientAlgo,"forward")
omxCheckEquals(plan$steps$GD$gradientIterations,2L)
omxCheckEquals(plan$steps$GD$gradientStepSize,0.001)
if(mxOption(NULL,"Default optimizer")=="SLSQP"){
	omxCheckEquals(plan$steps$CI$plan$plan$gradientAlgo,"forward")
	omxCheckEquals(plan$steps$CI$plan$plan$gradientIterations,2L)
	omxCheckEquals(plan$steps$CI$plan$plan$gradientStepSize,0.001)
} else{
	omxCheckEquals(plan$steps$CI$plan$gradientAlgo,"forward")
	omxCheckEquals(plan$steps$CI$plan$gradientIterations,2L)
	omxCheckEquals(plan$steps$CI$plan$gradientStepSize,0.001)
}