-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathREADME.Rmd
More file actions
98 lines (76 loc) · 3.13 KB
/
README.Rmd
File metadata and controls
98 lines (76 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# CVXR <img src="man/figures/logo.png" width="120" align="right" />
<!-- badges: start -->
[](https://github.com/cvxgrp/CVXR/actions/workflows/R-CMD-check.yaml)
[](https://cran.r-project.org/package=CVXR)
[](https://CRAN.R-project.org/package=CVXR)
<!-- badges: end -->
CVXR provides an object-oriented modeling language for convex
optimization, similar to [CVXPY](https://www.cvxpy.org/),
[CVX](http://cvxr.com/cvx/), [YALMIP](https://yalmip.github.io/), and
[Convex.jl](https://jump.dev/Convex.jl/stable/). It allows you to
formulate convex optimization problems in natural mathematical syntax
rather than the restrictive standard form required by most solvers. You
specify an objective and a set of constraints by combining constants,
variables, and parameters using a library of functions with known
mathematical properties. CVXR then applies signed [disciplined convex
programming
(DCP)](https://web.stanford.edu/~boyd/papers/pdf/disc_cvx_prog.pdf) to
verify the problem's convexity. Once verified, the problem is converted
into standard conic form and passed to an appropriate backend solver.
This version is a ground-up rewrite built on the
[S7](https://rconsortium.github.io/S7/) object system, designed to
mirror CVXPY 1.8 closely. It is **~4--5x faster** than the previous
S4-based release, ships with 13 solvers (4 built-in), and supports DCP,
DGP, DQCP, complex variables, mixed-integer programming, and warm-starting.
For tutorials, worked examples, and the full story, visit the [CVXR
website](https://cvxr.rbind.io).
## Installation
Install the released version from CRAN:
```{r, eval = FALSE}
install.packages("CVXR")
```
Or install the development version from GitHub:
```{r, eval = FALSE}
# install.packages("pak")
pak::pak("cvxgrp/CVXR")
```
## Quick example
```{r example, eval = FALSE}
library(CVXR)
# Data
set.seed(42)
n <- 50; p <- 10
X <- matrix(rnorm(n * p), n, p)
beta_true <- c(rep(1, 5), rep(0, 5))
y <- X %*% beta_true + rnorm(n, sd = 0.5)
# Problem
beta <- Variable(p)
objective <- Minimize(sum_squares(y - X %*% beta) + 0.1 * p_norm(beta, 1))
prob <- Problem(objective)
# Solve (Clarabel is the default solver)
result <- psolve(prob)
result # optimal value
estimated <- value(beta) # coefficient estimates
```
## Documentation
- **Tutorials and examples**: <https://cvxr.rbind.io>
- **Package reference**: <https://www.cvxgrp.org/CVXR/>
- **Paper**: Fu, Narasimhan, and Boyd (2020). "CVXR: An R Package for
Disciplined Convex Optimization." *Journal of Statistical Software*,
94(14), 1--34. [doi:10.18637/jss.v094.i14](https://doi.org/10.18637/jss.v094.i14)
If you use CVXR in your work, please cite the paper above
(`citation("CVXR")`).
## License
Apache License 2.0