Skip to contents

Minimise f over a convex set by gradient steps followed by projection. morie_pgdsdg is the module alias of projected_gradient_descent.

Usage

morie_pgdsdg(f, grad, x0, project, ...)

Arguments

f

Objective function.

grad

Its gradient.

x0

Starting point.

project

Projection onto the feasible set.

...

Further arguments: step size, rule, iteration and tolerance controls; see the source.

Value

A list with the iterate, objective value and convergence trace.

Examples

f <- function(v) sum((v - c(2, -1))^2)
g <- function(v) 2 * (v - c(2, -1))
res <- morie_pgdsdg(f, g, x0 = c(0, 0), project = project_nonneg)
res$x
#> [1] 2 0