Skip to content

Commit

Permalink
More T/F-to-TRUE/FALSE replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Apr 25, 2024
1 parent 8905d8b commit 96eb2c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions R/EMJMCMC2016-method-bittodec.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ EMJMCMC2016$methods(
# print(dec)
sum.one <- sum(bit) * which.max(bit) + sum(bit[Nvars - 7:Nvars + 1]) * Nvars
jjj <- 1
while (!add.key(dec, bit, sum.one, T)) {
while (!add.key(dec, bit, sum.one, TRUE)) {
hash.level <- hash.level + 1
bit1 <- dectobit.alt(2654435761 * (dec + 97 * sum.one + hash.level * 36599) + hash.level * 59 + hash.level)
dec <- hashing(bit1) + 1
Expand All @@ -45,7 +45,7 @@ EMJMCMC2016$methods(
hash.level <- 0
dec <- hashing(bit) + 1
sum.one <- sum(bit) * which.max(bit) + sum(bit[Nvars - 7:Nvars + 1]) * Nvars
while (!add.key(dec, bit, sum.one, F)) {
while (!add.key(dec, bit, sum.one, FALSE)) {
hash.level <- hash.level + 1
bit1 <- dectobit.alt(2654435761 * (dec + 97 * sum.one + hash.level * 36599) + hash.level * 59 + hash.level)
dec <- hashing(bit1) + 1
Expand Down
2 changes: 1 addition & 1 deletion R/EMJMCMC2016-method-initialize.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ EMJMCMC2016$methods(initialize = function(estimator.function = estimate.gamma.cp
max.N.randomize <<- as.integer(1)
deep.method <<- as.integer(1)
type.randomize <<- as.integer(3)
pool.cor.prob <<- F
pool.cor.prob <<- FALSE
prand <<- 0.01
max.cpu.glob <<- as.integer(Nvars * 0.05 + 1)
max.cpu.hyper <<- as.integer(2)
Expand Down
28 changes: 14 additions & 14 deletions R/EMJMCMC2016-method-modejumping_mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ EMJMCMC2016$methods(
}


add <- T
add <- TRUE


ids.lat <- integer(0)
if (latnames[1] != "") {
ids.lat <- which(fparam %in% latnames)
if (sum(stringi::stri_count_fixed(str = proposal, pattern = latnames)) > 0) {
add <- F
add <- FALSE
}
}
if (length(ids.lat) == 0) {
Expand All @@ -574,7 +574,7 @@ EMJMCMC2016$methods(
# print(proposal)
if (proposal %in% latnames) {
if ((proposal %in% fparam[ids.lat])) {
add <- F
add <- FALSE
}
} else {
if (add) {
Expand All @@ -583,13 +583,13 @@ EMJMCMC2016$methods(
bet.act <- do.call(.self$estimator, c(estimator.args, stats::as.formula(stri_paste(fobserved, "~ 1 +", paste0(c(fparam[-ids.lat], proposal), collapse = "+")))))$summary.fixed$mean

if (is.na(bet.act[length(fparam[-ids.lat]) + 2]) && (action.type != 4 && gen.prob[2] == 0 || gen.prob[2] != 0)) {
add <- F
add <- FALSE
} else {
idel <- idel + 1
}
},
error = function(err) {
add <- F
add <- FALSE
},
finally = {}
)))
Expand Down Expand Up @@ -659,12 +659,12 @@ EMJMCMC2016$methods(
acc_moves <- 1
j.a <- 1
} else if (allow_offsprings == 4 && j %% mutation_rate == 0 && (j <= last.mutation || Nvars != Nvars.max)) {
add.buf <- F
add.buf <- FALSE

# perform preliminary filtration here
if (Nvars > Nvars.max || j == mutation_rate) {
on.suggested <- 1
preaccepted <- F
preaccepted <- FALSE
# do the stuff here
if (j == mutation_rate) {
fparam.pool <<- unique(c(fparam.pool, filtered))
Expand Down Expand Up @@ -711,7 +711,7 @@ EMJMCMC2016$methods(
p2 <- array(1, dim = (Nvars))
acc_moves <- 1
j.a <- 1
super.backward <- F
super.backward <- FALSE
}
} else {
if (Nvars >= Nvars.max) {
Expand Down Expand Up @@ -753,7 +753,7 @@ EMJMCMC2016$methods(
mlikcur <- mlikcur.buf
varcurb <- varcurb.buf
}
preaccepted <- F
preaccepted <- FALSE
}

tmp.buf <- fparam[which(varcurb == 1)]
Expand Down Expand Up @@ -808,11 +808,11 @@ EMJMCMC2016$methods(
p.add <<- p.add.buf.1
mlikcur <- mlikcur.buf
varcurb <- varcurb.buf
preaccepted <- F
preaccepted <- FALSE
# on.suggested<-on.suggested+1
} else {
if (printable.opt) print("mutation is preaccepted")
preaccepted <- T
preaccepted <- TRUE
}
}
on.suggested <- on.suggested + 1
Expand Down Expand Up @@ -1017,20 +1017,20 @@ EMJMCMC2016$methods(
proposal <- fparam.pool[sample(x = length(fparam.pool), size = 1)]
}

add <- T
add <- TRUE

tryCatch(utils::capture.output(
{
bet.act <- do.call(.self$estimator, c(estimator.args, stats::as.formula(stri_paste(fobserved, "~ 1 +", paste0(c(fparam, proposal), collapse = "+")))))$summary.fixed$mean

if (is.na(bet.act[length(fparam) + 2])) {
add <- F
add <- FALSE
} else {
idel <- idel + 1
}
},
error = function(err) {
add <- F
add <- FALSE
}
))

Expand Down

0 comments on commit 96eb2c8

Please sign in to comment.