Skip to content

Commit

Permalink
Prepare v0.2.0 release. (#38)
Browse files Browse the repository at this point in the history
* Use native pipe and wallis prefix.

* Remove comments from _targets.R.

* Add a Makefile.

* Add instructions to the README.

* Add a NEWS.md file.
  • Loading branch information
MHenderson authored Jul 21, 2024
1 parent 7a6e392 commit 30c2557
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 53 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
Rscript -e "targets::tar_make()"
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# maximal-room-squares (development version)

# maximal-room-squares (v0.2.0)

* greedy1 and greedy2 implementations from Meszka and Rosa (2021)
* Based on wallis (v0.0.0.9006)
* renv for dependency installation (renv::restore())
* targets pipeline to generate all plots (targets::tar_make())
* Tested on Ubuntu 20.04.6 LTS (Focal Fossa) with R4.4.0, renv 1.0.7 and wallis 0.0.0.9006
6 changes: 3 additions & 3 deletions R/greedy1.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
greedy1 <- function(n) {

R <- empty_room(n) |>
R <- wallis::empty_room(n) |>
dplyr::mutate(avail = list(0:(n - 1))) |>
dplyr::mutate(visit = as.numeric(NA))

# pairs to be used in order
P <- unused_pairs(R)
P <- wallis::unused_pairs(R)
# empty cells to be visited in order
E <- empty_cells(R)
E <- wallis::empty_cells(R)

t <- 1

Expand Down
10 changes: 5 additions & 5 deletions R/greedy2.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
greedy2 <- function(n) {

R <- empty_room(n) %>%
dplyr::mutate(avail = list(0:(n - 1))) %>%
R <- wallis::empty_room(n) |>
dplyr::mutate(avail = list(0:(n - 1))) |>
dplyr::mutate(visit = as.numeric(NA))

# pairs to be used in order
P <- unused_pairs(R)
P <- wallis::unused_pairs(R)
# empty cells to be visited in order
E <- empty_cells(R)
E <- wallis::empty_cells(R)

t <- 1

Expand Down Expand Up @@ -52,5 +52,5 @@ greedy2 <- function(n) {
}

}
return(R %>% select(-avail))
return(R |> select(-avail))
}
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

# Generating Maximal Partial Room Squares in R

Two different greedy procedures for building maximal partial Room squares in R inspired by Meszka and Rosa (2021).
Two different greedy procedures for building maximal partial Room squares in R inspired by Meszka and Rosa (2021) using functions from the [wallis](https://mhenderson.r-universe.dev/wallis) R package.

Tested on R4.4.0 with renv 1.0.7, targets 1.7.1 and wallis 0.0.0.9006.

To create the plots below, first install `renv` and install package dependencies:
```
install.packages("renv")
renv::restore()
```

Now run the `targets` pipeline:
```
targets::tar_make()
```

## greedy1

Expand Down
45 changes: 1 addition & 44 deletions _targets.R
Original file line number Diff line number Diff line change
@@ -1,54 +1,11 @@
# Created by use_targets().
# Follow the comments below to fill in this target script.
# Then follow the manual to check and run the pipeline:
# https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline

# Load packages required to define the pipeline:
library(targets)
# library(tarchetypes) # Load other packages as needed.

# Set target options:
tar_option_set(
packages = c("dplyr", "ggplot2", "glue", "here", "patchwork", "tibble", "wallis") # Packages that your targets need for their tasks.
# format = "qs", # Optionally set the default storage format. qs is fast.
#
# Pipelines that take a long time to run may benefit from
# optional distributed computing. To use this capability
# in tar_make(), supply a {crew} controller
# as discussed at https://books.ropensci.org/targets/crew.html.
# Choose a controller that suits your needs. For example, the following
# sets a controller that scales up to a maximum of two workers
# which run as local R processes. Each worker launches when there is work
# to do and exits if 60 seconds pass with no tasks to run.
#
# controller = crew::crew_controller_local(workers = 2, seconds_idle = 60)
#
# Alternatively, if you want workers to run on a high-performance computing
# cluster, select a controller from the {crew.cluster} package.
# For the cloud, see plugin packages like {crew.aws.batch}.
# The following example is a controller for Sun Grid Engine (SGE).
#
# controller = crew.cluster::crew_controller_sge(
# # Number of workers that the pipeline can scale up to:
# workers = 10,
# # It is recommended to set an idle time so workers can shut themselves
# # down if they are not running tasks.
# seconds_idle = 120,
# # Many clusters install R as an environment module, and you can load it
# # with the script_lines argument. To select a specific verison of R,
# # you may need to include a version string, e.g. "module load R/4.3.2".
# # Check with your system administrator if you are unsure.
# script_lines = "module load R"
# )
#
# Set other options as needed.
packages = c("dplyr", "ggplot2", "glue", "here", "patchwork", "tibble", "wallis")
)

# Run the R scripts in the R/ folder with your custom functions:
tar_source()
# tar_source("other_functions.R") # Source other scripts as needed.

# Replace the target list below with your own:
list(
tar_target(
name = R6_g1,
Expand Down
2 changes: 2 additions & 0 deletions maximal-room-squares.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Makefile

0 comments on commit 30c2557

Please sign in to comment.