Skip to content

Commit

Permalink
fix check warnings/notes
Browse files Browse the repository at this point in the history
  • Loading branch information
bart6114 committed Oct 28, 2016
1 parent 24cf3d4 commit 4644076
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 212 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RoxygenNote: 5.0.1
Imports:
simmer (>= 3.2.0),
magrittr,
dplyr
dplyr,
methods,
utils
Suggests:
knitr,
rmarkdown,
Expand Down
14 changes: 7 additions & 7 deletions R/core.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ simmer_optim <- function(model,
if (length(params) == 0)
stop("Please supply parameters to optimize over.")

control <- modifyList(optim_control(), control)
control <- utils::modifyList(optim_control(), control)

r<-method(model = model,
direction = direction,
Expand All @@ -32,7 +32,7 @@ simmer_optim <- function(model,
control = control,
...)

if(!is(r, "MethodResults"))
if(!methods::is(r, "MethodResults"))
stop("Optimization method should return a MethodResults object (created by 'method_results')")

r
Expand All @@ -55,9 +55,9 @@ run_instance <- function(model, control, params){

if(control$parallel){
envs <- parallel::mclapply(1:rep, function(i){
env <- do.call(simmer::run, c(
list(env = eval(body(model), envir = temp_env)),
run_args))
env <- do.call(simmer::run,
c(list(.env = eval(body(model), envir = temp_env)),
run_args))
simmer::wrap(env)
}, mc.set.seed = F)
} else {
Expand All @@ -78,7 +78,7 @@ run_instance <- function(model, control, params){
#'
#' @export
objective_evaluator<-function(envs, objective){
if(is(objective, "funcArgs")){
if(methods::is(objective, "funcArgs")){
do.call(objective$f, c(list(envs=envs), objective$args))
} else {
do.call(objective, list(envs=envs))
Expand All @@ -96,7 +96,7 @@ constraints_evaluator<-function(envs, constraints){
stop("Please supply a list of constraint evaluation functions")

lapply(1:length(constraints), function(i){
if(is(constraints[[i]], "funcArgs")){
if(methods::is(constraints[[i]], "funcArgs")){
do.call(constraints[[i]]$f, c(list(envs = envs), constraints[[i]]$args))
} else {
do.call(constraints[[i]], list(envs=envs))
Expand Down
2 changes: 1 addition & 1 deletion R/de_optim.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ de_optim <- function(model,
lower_bounds <- sapply(params, function(x) x[1])
upper_bounds <- sapply(params, function(x) x[length(x)])
param_types <- sapply(params, function(x){
if(is(x, "ParDiscrete")){
if(methods::is(x, "ParDiscrete")){
"ParDiscrete"
} else {
"ParContinuous"
Expand Down
4 changes: 2 additions & 2 deletions R/grid_optim.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ grid_optim <- function(model, direction = c("min", "max"), objective, constraint

if(control$verbose){
cat("Running grid optimization procedure", "\n")
pb <- txtProgressBar(style=3)
pb <- utils::txtProgressBar(style=3)
}


Expand All @@ -37,7 +37,7 @@ grid_optim <- function(model, direction = c("min", "max"), objective, constraint
index = i
)

if(control$verbose) setTxtProgressBar(pb, i/NROW(search_grid))
if(control$verbose) utils::setTxtProgressBar(pb, i/NROW(search_grid))
res
})

Expand Down
12 changes: 6 additions & 6 deletions R/measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
msr_arrivals_finished<-function(envs, agg = mean){
tmp <- simmer::get_mon_arrivals(envs) %>%
dplyr::group_by_("replication") %>%
dplyr::summarise(finished = n())
dplyr::summarise_(finished = "n()")

tmp$finished %>%
agg
Expand Down Expand Up @@ -52,11 +52,11 @@ msr_resource_utilization<-function(envs, name, agg=mean){
simmer::get_mon_resources(envs) %>%
dplyr::group_by_("resource", "replication") %>%
dplyr::arrange_("resource", "time", "replication") %>%
dplyr::mutate_("server_prev" = lag("server", default = 0),
"next_time" = dplyr::lead("time"),
"step_time" = "next_time" - "time",
"usage_time_weighted" = "step_time" * "server",
"non_usage_time_weighted" = ifelse("server" == 0, "step_time", 0)) %>%
dplyr::mutate_("server_prev" = "lag(server, default = 0)",
"next_time" = "lead(time)",
"step_time" = "next_time - time",
"usage_time_weighted" = "step_time" * "server",
"non_usage_time_weighted" = ifelse("server" == 0, "step_time", 0)) %>%
dplyr::summarise_(utilization = sum("usage_time_weighted", na.rm=T) / sum("non_usage_time_weighted", "usage_time_weighted", na.rm=T)) %>%
dplyr::group_by_("resource") %>%
dplyr::summarise_(utilization = agg("utilization")) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/sa_optim.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sa_optim <- function(model,
upper_bounds <- sapply(params, function(x) x[length(x)])

param_types <- sapply(params, function(x){
if(is(x, "ParDiscrete")){
if(methods::is(x, "ParDiscrete")){
"ParDiscrete"
} else {
"ParContinuous"
Expand Down
Loading

0 comments on commit 4644076

Please sign in to comment.