set_label: Set a Label on a Constraint

View source: R/121_constraints_constraint.R

set_labelR Documentation

Set a Label on a Constraint

Description

Attaches a human-readable label to a constraint for use in visualizations and pretty-printing. Labels are visualization-only and never affect the solver pipeline.

Usage

set_label(constraint, label)

Arguments

constraint

A Constraint object.

label

A character string label.

Details

Because R uses copy-on-modify semantics, you must either assign the result back or use set_label fluently when building constraint lists.

Value

The modified constraint (invisibly).

Examples

## Not run: 
x <- Variable(3, name = "x")

# Assign back
con <- (x >= 0)
con <- set_label(con, "non-negativity")

# Fluent use in constraint lists
constraints <- list(
  set_label(x >= 1, "lower bound"),
  set_label(sum_entries(x) <= 10, "budget")
)

## End(Not run)


CVXR documentation built on March 6, 2026, 9:10 a.m.