Skip to contents

Torus case of optimize_base_point: numerically minimizes the total torus distance (dist_torus) from a candidate point p to every row of X, searching over the box \([0,1]^d\) with restarts drawn uniformly in it. See choose_base_point.

Usage

optimize_base_point_torus(X, n_start = 10, maxit = 200, seed = 42)

Arguments

X

A matrix or data frame of torus data in \([0,1)^d\); rows are samples, columns are coordinates.

n_start

Number of random restarts used to avoid local minima of the (non-convex) objective. Defaults to 10.

maxit

Maximum number of optim iterations per restart. Defaults to 200.

seed

Integer random seed used to generate the restart points, for reproducibility. Defaults to 42.

Value

A list with three elements: p (the best point found across all restarts, clamped to \([0,1]^d\)), value (its total torus distance to the rows of X), and convergence (the optim convergence code of the best restart; 0 indicates successful convergence).

Examples

X <- matrix(runif(20), nrow = 10, ncol = 2)
optimize_base_point_torus(X, n_start = 5)
#> $p
#> [1] 0.29449488 0.08879601
#> 
#> $value
#> [1] 3.240758
#> 
#> $convergence
#> [1] 0
#>