No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
4585a84
... +0 ...
b9f7b7e
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
43  43  #' For further details on installing this package, please consult 

44  44  #' [official installation instructions for the package](https://dirkschumacher.github.io/rcbc/). 

45  45  #' 

46  +  #' @inheritSection add_gurobi_solver Start solution format 

47  +  #' 

46  48  #' @return Object (i.e. [`ConservationProblemclass`]) with the solver 

47  49  #' added to it. 

48  50  #' 
63  65  #' 

64  66  #' # create problem 

65  67  #' p < problem(sim_pu_raster, sim_features) %>% 

66    #' add_min_set_objective() %>% 

67    #' add_relative_targets(0.1) %>% 

68    #' add_binary_decisions() %>% 

69    #' add_cbc_solver(gap = 0.1, verbose = FALSE) 

68  +  #' add_min_set_objective() %>% 

69  +  #' add_relative_targets(0.1) %>% 

70  +  #' add_binary_decisions() %>% 

71  +  #' add_cbc_solver(gap = 0, verbose = FALSE) 

70  72  #' 

71  73  #' # generate solution %>% 

72  74  #' s < solve(p) 

73  75  #' 

74  76  #' # plot solution 

75  77  #' plot(s, main = "solution", axes = FALSE, box = FALSE) 

78  +  #' 

79  +  #' # create a similar problem with boundary length penalties and 

80  +  #' # specify the solution from the previous run as a starting solution 

81  +  #' p2 < problem(sim_pu_raster, sim_features) %>% 

82  +  #' add_min_set_objective() %>% 

83  +  #' add_relative_targets(0.1) %>% 

84  +  #' add_boundary_penalties(10) %>% 

85  +  #' add_binary_decisions() %>% 

86  +  #' add_cbc_solver(gap = 0, start_solution = s, verbose = FALSE) 

87  +  #' 

88  +  #' # generate solution 

89  +  #' s2 < solve(p2) 

90  +  #' 

91  +  #' # plot solution 

92  +  #' plot(s2, main = "solution with boundary penalties", axes = FALSE, 

93  +  #' box = FALSE) 

76  94  #' } 

77  95  #' @name add_cbc_solver 

78  96  NULL 
83  101  time_limit = .Machine$integer.max, 

84  102  presolve = TRUE, threads = 1, 

85  103  first_feasible = FALSE, 

104  +  start_solution = NULL, 

86  105  verbose = TRUE) { 

87    # assert that arguments are valid 

106  +  # assert that arguments are valid (except start_solution) 

88  107  assertthat::assert_that(inherits(x, "ConservationProblem"), 

89  108  isTRUE(all(is.finite(gap))), 

90  109  assertthat::is.scalar(gap), 
100  119  assertthat::noNA(first_feasible), 

101  120  assertthat::is.flag(verbose), 

102  121  requireNamespace("rcbc", quietly = TRUE)) 

122  +  # extract start solution 

123  +  if (!is.null(start_solution)) { 

124  +  # verify that version of rcbc installed supports starting solution 

125  +  assertthat::assert_that( 

126  +  any(grepl( 

127  +  "initial_solution", deparse1(args(rcbc::cbc_solve)), fixed = TRUE)), 

128  +  msg = paste( 

129  +  "please update to a newer version of the \"rcbc\" package", 

130  +  "to specify starting solutions" 

131  +  ) 

132  +  ) 

133  +  # extract data 

134  +  start_solution < planning_unit_solution_status(x, start_solution) 

135  +  } 

103  136  # add solver 

104  137  x$add_solver(pproto( 

105  138  "CbcSolver", 

106  139  Solver, 

107  140  name = "CBC", 

108    data = list(), 

141  +  data = list(start = start_solution), 

109  142  parameters = parameters( 

110  143  numeric_parameter("gap", gap, lower_limit = 0), 

111  144  integer_parameter("time_limit", time_limit, lower_limit = 1L, 
122  155  sense < x$sense() 

123  156  assertthat::assert_that( 

124  157  all(sense %in% c("=", "<=", ">=")), 

125    msg = "failed to prepare problem formulation for rcbc package") 

158  +  msg = "failed to prepare problem formulation for \"rcbc\" package") 

126  159  ## initialize CBC arguments 

127  160  row_lb < numeric(length(rhs)) 

128  161  row_ub < numeric(length(rhs)) 
148  181  col_ub = x$ub(), 

149  182  row_lb = row_lb, 

150  183  row_ub = row_ub) 

184  +  # add starting solution if specified 

185  +  start < self$get_data("start") 

186  +  if (!is.null(start) && !is.Waiver(start)) { 

187  +  n_extra < length(model$obj)  length(start) 

188  +  model$initial_solution < c(c(start), rep(NA_real_, n_extra)) 

189  +  } 

151  190  # create parameters 

152  191  p < list( 

153  192  log = as.character(as.numeric(self$parameters$get("verbose"))), 
b9f7b7e
4585a84