Description Usage Arguments Details Value References See Also Examples
This function lets you perform Disciplined Convex Programming (http://stanford.edu/~boyd/papers/disc_cvx_prog.html) using the julia package Convex.jl.
1 2 3 | callconvex(opt.vars, pr.def, const.vars, opt.var.names,
pr.solve = "solve!(pr)", code.before = "", code.after = "",
delete.temp = TRUE, norun = FALSE, julia.call = "julia")
|
opt.vars |
string of code to declare optimization variables |
pr.def |
string of code defining a problem called |
const.vars |
list of non-optimization variables used in expression. Labels of list elements should be the names of the variables. |
opt.var.names |
array of names of optimization variables to return. |
pr.solve |
string of code for solving problem |
code.before |
optional string of julia code to run before solving problem |
code.after |
optional string of julia code to run after solving problem |
delete.temp |
Default |
norun |
Default |
julia.call |
How julia can be invoked through the |
This function uses calljulia
.
Returns optval
and status
from Convex.jl in addition to
optimal values of variables named in opt.var.names
.
Udell, Madeleine, et al. "Convex optimization in Julia." Proceedings of the 1st First Workshop for High Performance Technical Computing in Dynamic Languages. IEEE Press, 2014.
Convex.jl julia package. https://github.com/cvxgrp/Convex.jl
Grant, Michael, Stephen Boyd, and Yinyu Ye. Disciplined convex programming. Springer US, 2006.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
set.seed(1)
n <- 200; p <- 100
x <- scale(matrix(rnorm(n * p), n, p))
beta <- rnorm(p)
y <- x %*% beta + 0.1 * rnorm(n)
# change this next line based on where julia is located:
julia <- "/Applications/Julia-0.3.3.app/Contents/Resources/julia/bin/julia"
# solve the lasso:
pr.def <- "pr = minimize(sumsquares(y - x * b) + lam * norm(b, 1))"
lasso <- callconvex(opt.vars = "b = Variable(p)",
pr.def = pr.def,
const.vars = list(x = x, y = y, lam = 10, p = p),
opt.var.names = "b", julia.call = julia)
# solve the lasso in bound form:
pr.def2 <- paste("pr = minimize(sumsquares(y - x * b))",
"pr.constraints += norm(b, 1) <= s", sep = ";")
lasso.bnd <- callconvex(opt.vars = "b = Variable(p)",
pr.def = pr.def2,
const.vars = list(x = x, y = y, s = 70, p = p),
opt.var.names = "b", julia.call = julia)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.