backward: Compute the gradient of a solution with respect to Parameters

View source: R/141_problems_problem.R

backwardR Documentation

Compute the gradient of a solution with respect to Parameters

Description

Differentiates through the solution map of problem: populates the gradient slot of each Parameter with the sensitivity of a scalar-valued function of the variables (defaulting to the sum-of-x loss; override per variable by setting ⁠gradient(variable) <-⁠ before calling) with respect to that parameter. Mirrors cvxpy.Problem.backward().

Usage

backward(problem)

Arguments

problem

A solved Problem.

Details

Must be called after psolve() with requires_grad = TRUE.

Value

The problem (for piping); side-effect sets gradient(param) on each parameter.

See Also

derivative(), psolve(), gradient()


CVXR documentation built on Aug. 24, 2026, 9:10 a.m.