Title: | Operations Research LOCational Analysis Models |
---|---|
Description: | Objects and methods to handle and solve the min-sum location problem, also known as Fermat-Weber problem. The min-sum location problem search for a point such that the weighted sum of the distances to the demand points are minimized. See "The Fermat-Weber location problem revisited" by Brimberg, Mathematical Programming, 1, pg. 71-76, 1995. <DOI:10.1007/BF01592245>. General global optimization algorithms are used to solve the problem, along with the adhoc Weiszfeld method, see "Sur le point pour lequel la Somme des distances de n points donnes est minimum", by Weiszfeld, Tohoku Mathematical Journal, First Series, 43, pg. 355-386, 1937 or "On the point for which the sum of the distances to n given points is minimum", by E. Weiszfeld and F. Plastria, Annals of Operations Research, 167, pg. 7-41, 2009. <DOI:10.1007/s10479-008-0352-z>. |
Authors: | Manuel Munoz-Marquez <[email protected]> |
Maintainer: | Manuel Munoz-Marquez <[email protected]> |
License: | GPL (>= 3) |
Version: | 5.6 |
Built: | 2024-11-04 02:50:38 UTC |
Source: | https://github.com/cran/orloca |
Objects and methods to handle and solve the min-sum location problem, also known as Fermat-Weber problem.
Package: orloca Type: Package Version: 5.6 Date: 2024-01-31 License: GPL (>= 3)
The min-sum location problem search for a point such that the weighted sum of the distances to the demand points are minimized. See "The Fermat-Weber location problem revisited" by Brimberg, Mathematical Programming, 1, pg. 71-76, 1995, doi:10.1007/BF01592245.
General global optimization algorithms are used to solve the problem, along with the adhoc Weiszfeld method, see "Sur le point pour lequel la Somme des distances de n points donnes est minimum", by E. Weiszfeld, Tohoku Mathematical Journal, First Series, 43, pg. 355-386, 1937 or "On the point for which the sum of the distances to n given points is minimum", by E. Weiszfeld and F. Plastria, Annals of Operations Research, 167, pg. 7-41, 2009, doi:10.1007/s10479-008-0352-z.
The package provides a class loca.p
that represents a location problem with a finite set of demand points on the plane.
Also, it is possible to plot the points and the objective function.
Such objective function is the total weighted distances travelled by all the customers to the service.
Non-planar location problems could be handle in future versions of the package.
For a demo, load the package with the instruction library(orloca)
, and run the demo executing the instruction demo(orloca)
.
The package is ready for internationalization. The author kindly ask for translated version of the .mo file to include in the package.
Manuel Munoz-Marquez <[email protected]>
Mantainer: Manuel Munoz-Marquez <[email protected]>
[1] Brimberg, J. The Fermat-Weber location problem revisited, Mathematical Programming, 1, pg. 71-76, 1995. doi:10.1007/BF01592245.
[2] Love, R. F., Morris, J. G., Wesolowsky, G. O. Facilities Location: Chapter 2: Introduction to Single-Facility Location, 1988, North-Holland. ISBN: 0-444-01031-9.
[3] Weiszfeld, E. and Plastria, F. On the point for which the sum of the distances to n given points is minimum, Annals of Operations Research, 167, pg. 7-41, 2009, doi:10.1007/s10479-008-0352-z.
[4] http://knuth.uca.es/orloca/
Useful links:
# A new unweighted loca.p object o <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Compute the sum of distances to point (3, 4) # [1] 20.39384 distsum(o, 3, 4) # Compute the sum of distances to point (3, 4) using lp norm with p = 2.5 # [1] 19.27258 distsum(o, 3, 4, lp = 2.5) # Solve the optimization problem # [1] 0 0 distsummin(o) # Contour plot contour(o) # Run a demo of the package demo(orloca)
# A new unweighted loca.p object o <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Compute the sum of distances to point (3, 4) # [1] 20.39384 distsum(o, 3, 4) # Compute the sum of distances to point (3, 4) using lp norm with p = 2.5 # [1] 19.27258 distsum(o, 3, 4, lp = 2.5) # Solve the optimization problem # [1] 0 0 distsummin(o) # Contour plot contour(o) # Run a demo of the package demo(orloca)
The 'andalusia' data frame has 12 rows and 4 columns, which are the geographical position of the main capital cities of andalusia.
name
: The name of the city or relative position label.
x
: The x coordinate of points.
y
: The y coordinate of points.
city
: If yes the point is a city in other case is a limit.
data('andalusia')
Data are taken from wikipedia.
See also orloca-package
.
Conversions between loca.p class and some others classes
x |
is the object to convert to the new class object. |
row.names |
Unused. |
optional |
Unused. |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
Conversions between loca.p class and some others classes
## S3 method for class 'loca.p' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
## S3 method for class 'loca.p' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
is the object to convert to the new class object. |
row.names |
Unused. |
optional |
Unused. |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
Conversions between loca.p class and some others classes
as.loca.p(x, ...)
as.loca.p(x, ...)
x |
is the object to convert to the new class object. |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
Conversions between loca.p class and some others classes
as.loca.p.data.frame(x, ...)
as.loca.p.data.frame(x, ...)
x |
is the object to convert to the new class object. |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
Conversions between loca.p class and some others classes
as.loca.p.matrix(x, ...)
as.loca.p.matrix(x, ...)
x |
is the object to convert to the new class object. |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
Conversions between loca.p class and some others classes
## S3 method for class 'loca.p' as.matrix(x, rownames.force = NA, ...)
## S3 method for class 'loca.p' as.matrix(x, rownames.force = NA, ...)
x |
is the object to convert to the new class object. |
rownames.force |
If True the rownames is setted |
... |
Other arguments, unused. |
Methods to convert from and to loca.p
class.
NA's values are not allowed in any of the arguments.
The matrix
or data.frame
to convert into loca.p
must have at least two columns.
The first column will be consider as the x coordinates, the second as the y coordinates, and the third (if given) as the values of weights w
.
It returns a new object of the new class.
See also loca.p
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Conversion to matrix m <- as.matrix(loca) # Show matrix m # Conversion from matrix as.loca.p(m)
contour
provides a graphical representations of min-sum objective function, which is the weighted sum of the distances to demand points (distsum
).
## S3 method for class 'loca.p' contour( x, lp = numeric(0), xmin = min(min(x@x), xleft), xmax = max(max(x@x), xright), ymin = min(min(x@y), ybottom), ymax = max(max(x@y), ytop), n = 100, img = NULL, xleft = min(x@x), ybottom = min(x@y), xright = max(x@x), ytop = max(x@y), ... )
## S3 method for class 'loca.p' contour( x, lp = numeric(0), xmin = min(min(x@x), xleft), xmax = max(max(x@x), xright), ymin = min(min(x@y), ybottom), ymax = max(max(x@y), ytop), n = 100, img = NULL, xleft = min(x@x), ybottom = min(x@y), xright = max(x@x), ytop = max(x@y), ... )
x |
The loca.p object to compute the objective. |
lp |
If given, then |
xmin |
The minimum value for x axis. |
xmax |
The maximum value for x axis. |
ymin |
The minimum value for y axis. |
ymax |
The maximum value for y axis. |
n |
The number of divisions for grid. |
img |
A raster image to plot on background. |
xleft |
The left position of the image. |
ybottom |
The bottom position of the image. |
xright |
The right position of the image. |
ytop |
The top position of the image. |
... |
Other options. |
If then
is not a norm, so only
are valid values.
contour.loca.p
plots a contour plot of min-sum function (distsum
).
See also orloca-package
, plot.loca.p
and loca.p
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The contour plot of min-sum function for loca (a loca.p object) contour(loca)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The contour plot of min-sum function for loca (a loca.p object) contour(loca)
The objective function and the gradient of the objective function for the min-sum location problem.
distsum(o, x = 0, y = 0, lp = numeric(0))
distsum(o, x = 0, y = 0, lp = numeric(0))
o |
An object of |
x |
The x coordinate of the point to be evaluated. |
y |
The y coordinate of the point to be evaluated. |
lp |
If given, then |
The function zsum is deprecated and will be removed from new versions of the package.
distsum
returns the objective function of the min-sum location problem, , where
gives the euclidean or the
distances between
and the point
.
See also orloca-package
and distsummin
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Evaluation of distsum at (0, 0) distsum(loca) # Evaluation of distsum at (1, 3) distsum(loca, 1, 3) # Compute the objective function at point (3, 4) using lp norm and p = 2.5 distsum(loca, 3, 4, lp=2.5) # The gradient function at (1,3) distsumgra(loca, 1, 3)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Evaluation of distsum at (0, 0) distsum(loca) # Evaluation of distsum at (1, 3) distsum(loca, 1, 3) # Compute the objective function at point (3, 4) using lp norm and p = 2.5 distsum(loca, 3, 4, lp=2.5) # The gradient function at (1,3) distsumgra(loca, 1, 3)
The gradient of the objective function for the min-sum location problem.
distsumgra(o, x = 0, y = 0, lp = numeric(0), partial = F)
distsumgra(o, x = 0, y = 0, lp = numeric(0), partial = F)
o |
An object of |
x |
The x coordinate of the point to be evaluated. |
y |
The y coordinate of the point to be evaluated. |
lp |
If given, then |
partial |
If (x,y) is a demand point |
The function zsumgra is deprecated and will be removed from new versions of the package.
distsumgra
returns the gradient vector of the objective function of the min-sum location problem, , where
gives the euclidean or the
distances between
and the point
.
See also orloca-package
and distsum
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Evaluation of distsum at (0, 0) distsum(loca) # Evaluation of distsum at (1, 3) distsum(loca, 1, 3) # Compute the objective function at point (3, 4) using lp norm and p = 2.5 distsum(loca, 3, 4, lp=2.5) # The gradient function at (1,3) distsumgra(loca, 1, 3)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Evaluation of distsum at (0, 0) distsum(loca) # Evaluation of distsum at (1, 3) distsum(loca, 1, 3) # Compute the objective function at point (3, 4) using lp norm and p = 2.5 distsum(loca, 3, 4, lp=2.5) # The gradient function at (1,3) distsumgra(loca, 1, 3)
Solve the min-sum location problem for a given loca.p
class object.
distsummin( o, x = 0, y = 0, lp = numeric(0), max.iter = 1e+05, eps = 0.001, verbose = FALSE, algorithm = "Weiszfeld", ... )
distsummin( o, x = 0, y = 0, lp = numeric(0), max.iter = 1e+05, eps = 0.001, verbose = FALSE, algorithm = "Weiszfeld", ... )
o |
An object of loca.p class. |
x |
The x coordinate of the starting point. It's default value is 0. |
y |
The y coordinate of the starting point. It's default value is 0. |
lp |
If given, the |
max.iter |
Maximum number of iterations allowed. It's default value is 100000. |
eps |
The module of the gradient in the stop rule. It's default value is 1e-3. |
verbose |
If TRUE the function produces detailed output. It's default value is FALSE. |
algorithm |
The method to be use. For this version of the package, the valid values are: "gradient" for a gradient based method, "search" for local search method (this option is deprecated), "ucminf" for optimization with ucminf from ucminf package, and "Weiszfeld" for the Weiszfeld method or any of the valid method for optim function, now "Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN". "Weiszfeld" is the default value. |
... |
Other options for optimization algorithms. |
The algorithms Weiszfeld and gradient include and optimality test for demand points. The Weiszfeld version of the algorithm also implements slow convergence test and accelerator procedure.
If thus
is not a norm, so, only
are valid values.
Since norm is the Euclidean norm, when
distsumlpmin
are equal to distsummin
.
But the computations involved are greater for the first form.
max.iter for SANN algorithm is the number of evaluation of objective function, so this method usually requires large values of max.iter to reach optimal value
The function zsummin is deprecated and will be removed from new versions of the package.
distsummin
returns an array with the coordinates of the solution point.
See also orloca-package
, loca.p
and distsum
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Compute the minimum sol<-distsummin(loca) # Show the result sol # Evaluation of the objective function at solution point distsum(loca, sol[1], sol[2])
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Compute the minimum sol<-distsummin(loca) # Show the result sol # Evaluation of the objective function at solution point distsum(loca, sol[1], sol[2])
An object of class loca.p
represents a weighted location problem with a finite demand points set.
The orloca-package
is mainly devoted to deals with location problems.
x |
is a vector of the x coordinates of the demand points. |
y |
is a vector of the y coordinates of the demand points. |
w |
is a vector of weights of the demand points. If w is omitted then all weights are considered as 1. |
label |
If given, it is the label of the new object. |
The main generator of the loca.p class is loca.p(x, y, w = numeric(0), label = "")
.
An alternative form is new("loca.p", x, y, w = numeric(0), label = "")
.
The lengths of x
and y
vector must be equals.
The length of w
must be equal to the previous ones or must be 0, or should be omitted.
NA's values are not allowed at any of the arguments.
summary(x)
returns a summary of the x
loca.p
object and print(x)
prints the x
loca.p
object in table format.
If the arguments have valid values, it returns a new object of class loca.p
, else it returns an error.
See also orloca-package
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # or loca <- new("loca.p", x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # An example with weights and name locb <- new("loca.p", x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1), w = c(1, 2, 1, 2), label = "Weighted case")
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # or loca <- new("loca.p", x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # An example with weights and name locb <- new("loca.p", x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1), w = c(1, 2, 1, 2), label = "Weighted case")
Objetos y metodos para manejar y resolver el problema de localizacion de suma ponderada minima, tambien conocido como problema de Fermat-Weber.
Paquete: orloca Version: 5.5 Fecha: 2023-09-19 Licencia: GPL (>= 3)
El problema de localizacion de suma minima busca un punto tal que la suma ponderada de las distancias a los puntos de demanda se minimice. Vease "The Fermat-Weber location problem revisited" por Brimberg, Mathematical Programming, 1, pag. 71-76, 1995. doi:10.1007/BF01592245.
Se usan algoritmos generales de optimizacion global para resolver el problema, junto con el metodo adhoc Weiszfeld, vease "Sur le point pour lequel la Somme des distance de n points donnes est minimum", por Weiszfeld, Tohoku Mathematical Journal, First Series, 43, pag. 355-386, 1937 o "On the point for which the sum of the distances to n given points is minimum", por E. Weiszfeld y F. Plastria, Annals of Operations Research, 167, pg. 7-41, 2009. doi:10.1007/s10479-008-0352-z.
El paquete proporciona una clase loca.p
que representa un problema de localizacion sobre el plano.
Tambien permite dibujar los puntos junto a la funcion objetivo.
Dicho objetivo es la suma ponderada de las distancias que viajan los clientes del servicio.
Versiones no planas del problema podrian incorporarse en futuras versiones del paquete.
Para una demostracion, cargue el paquete con la instrucción library(orloca)
y ejecute la demostracion con la instruccion demo(orloca)
.
El paquete esta preparado para su internacionalizacion. Las traducciones de los ficheros .mo recibidas seran anadidas en proximas versiones del paquete.
Manuel Munoz-Marquez <[email protected]>
Mantenedor: Manuel Munoz-Marquez <[email protected]>
[1] Brimberg, J. The Fermat-Weber location problem revisited, Mathematical Programming, 1, pg. 71-76, 1995. doi:10.1007/BF01592245.
[2] Love, R. F., Morris, J. G., Wesolowsky, G. O. Facilities Location: Chapter 2: Introduction to Single-Facility Location, 1988, North-Holland
[3] Weiszfeld, E. and Plastria, F. On the point for which the sum of the distances to n given points is minimum, Annals of Operations Research, 167, pg. 7-41, 2009, doi:10.1007/s10479-008-0352-z.
[4] http://knuth.uca.es/orloca/
# Un objeto loca.p no ponderado o <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Calcula la funcion objetivo en el punto (3, 4) # [1] 20.39384 zsum(o, 3, 4) # Calcula la suma de las distancias al punto (3, 4) usando la norma lp con p = 2.5 # [1] 19.27258 zsum(o, 3, 4, lp = 2.5) # Resuelve el problema de localizacion # [1] 0 0 zsummin(o) # Curvas de nivel contour(o) # Ejecuta una demo del paquete demo(orloca)
# Un objeto loca.p no ponderado o <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # Calcula la funcion objetivo en el punto (3, 4) # [1] 20.39384 zsum(o, 3, 4) # Calcula la suma de las distancias al punto (3, 4) usando la norma lp con p = 2.5 # [1] 19.27258 zsum(o, 3, 4, lp = 2.5) # Resuelve el problema de localizacion # [1] 0 0 zsummin(o) # Curvas de nivel contour(o) # Ejecuta una demo del paquete demo(orloca)
persp
provides a graphical representations of objetive function of the min-sum problem, which is the total weighte distance to the demand points (distsum
).
## S3 method for class 'loca.p' persp( x, lp = numeric(0), xmin = min(x@x), xmax = max(x@x), ymin = min(x@y), ymax = max(x@y), n = 10, ticktype = "detailed", ... )
## S3 method for class 'loca.p' persp( x, lp = numeric(0), xmin = min(x@x), xmax = max(x@x), ymin = min(x@y), ymax = max(x@y), n = 10, ticktype = "detailed", ... )
x |
The loca.p object to compute the objective. |
lp |
If given, then |
xmin |
The minimum value for x axis. |
xmax |
The maximum value for x axis. |
ymin |
The minimum value for y axis. |
ymax |
The maximum value for y axis. |
n |
The number of divisions for grid. |
ticktype |
parameter to pass to low level function persp |
... |
Other options. |
If then
is not a norm, so only
are valid values.
A plot a 3D plot or min-sum function.
See also orloca-package
, plot.loca.p
and loca.p
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The 3D graphics persp(loca)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The 3D graphics persp(loca)
This method provides a graphical representations of an object of class loca.p
.
## S3 method for class 'loca.p' plot( x, xlab = "", ylab = "", main = paste(gettext("Plot of loca.p"), ifelse(x@label == "", "", paste0(": \"", x@label, "\""))), img = NULL, xlim = c(min(xleft, min(x@x)), max(xright, max(x@x))), ylim = c(min(ybottom, min(x@y)), max(ytop, max(x@y))), xleft = min(x@x), ybottom = min(x@y), xright = max(x@x), ytop = max(x@y), ... )
## S3 method for class 'loca.p' plot( x, xlab = "", ylab = "", main = paste(gettext("Plot of loca.p"), ifelse(x@label == "", "", paste0(": \"", x@label, "\""))), img = NULL, xlim = c(min(xleft, min(x@x)), max(xright, max(x@x))), ylim = c(min(ybottom, min(x@y)), max(ytop, max(x@y))), xleft = min(x@x), ybottom = min(x@y), xright = max(x@x), ytop = max(x@y), ... )
x |
The |
xlab |
The label for x axis. |
ylab |
The label for y axis. |
main |
The main title for the plot. |
img |
A raster image to plot on background. |
xlim |
Limit over the x axes of the plot. |
ylim |
Limit over the y axes of the plot. |
xleft |
The left position of the image. |
ybottom |
The bottom position of the image. |
xright |
The right position of the image. |
ytop |
The top position of the image. |
... |
Other graphical options. |
The function plots demand points by evaluating limits automatically.
The function plots the required graphics.
See also orloca-package
, loca.p
and plot
.
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The plot of loca object plot(loca)
# A new unweighted loca.p object loca <- loca.p(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)) # The plot of loca object plot(loca)
rloca.p
function returns a random instance of loca.p
class object at a given rectangular region.
rloca.p( n, xmin = 0, xmax = 1, ymin = 0, ymax = 1, wmin = 1, wmax = 1, label = "", groups = 0, xgmin = xmin, xgmax = xmax, ygmin = ymin, ygmax = ymax )
rloca.p( n, xmin = 0, xmax = 1, ymin = 0, ymax = 1, wmin = 1, wmax = 1, label = "", groups = 0, xgmin = xmin, xgmax = xmax, ygmin = ymin, ygmax = ymax )
n |
The number of demand points. |
xmin |
Minimum value for the x coordinates of the demand points. |
xmax |
Maximum value for the x coordinates of the demand points. |
ymin |
Minimum value for the y coordinates of the demand points. |
ymax |
Maximum value for the y coordinates of the demand points. |
wmin |
Minimum value for weights |
wmax |
Maximum value for weights |
label |
The label for the new loca.p object. |
groups |
The number of (almost) equal size groups to generate, or a list size of the groups to generate. In the second case |
xgmin |
Minimum value for the x coordinate of demand points with respect to the group reference point. |
xgmax |
Maximum value for the x coordinate of demand points with respect to the group reference point. |
ygmin |
Minimum value for the y coordinate of demand points with respect to the group reference point. |
ygmax |
Maximum value for the y coordinate of demand points with respect to the group reference point. |
n
must be at least 1.
xmin
must be less or equal than xmax
.
ymin
must be less or equal than ymax
.
If a non zero value is given for groups
parameter, then a reference point for each group are generated. At second stage, the offset part for each demand point are generated, and added to the reference point generated at the first stage.
Note that groups = 1
is not equivalent to the default value groups = 0
, because in the first case a reference point are generated at the first stage.
If the arguments are valid values, it returns a new object of loca.p
class, else it returns an error.
See also orloca-package
and loca.p
.
# A random loca.p object at unit square with 5 demand points rloca.p(5) # At another region rloca.p(10, xmin=-2, xmax=2, ymin=-2, ymax=2) # Five groups rloca.p(48, groups=5) # Three unequal size groups rloca.p(1, groups=c(10, 7, 2))
# A random loca.p object at unit square with 5 demand points rloca.p(5) # At another region rloca.p(10, xmin=-2, xmax=2, ymin=-2, ymax=2) # Five groups rloca.p(48, groups=5) # Three unequal size groups rloca.p(1, groups=c(10, 7, 2))
The function zsumgra is deprected and could be removed in next version of the package. Use distsumgra instead.
zsumgra(...)
zsumgra(...)
... |
Parameters passed to distsumgra |
The function zsummin is deprected and could be removed in next version of the package. Use distsummin instead.
zsummin(...)
zsummin(...)
... |
Parameters passed to distsummin |