This is a constructor for a single Coupled Partition MCMC step. The function constructs an environment with the proposal, inverse temperature, and verbose flag. It then returns a function that takes the current_state and a scorer object. This only allows the scores to be raised to a constant temperature for every step.
Usage
CoupledPartitionMCMC(
proposal = DefaultProposal(),
temperature = c(1, 10, 100, 1000),
verbose = TRUE
)
Examples
scorer <- CreateScorer(
scorer = BNLearnScorer,
data = bnlearn::learning.test
)
nodes <- names(bnlearn::learning.test)
n_coupled_chains <- 8
coupled_state <- InitCoupledPartition(nodes, scorer,
n_parallel_chains = 1,
n_coupled_chains = n_coupled_chains)
coupled_transition <- CoupledPartitionMCMC(
proposal = DefaultProposal(p = c(0.0, 1.0, 0.0, 0.0, 0.0)),
temperature = 2^(0:(n_coupled_chains - 1))
)
coupled_transition(coupled_state, scorer)
#> $state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 D
#> 4 3 F
#> 5 4 B
#> 6 5 E
#>
#> $log_score
#> [1] -24035.47
#>
#> $proposal_info
#> NULL
#>
#> $mcmc_info
#> $mcmc_info[[1]]
#> $mcmc_info[[1]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 D
#> 4 3 F
#> 5 4 B
#> 6 5 E
#>
#> $mcmc_info[[1]]$log_score
#> [1] -24035.47
#>
#> $mcmc_info[[1]]$proposal_info
#> $mcmc_info[[1]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[1]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[1]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[1]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[1]]$jac
#> [1] -0.2231436
#>
#> $mcmc_info[[1]]$mhr
#> [1] 136.9095
#>
#>
#> $mcmc_info[[2]]
#> $mcmc_info[[2]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 F
#> 4 3 B
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[2]]$log_score
#> [1] -24172.38
#>
#> $mcmc_info[[2]]$proposal_info
#> $mcmc_info[[2]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[2]]$accept
#> [1] FALSE
#>
#> $mcmc_info[[2]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[2]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[2]]$jac
#> [1] -0.2231436
#>
#> $mcmc_info[[2]]$mhr
#> [1] -45.86196
#>
#>
#> $mcmc_info[[3]]
#> $mcmc_info[[3]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 F
#> 4 3 B
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[3]]$log_score
#> [1] -24172.38
#>
#> $mcmc_info[[3]]$proposal_info
#> $mcmc_info[[3]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[3]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[3]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[3]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[3]]$jac
#> [1] 0
#>
#> $mcmc_info[[3]]$mhr
#> [1] 0.8544307
#>
#>
#> $mcmc_info[[4]]
#> $mcmc_info[[4]]$state
#> partition node
#> 1 1 C
#> 2 2 A
#> 3 2 F
#> 4 3 B
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[4]]$log_score
#> [1] -24168.96
#>
#> $mcmc_info[[4]]$proposal_info
#> $mcmc_info[[4]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[4]]$accept
#> [1] FALSE
#>
#> $mcmc_info[[4]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[4]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[4]]$jac
#> [1] 0
#>
#> $mcmc_info[[4]]$mhr
#> [1] -2.157323
#>
#>
#> $mcmc_info[[5]]
#> $mcmc_info[[5]]$state
#> partition node
#> 1 1 C
#> 2 2 F
#> 3 3 A
#> 4 4 B
#> 5 5 D
#> 6 5 E
#>
#> $mcmc_info[[5]]$log_score
#> [1] -24160.45
#>
#> $mcmc_info[[5]]$proposal_info
#> $mcmc_info[[5]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[5]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[5]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[5]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[5]]$jac
#> [1] -0.2231436
#>
#> $mcmc_info[[5]]$mhr
#> [1] 0.7456743
#>
#>
#> $mcmc_info[[6]]
#> $mcmc_info[[6]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 F
#> 4 3 B
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[6]]$log_score
#> [1] -24172.38
#>
#> $mcmc_info[[6]]$proposal_info
#> $mcmc_info[[6]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[6]]$accept
#> [1] FALSE
#>
#> $mcmc_info[[6]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[6]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[6]]$jac
#> [1] -0.2231436
#>
#> $mcmc_info[[6]]$mhr
#> [1] -1.029263
#>
#>
#> $mcmc_info[[7]]
#> $mcmc_info[[7]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 B
#> 4 3 F
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[7]]$log_score
#> [1] -24083.05
#>
#> $mcmc_info[[7]]$proposal_info
#> $mcmc_info[[7]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[7]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[7]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[7]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[7]]$jac
#> [1] 0
#>
#> $mcmc_info[[7]]$mhr
#> [1] 1.395832
#>
#>
#> $mcmc_info[[8]]
#> $mcmc_info[[8]]$state
#> partition node
#> 1 1 A
#> 2 1 C
#> 3 2 F
#> 4 3 B
#> 5 4 D
#> 6 4 E
#>
#> $mcmc_info[[8]]$log_score
#> [1] -24172.38
#>
#> $mcmc_info[[8]]$proposal_info
#> $mcmc_info[[8]]$proposal_info$proposal_used
#> [1] "node_move"
#>
#>
#> $mcmc_info[[8]]$accept
#> [1] FALSE
#>
#> $mcmc_info[[8]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[8]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[8]]$jac
#> [1] 0
#>
#> $mcmc_info[[8]]$mhr
#> [1] -3.82123
#>
#>
#> $mcmc_info$mcmc_swap_info
#> $mcmc_info$mcmc_swap_info$accept
#> [1] TRUE
#>
#> $mcmc_info$mcmc_swap_info$state_1
#> [1] 4
#>
#> $mcmc_info$mcmc_swap_info$state_2
#> [1] 3
#>
#>
#>