This function generates or appends the budget and transition cost to
a .dat file for ampl. The file
will be written to the location specified by the name
argument. If the file
already exists, it will be overwritten. The file format is plain text, with each
line terminated by a newline character.
Arguments
- budget
maximum cost for the problem
- Rastercurrentlanduse
raster object of current landuses
- landuses
character vector with all landuses
- name
The name of the output file
- verbose
Logical whether messages will be written while the function is generating calculations, defaults to FALSE
Examples
data(CurrentLanduse)
CurrentLU <- terra::unwrap(CurrentLanduse)
TroublemakeR::create_budget(budget = 2,
Rastercurrentlanduse = CurrentLU,
landuses = c("Agriculture", "Forest", "Urban"),
name = "Problem",
verbose = TRUE)
#> Landuse 1 of 3 ready 2024-04-02 12:17:30.060274
#> Landuse 2 of 3 ready 2024-04-02 12:17:30.255159
#> Landuse 3 of 3 ready 2024-04-02 12:17:30.399683
# delete the file so the test on cran can pass this
file.remove("Problem.dat")
#> [1] TRUE