vc_plot_lagrange: View equality constraints, objective contours and Lagrange...

View source: R/plot_lagrange.R

vc_plot_lagrangeR Documentation

View equality constraints, objective contours and Lagrange gradients

Description

View equality constraints, objective contours and Lagrange gradients

Usage

vc_plot_lagrange(
  result,
  f,
  g,
  xlim = NULL,
  ylim = NULL,
  n = 81L,
  vector_scale = 0.3,
  show_gradients = TRUE,
  show_weighted = FALSE,
  colors = c(point = "#222222", gradient = "#c44736", weighted = "#dd8800"),
  constraint_colors = "#8250a3",
  colorscale = "Viridis",
  alpha = 0.6,
  line_width = 2,
  marker_size = 10,
  title = NULL,
  xlab = "x",
  ylab = "y"
)

Arguments

result

Two-dimensional vc_lagrange result, including inconclusive or infeasible assessments. This is a supplied-candidate view, not an optimizer.

f, g

Same objective and constraints used in calculation.

xlim, ylim

Optional finite increasing bounds; NULL uses point +/- 1.

n

Integer samples per coordinate, at least two. Stored contour matrices use y rows and x columns. Unavailable samples are gaps.

vector_scale

Positive common display multiplier for gradient vectors. Magnitudes are not normalized; hover retains the unscaled estimates.

show_gradients

Logical; show objective and each constraint gradient when the stored first-derivative data are available.

show_weighted

Logical; additionally show lambda_i times grad(g_i). Their SUM, not each individual vector, matches grad(f) at a regular stationary candidate. They share the candidate as their display origin.

colors

Named point, gradient and weighted colors.

constraint_colors

One color or one per constraint; the same color is used for its zero set and unweighted gradient.

colorscale

Plotly name/list for the objective contours.

alpha

Objective contour opacity between zero and one.

line_width

Positive line/arrow width.

marker_size

Positive candidate marker size.

title

Optional scalar title; default reports conditional classification, reason and numerical constraint-rank diagnostic.

xlab, ylab

Scalar coordinate-axis labels.

Details

Functions are checked against stored candidate values, then sampled for context. A grid may miss singular/tangential/narrow zero sets; absence of a rendered zero contour does not mean no feasible point exists. Finite arrow endpoints that overflow are omitted. Labels remain conditional on the mathematical hypotheses and numerical evidence in result; this plot does not certify regularity, stationarity or an extremum.

Value

Plotly contour widget with candidate marker, zero constraints and stored gradient vectors, plus arrow annotations. Calculation and derivative assessment are not rerun. Legend controls toggle traces; arrowhead annotations are static overlays controlled by show_gradients/show_weighted.

Examples

if(requireNamespace("plotly",quietly=TRUE)) {
  f <- function(v)sum(v^2)
  g <- function(v)sum(v)-1
  f |> vc_lagrange(g,c(.5,.5),assume_c2=TRUE,hessian_h=.01) |>
    vc_plot_lagrange(f=f,g=g)
}

vectorialcalculus documentation built on Nov. 17, 2026, 1:09 a.m.