Skip to content

Commit

Permalink
set the seed value consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxo-m committed Nov 5, 2024
1 parent 03b7e3e commit 1377f7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion data-raw/generate_allocation_rule_files_for_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ models <- DoseFinding::Mods(

allocation_rule <- learn_allocation_rule(
models, N_total = 150, N_ini = rep(10, 5), N_block = 10, Delta = 1.3,
outcome_type = "continuous", sd_normal = sqrt(4.5), seed = 314,
outcome_type = "continuous", sd_normal = sqrt(4.5),
seed = 123,
rl_config = rl_config_set(iter = 1, model = rl_dnn_config(fcnet_hiddens = c(1, 1))),
output_dir = "allocation_rule_for_test", output_base_dir = "inst/extdata",
alpha = 0.025
Expand Down
Binary file modified inst/extdata/allocation_rule_for_test/policy_state.pkl
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/testthat/test-allocation_rule.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test_that("opt_allocation_probs", {
doses <- c( 0, 0, 0, 0, 2, 2, 4, 4, 4, 6, 6, 8, 8, 8)
resps <- c(.2, .1, .0, .3, .2, .4, .1, .6, .8, .5, .8, 1.1, .9, 1.6)

expected <- c(`0` = 0.2036620, `2` = 0.1981888, `4` = 0.1986541,
`6` = 0.1962135, `8` = 0.2032815)
expected <- c(`0` = 0.2139878, `2` = 0.1945756, `4` = 0.1992008,
`6` = 0.1905261, `8` = 0.2017096)
act <- obj$opt_allocation_probs(doses, resps)

expect_equal(expected, act, tolerance = 1e-6)
Expand Down

0 comments on commit 1377f7b

Please sign in to comment.