Recent Releases of prioritizr
prioritizr - prioritizr 8.0.4
Notice
- New default portfolio method for
problem()objects. This new default portfolio -- which can be manually specified usingadd_default_portfolio()-- involves simply generating a single solution. The reason why this new default portfolio method was chosen was because planning problems that contain insufficient data (e.g., feature and cost data) to identify meaningful priorities can sometimes result in solutions containing strange spatial artifacts (e.g., lines or bands of selected planning units, see #205 and #268). Since the presence of these spatial artifacts can indicate an under-specified problem and shuffling optimization problems can suppress them, we have decided to update the default portfolio so that it does not shuffle problems. If users wish to prevent spatial artifacts from appearing in solutions, then spatial penalties (e.g.,add_boundary_penalties()), spatial constraints (e.g.,add_neighbor_constraints()), or shuffle portfolios (e.g.,add_shuffle_portfolio(number_solutions = 1)) can be used.
Minor improvements and bug fixes
- New
add_default_portfolio()function for specifying the default behavior for generating a solution (see Notice above for further details). - Update
solve()so that it provides information on the optimality of solutions (#323). For example, you might specify a 10% optimality gap for the optimization process (e.g., usingadd_highs_solver(gap = 0.1)), and this might produce a solution that is at least 7% from optimality. The resulting output fromsolve()will now provide this information about the solution (i.e., the 7% from optimality), and can be accessed using thegapattribute (e.g.,attr(x, "gap"), wherexis the output fromsolve()). Note that this information is currently only available when using the Gurobi or HiGHS solvers. - Fix bug in
add_linear_constraints()andadd_linear_penalties()that resulted in an incorrect error message being shown (#324). - Fix bug in
add_shuffle_portfolio()that prevented solvers from using a pre-specified starting solution (per thestartparameter) correctly. Please note that this bug did not result in incorrect solutions, it only meant that any pre-specified starting solutions were not used properly. - Fix bug in
add_cplex_solver()that caused solutions to not provide runtime information for the optimization process. - Fix bug in
add_shuffle_portfolio()so that optimization problems are randomly shuffled when a single solution is requested. This update should help prevent "strange" solutions that contain long horizontal lines/bands of planning units (#205, #268). - Update
add_contiguity_constraints()andadd_feature_contiguity_constraints()to be compatible with updates to the igraph package. - Update
write_problem()so that it can use the gurobi package to write problems (if desired). This substantially reduces run time, because writing problems using the Rsymphony packages also requires solving them. - Update
presolve_check()to throw warning if a problem has a single feature (#309). Thanks to Sandra Neubert (\@sandra-neubert) for code contribution. - Update
print()andsummary()forproblem()objects so that all text is printed at once (rather than sequentially). - Fix
write_problem()so that it works as expected (#312). - Update
problem(),add_linear_constraints(),add_linear_penalties(),add_locked_in_constraints(),add_locked_out_constraints(),adjacency_matrix(),binary_stack(),category_layer(),connectivity_matrix(),fast_extract(),intersecting_units(),proximity_matrix(),rij_matrix(),simulate_data(),simulate_species(),simulate_cost(), andzones()and other functions so that they will throw an error if a categoricalterra::rast()object is provided as an argument (#313). This is because categorical rasters are not supported. Thanks to Martin Jung (\@Martin-Jung) for bug report. - Fix NAMESPACE issues related to registration of internal S3 methods.
- Fix bug with
problem()not throwing multiple warnings with unusual data (e.g., given cost and feature data with negative values, previously only a single warning about negative costs would be thrown). Thanks to Sandra Neubert (\@sandra-neubert) for bug report. - Update
problem()to be more memory efficient when using a sparse matrix (dgCMatrix) argument for therij_matrixparameter. - Update error messages for checking that objects have the same coordinate reference system and overlapping spatial extents to format argument names correctly.
- Update error messages for nested expressions to refer to expressions using
Caused by errorinstead ofCaused by NULL. - Fix
add_locked_in_constraints()andadd_locked_in_constraints()error messages when supplyinglocked_inandlocked_outobjects that do not spatially intersect with the planning units. - Update error message for checking if objects spatially overlap to improve clarity.
Documentation updates
- Update publication record.
- Update package-level manual entry.
- Update URLs.
- Fix aliasing for package manual entry (#301).
- R
Published by jeffreyhanson over 1 year ago
prioritizr - prioritizr 8.0.3
Notice
- We have developed a better approach for rescaling boundary data to
avoid numerical issues during optimization (#297). Earlier versions of the
package recommended the use of the
scales::rescale()to rescale such data. However, we now realize that this approach can produce inconsistencies for boundary length data (e.g., the total perimeter of a planning unit might not necessarily equal the sum of the edge lengths). In some cases, these inconsistencies can cause solutions generated with high boundary penalties (i.e., usingadd_boundary_penalties()with a highpenaltyvalue) to contain a large reserve (i.e., a spatial cluster of selected of planning units) with a single unselected planning unit in the middle of the reserve. In the the worst case, these inconsistencies produce a situation where increasing boundary penalties (i.e., generating multiple solutions withadd_boundary_penalties()and increasingpenaltyvalues) does not alter the spatial configuration of solutions. Although use ofscales::rescale()did not produce such behavior prior to version 8.0.0, changes to the output format forboundary_matrix()in subsequent versions now mean thatscales::rescale()can cause these issues. We now recommend using the newrescale_matrix()function to rescale boundary length data to avoid numerical issues, whilst also avoid such inconsistencies.
New features
- New
rescale_matrix()function to help with rescaling boundary length (e.g., generated usingboundary_matrix()) and connectivity (e.g., generated usingconnectivity_matrix()) data so avoid numerical issues during optimization (#297). - Update
add_neighbors_constraints()so that it has an additionalclampargument so the minimum number of neighbors permitted for each planning unit in the solution is clamped to the number of neighbors that each planning unit has. For example, if a planning unit has 2 neighbors,k = 3, andclamp = FALSE, then the planning unit could not ever be selected in the solution. However, ifclamp = TRUE, then the planning unit could potentially be selected in the solution if both of its 2 neighbors were also selected.
Minor improvements and bug fixes
- Update examples and vignettes to use the
rescale_matrix()function instead of thescales::rescale()function for rescaling boundary length and connectivity data (#297). - Update the
print()andsummary()methods forproblem()objects so that they will now better describe situations when the planning cost data all contain a constant value (e.g., all costs equal to 1). - Fix issue with
problem()that preventsfeaturesbeing supplied as adata.framethat contains feature names stored as afactor(#295). - Fix broken URLs in documentation.
- Fix compatibility with updates to terra package.
- Fix
rij_matrix()so that it works when none of the raster layers being processed fit into memory (#290). - Fix spatial extent of built-in raster datasets so that extents are between
0 and 1 (i.e.,
get_sim_pu_raster(),get_sim_locked_in_raster(),get_sim_locked_out_raster(),get_sim_zones_pu_raster(),get_sim_features(),get_sim_zones_features()). - Update
add_manual_locked_constraints()andadd_manual_bounded_constraints()so that the indices in the specified in the argumentdata$pushould consistently refer to the total units. In other words, the indices indata$pushould refer to the row numbers (for planning units insfordata.frameformat) or cell numbers (for planning units inRasterorSpatRasterformat) of the planning units that should be locked. - Fix warnings thrown due to package version comparisons.
- Update
problem()so that it will throw a meaningful error message if the user accidentally specifies the geometry column forsfplanning unit data as a feature. - Export
solve.ConservationProblem()so that it can be called directly (#283). - Fix compatibility with highs package (version 0.1-10) (#281).
- Update
problem()so that an error will be thrown if argument tofeaturescontains only missing (NA) values (e.g., an sf object is supplied that hasNAvalues in all rows for a feature's column). - Update publication record.
- R
Published by jeffreyhanson over 2 years ago
prioritizr - prioritizr 8.0.2
Notice
- The package has been updated to focus on using the sf and terra package
for spatial vector and raster datasets. This is because the sf package is
the successor to the sp package, and the terra package is the successor
to the raster package. By leveraging these newer packages, the prioritizr
package can provide better performance. Although sp and raster package
classes (e.g.,
raster::stack()andsp::SpatialPolyonsDataFrame()) are still supported, the prioritizr package will now throw deprecation warnings. Since support for the sp and raster package classes will be fully deprecated and removed in a later version this year, we recommend updating code to use the sf and terra packages.
Breaking changes
- All proto classes have been migrated to R6 classes. This update reduces
memory usage (#238), so
problem()objects can now contain many more constraints and penalties. Note that anyproblem()objects that were produced using earlier versions of the package are no longer compatible. - The proto, raster, sf, sp packages are no longer automatically
loaded alongside prioritizr. As such, users will need to load them manually
(e.g., using
library(sf)). - The built-in datasets have been removed and replaced with functions
to import them as needed (i.e.,
get_sim_pu_raster(),get_sim_pu_polygons(),get_sim_pu_lines(),get_sim_pu_points(),,get_sim_locked_in_raster(),get_sim_locked_out_raster(),get_sim_zones_pu_raster(),get_sim_zones_pu_polygons(),get_sim_phylogeny(),get_sim_features(),get_sim_zones_features()). These functions now returnsf::st_sf(),terra::rast(),ape::read.tree()andzones()objects. Note that these functions are provided becausedata(...)cannot be used withterra::rast()objects. See?datafor more information. - The
boundary_matrix()output format has been updated. This means that users will not be able to use boundary data generated using previous versions of the package. - The
add_lpsymphony_solver()now throws an error, instead of a warning, if an old version of the lpsymphony R package is installed that is known to produce incorrect results. - The
marxan_boundary_data_to_matrix()function is no longer compatible with boundary data for multiple zones. - The
distribute_load()function has been deprecated, because it is no longer used. For equivalent functionality, Seeparallel::splitIndices(). - The
new_optimization_problem()andpredefined_optimization_problem()functions have been superseded by the newoptimization_problem()function. - To simplify package documentation and functionality, the following functions
are no longer exported:
is.Waiver(),add_default_decisions()new_id(),is.Id(),print.Id(),pproto().
New features
- The
print()function forproblem(),optimization_problem(), andzones()objects has been updated to provide more information. - New
summary()function to provide extensive detail onproblem()objects. - Updates to improve the error messages and error message handling.
Hopefully, users should no longer see
"bad error message"!
Minor improvements and bug fixes
- Fix bug for
add_feature_weights()when applied to problems with anadd_max_phylo_div_objective()oradd_max_phylo_end_objectve(). Specifically, the bug meant that weights weren't being applied to problems with these particular objectives. - Fix instructions in
add_gurobi_solver()documentation for opening vignette. - Update solver functions to provide instructions for installing dependencies in error messages when their dependencies are not available.
- To ensure consistency among the portfolio functions, all of them (except for
add_extra_portfolio()) default to generating 10 solutions. - Update publication record.
- The
solve()function will now outputtibble::tibble()objects (instead ofdata.frame()objects), when the planning unit data aretibble::tibble()objects. - The
boundary_matrix()function now usesterra::sharedPaths()for calculations, providing greater performance (#257). - The
eval_ferrier_importance()function can now be used with any objective function that uses targets and a single zone. - Fix CRAN note regarding C++ standards (#263).
- Remove doParallel and plyr packages as dependencies by simplifying
the
add_shuffle_portfolio()andeval_replacement_importance()functions. - Assorted tweaks to improve writing in the vignettes and documentation. Many thanks to Marc Edwards (@edwardsmarc)!
- R
Published by jeffreyhanson almost 3 years ago
prioritizr - prioritizr 7.2.2
- Fix compiler warnings.
- Update tests to skip long-running tests on CRAN.
- Update examples to minimize overall package check timings for CRAN.
- Fix compatibility with upcoming Matrix package version (version 1.5-0).
- Update package documentation to provide details for obtaining and installing the cplexAPI package since it has been archived on CRAN (#214).
- Fix bug that caused the
add_cbc_solver()to throw a segfault when solving a problem wherein therij_matrix(x)has a zero amount for the last feature in the last planning unit (#247). - Update
simulate_data(),simulate_cost()andsimulate_species()functions to improve performance using the fields package. - Update
boundary_matrix()to use STR query trees by default. - Remove maptools, PBSmapping, and rgeos packages as dependencies. This involved updating the unit tests to hard-code correct results, updating examples to use the sf package, and updating the
boundary_matrix()to use the geos package (#218). - Fix broken URLs in package documentation.
- Update publication record.
- Update the
presolve_check()function to (i) reduce chances of it incorrectly throwing an error when the input data won't actually cause any issues, and (ii) provide recommendations for addressing issues. - Update documentation for
add_min_largest_shortfall_objective()so that examples complete in a shorter period of time. - Fix bug in processing planning unit data when a problem is constructed using arguments to (i)
xthat arenumericormatrixformat, (ii)xthat contain missing (NA) values, and (iii)rij_matrixthat are indgCMatrixformat. This bug only occurred when all three of these specific conditions were met. When it occurred, the bug caused planning units withNAcost values to receive very high cost values (e.g., 1e+300). This bug meant that when attempting to solve the problem, the presolve checks (perpresolve_check()) would throw an error complaining about very high cost values (#236). - Fix
add_locked_in_constraints()andadd_locked_out_constraints()to ensure that a meaningful error message is provided when no planing units are locked (#234). - Fix
presolve_check()so that it does not throw a meaningless warning when the mathematical objective function only contains zeros. - Update
presolve_check()to help reduce chances of mis-attributing high connectivity/boundary values due to planning unit costs. - Update
add_connectivity_penalties()function and documentation so that it is designed specifically for symmetric connectivity data. - New
add_asym_connectivity_penalties()function that is designed specifically for asymmetric connectivity data. This function has been created to help ensure that asymmetric connectivity data are handled correctly. For instance, using asymmetric connectivity data withadd_connectivity_penalties()function in previous versions of the package sometimes resulted in the data being incorrectly treated as symmetric data. Additionally, this function uses an updated mathematical formulation for handling asymmetric connectivity so that it provides similar results to the Marxan software (#323). - Update
marxan_problem()function so that it can be used with asymmetric connectivity data. This is now possible because there are dedicated functions for symmetric and asymmetric connectivity. - Improve documentation for the
zonesparameter of theadd_connectivity_penalties()function. - Update documentation for
eval_ferrier_importance()(#220). Although this function is now recommended for general use, the documentation contained an outdated warning and so the warning has now been removed. - Fix bug so that the
eval_n_summary()function now returns a table with the column name"n"(instead of"cost") for the number of selected planning units (#219). - Update reference index for package website.
- Fix minor typos in vignettes.
- Minimum version numbers are now provided for all R package dependencies (excepting base R packages) (#217).
- The data.table package is now listed as a suggested (optional) dependency. This is because it is only used by the
marxan_problem()for importing Marxan data files. - The Tasmania tutorial has been reworked into the Getting started tutorial. This tutorial now provides short introduction to using the package.
- The Salt Spring Island tutorial has been reworked into the Connectivity tutorial. This tutorial now explores different approaches for incorporating connectivity.
- The prioritizr vignette has been renamed to the Package overview vignette.
- New Calibrating trade-offs tutorial showcasing methods for running calibration analyses. It outlines blended and hierarchical approaches for generating a set of different prioritizations based on different parameters. It also covers different approaches for selecting a candidate prioritization based on different trade-offs.
- Update tests to reduce run time and pass given slightly different results with new Gurobi version (9.5.0).
- Update built-in
sim_pu_sfandsim_pu_zones_sfdata given class updates to the sf package (compatible with version 1.0.3+). - Update example for
write_problem()function.
- R
Published by jeffreyhanson over 3 years ago
prioritizr - prioritizr 3.0.4
This release contains version 3.0.4 of the prioritizr R package. It is significant because this version is the most the most up-to-date and best-working version of the package before it was over-hauled to manage problems with multiple management zones.
- R
Published by jeffreyhanson almost 8 years ago