Methods to optimize sample configurations using spatial simulated annealing. Multiple objective functions are implemented for various purposes, such as variogram estimation, spatial trend estimation and spatial interpolation. A general purpose spatial simulated annealing function enables the user to define his/her own objective function. Solutions for augmenting existing sample configurations and solving multi-objective optimization problems are available as well.
The spsann package was created to help you creating optimum spatial
sample configurations using the power of spatial simulated annealing. It
can be downloaded from CRAN
using:
install.packages(pkgs = "spsann")
The development version of spsann, available at
GitHub, can be downloaded --
using the devtools package -- with:
if (!require(devtools)) {
install.packages(pkgs = "devtools")
}
devtools::install_github("samuel-rosa/spsann")
We use the fork & pull collaborative development model. This means that you are free to make a parallel copy of this repository, change the source code as you see fit, and then push the changes to your personal copy of this repository. All this without requiring any authorization. If the changes you've made to your personal copy of this repository are interesting and you're willing to share them with us, then just have them pulled -- pull request -- to this repository. After reviewing the changes, we will decide whether they can be merged -- merge -- with the source code of this repository.
The new version of the spsann package includes some bug fixes and a few modifications. Users now can
choose how optimCLHS computes objective function values: as in the original paper or as in the FORTRAN
implementation. Users now also must inform the weights passed to optimCLHS as to guarantee that s/he is
aware of what s/he is doing. The same apples to other functions that deal with multi-objective optimization
problems: optimACDC and optimSPAM. Another important modification in the current version of spsann is
the possibility to use a finite set of candidate locations by setting cellsize = 0. This is useful when
optimizing sample points only in the feature space and should reduce the computation time needed to find the
solution.
plot.OptimizedSampleConfiguration related to the selection of the information to be
displayed.weights of optimCLHS, optimACDC and optimSPAM now is mandatory. The user is now required to
set the weights as to guarantee that s/he is aware of what s/he is doing.data.frames that store objective function
values.cellsize = 0. When
this is done, spsann now checks for neighbouring candidate locations already included in the sample as to
avoid duplicated sampling points.optimCLHS computes objective function values.optimCLHS computes objective function values.optimCLHS computes objective function values.Now spsann can be used to augment an existing sample configuration, that is, add new sampling points
to a spatial sample configuration generated using spsann or any other means. To do so, when using one
of the functions from the family of optim...() functions, the user must pass to the function argument
points an object of class list containing two named sub-arguments: fixed, a matrix with the
coordinates of the existing sample configuration -- kept fixed during the optimization --, and free,
the number of sample points that should be added to the existing sample configuration -- free to move around
during the optimization.
This is a major release of package spsann that includes several conceptual changes. Despite our efforts, it was not possible to guarantee the compatibility with previous versions. We have decided not to deprecate functions and function arguments because (1) this would require deprecating a lot of code and (2) you should first read the updated package documentation to understand the conceptual changes that we have made before you start using it. This is a summary of the changes:
scheduleSPSANN.minmaxPareto(). This function computes the Pareto maximum and minimum values of the
objective functions that compose the MOCOP needed to scale the objective functions to the same approximate
range of values.OptimizedSampleConfiguration. This
object contains three slots. The first (points) holds the coordinates of the optimized sample
configuration. The second, spsann, stores information about the settings used with the spatial simulated
annealing algorithm. The third, objective, holds the settings used with the chosen objective function.
Methods were implemented to retrieve information from the new class, as well as producing plots of the
optimized sample configuration.devel branch was merged into master branch.knitr is
the engine used to produce the package vignette.OptimizedSampleConfiguration.OptimizedSampleConfiguration is no longer exported.optimPPL was incorrect because it neglected the fact that, in a full
distance matrix, two points a and b form two pairs, i.e. ab and ba.
The mistake is due to the fact that we use SpatialTools::dist1 to compute
the distance matrix instead of stats::dist.optimPPL.autofun to check the number of accepted jitters in the first
chain. If the number of accepted jitters is superior to the value passed to
schedule$initial.acceptance, the process continues and a message is printed
informing the proportion of jitters that have been accepted.optimCLHS()
following the original Fortran code of Budiman Minasny."txt", for a text progress bar in the R console, "tk", to put
up a Tk progress bar widget, and NULL to omit the progress bar. A Tk
progress bar widget is useful when running spsann in parallel
processors. The tcltk-package is now a suggested package.base, and due to examples that take more than 5
seconds to run.plotOSC()),
with options to display the evolution of the energy state and/or the
optimized sample configuration.minmaxPareto()) was optimized to be
used with both ACDC and SPAN.OptimizedSampleConfiguration) to store the output of
optim functions.optimMKV()-function to avoid errors due to
the LDLfactor error of the gstat-package had to be reformulated. We are
now using try() with a default value which is returned in case of error.scheduleSPSANN().optimMKV()-function to avoid errors due to
the LDLfactor error of the gstat-package.minmaxPareto().x.max and y.max are, by default, set to half of the maximum distance
in the x- and y-coordinates of candi, respectively. In the same manner, the
argument cutoff of optimPPL() is set, by default, to half of the diagonal
of the rectangle of sides x.max and y.max.optimCORR() that was causing the following error: Error
in if (new_energy <= old_energy) { : missing value where TRUE/FALSE needed.
This bug used to affect optimACDC() and optimSPAN().optimCLHS).objSPSANN()) was created to retrieve the energy state
of an optimized sample configuration (OSC) at a given point of the
optimization.R CMD check.utils::globalVariables to avoid the R CMD check note
no visible binding for global variable [variable name]. Source of the
solution: http://stackoverflow.com/a/12429344/3365410.plotit,
track, verbose, and iteration. The first three were set to FALSE,
while the last was set to 100.optimSPAN() and objSPAN() are now full operational..optimPPLcheck() was
renamed as .checkPPL(), and .getLagBreaks() was renamed as .lagsPPL().
Note that the first part of the function name indicates what it does, while
the second indicates the objective function to which it applies. This
standardization is important to ease the construction of multi-objective
optimization problems.covars.type.autofun was created to set-up the covariates (covar).boundary of the spatial domain can now be estimated internally. The user
should use the rgeos package if a more precise boundary is needed.obj...() and optim...()
functions are included in individual files. These R code chunks are used to
automatically build internal functions. Currently, R code chunks are
used to check the arguments of the family of optim...() functions, prepare
points and candi, set plotting options, estimate the boundary,
prepare for jittering, plot and jitter, and prepare the output.obj...() functions may not return the same criterion
value of the optimized sample configuration returned by the family of
optim...() functions if the number of iterations used in the optimization
is equal to 100. The problem seems to disappear if a larger number of
iterations is used.spJitterFinite() now tries to find an alternative point if the new point
already is included in the sample. The number of tries is equal to the total
number of points included in the sample. Because the more points we have, the
more likely it is that the candidate point already is included in the sample.spJitterFinite() now returns the old point if the new point already is in
the sample. This is to avoid an infinite loop at the end of the optimization
when the objective function creates a cluster of points.optimACDC(), including new argument definitions;optimACDC(): optimDIST() and optimCORR();