Skip to content

Commit 042d65b

Browse files
committed
03-dcp: pre-render the visualize() example until CVXR 1.9.3 lands
CVXR 1.9.2 errors on this exact call ("values must be length 1"): the sqrt -> SOC change gave power atoms exact rational exponents, which the visualizer's formatter mishandles (length-16 vector from gmp's format). Fixed upstream for 1.9.3. Until that is on CRAN, the chunk is eval:false with a callout explaining why, and the output is the genuine result from the fixed build (captured locally 2026-08-24). This also unbreaks the CI macOS leg, which already receives the CRAN 1.9.2 binary and died on this chunk (run 32768940810); the ubuntu publish leg would have followed once P3M serves 1.9.2. Restoration recipe in the HTML comment.
1 parent 075377d commit 042d65b

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

03-dcp.qmd

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,58 @@ psolve(Problem(Minimize(sqrt(x))))
158158
For anything bigger than a toy, `visualize()` draws the expression tree with each
159159
node's curvature, flagging the offending node so you know *where* to reformulate:
160160

161+
<!-- STATIC until CVXR >= 1.9.3 is on CRAN: 1.9.2 has a display bug that makes
162+
this exact call error (rational power exponents crash the visualizer's
163+
formatter; fixed for 1.9.3). Output below pre-rendered 2026-08-24 with the
164+
fixed build. To restore live rendering: delete eval: false, this comment,
165+
the callout, and the static block. -->
166+
161167
```{r}
162168
#| label: visualize
169+
#| eval: false
163170
visualize(Problem(Minimize(sqrt(1 + square(x)))))
164171
```
165172

173+
::: callout-note
174+
## Pre-rendered output
175+
On CVXR 1.9.2 this call errors (`values must be length 1 ...`) — a display bug
176+
introduced with 1.9.2's exact rational power exponents, fixed in CVXR 1.9.3.
177+
The output below is pre-rendered with the fixed version; run the chunk yourself
178+
once 1.9.3 is on CRAN.
179+
:::
180+
181+
```
182+
── Expression Tree (MINIMIZE) ──────────────────────────────────────────
183+
t_3 = PowerApprox(...) [unknown, \mathbb{R}_+, 1x1]
184+
\-- t_2 = AddExpression(...) [convex, \mathbb{R}_+, 1x1]
185+
|-- 1 [constant, 1x1]
186+
\-- t_1 = PowerApprox(...) [convex, \mathbb{R}_+, 1x1]
187+
\-- var1 [affine, 1x1]
188+
── DCP ANALYSIS ────────────────────────────────────────────────────────
189+
✗ Problem is NOT DCP compliant.
190+
Objective (Minimize): requires convex expression
191+
✗ PowerApprox: unknown [1x1]
192+
arg 1: convex, increasing (cvx-rule ✓, ccv-rule ✗)
193+
=> PowerApprox is concave, but DCP concave composition fails at arg 1.
194+
Hint: var1 must be nonneg (>= 0)
195+
── SMITH FORM ──────────────────────────────────────────────────────────
196+
t_{1} = phi^{(.)^2}({var1})
197+
t_{2} = {1} + {t_{1}}
198+
t_{3} = phi^{(.)^{1/2}}({t_{2}})
199+
── RELAXED SMITH FORM ───────────────────────────────────────────────────
200+
t_{1} >= phi^{(.)^2}({var1})
201+
t_{2} = {1} + {t_{1}}
202+
t_{3} = phi^{(.)^{1/2}}({t_{2}})
203+
── CONIC FORM ───────────────────────────────────────────────────────────
204+
(\frac{1+t_{1}}{2}, \frac{1-t_{1}}{2}, {var1}) in Q^3
205+
t_{2} = {1} + {t_{1}}
206+
t_{3} = phi^{(.)^{1/2}}({t_{2}}) [conic form: see canonicalizer]
207+
```
208+
209+
The tree reads bottom-up: `square(x)` is convex (`t_1`), adding 1 keeps it convex
210+
(`t_2`), but the outermost `sqrt` — concave and increasing — cannot take a convex
211+
argument, and the analysis flags exactly that node with a hint.
212+
166213
See the [Visualization page](https://cvxr.rbind.io/reference/visualization.html)
167214
for the full feature set (curvature coloring, fix hints, HTML trees).
168215

0 commit comments

Comments
 (0)