This function takes a list of pyDarwin options and writes them to a JSON file in the specified format. The options can be generated using the create_pyDarwinOptions function or customized manually. The resulting JSON file can be used as input for a pyDarwin model search.

write_pyDarwinOptions(
  pyDarwinOptions = create_pyDarwinOptions(),
  file = file.path(getwd(), "options.json"),
  pretty = TRUE,
  digits = NA,
  auto_unbox = TRUE
)

Arguments

pyDarwinOptions

A list containing the pyDarwin options to be written to the JSON file. Default is the result of calling create_pyDarwinOptions() with default arguments.

file

Character: The path to the JSON file where the options will be written. Default is a file named "options.json" in the current working directory.

pretty

adds indentation whitespace to JSON output. Can be TRUE/FALSE or a number specifying the number of spaces to indent. See prettify()

digits

max number of decimal digits to print for numeric values. Use I() to specify significant digits. Use NA for max precision.

auto_unbox

automatically unbox() all atomic vectors of length 1. It is usually safer to avoid this and instead use the unbox() function to unbox individual elements. An exception is that objects of class AsIs (i.e. wrapped in I()) are not automatically unboxed. This is a way to mark single values as length-1 arrays.

Value

None (invisible NULL).

Examples

# Write pyDarwin options to a JSON file
Options <-
  create_pyDarwinOptions(author = "John Doe",
                         algorithm = "GA",
                         population_size = 10)
write_pyDarwinOptions(Options,
                      file = file.path(tempdir(), "options.json"))