You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/qp_rand_model.jl
+15-11Lines changed: 15 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,34 @@ export qp_rand_model
2
2
using.QuadraticModels
3
3
4
4
"""
5
-
model, x0 = qp_rand_model(n, dens = 1.0e-3)
5
+
model, x0 = qp_rand_model(n; dens = 1.0e-3, convex = false)
6
6
7
7
Return an instance of a `QuadraticModel` representing
8
8
9
-
½ xᵀQx + cᵀx s.t. x ≥ 1,
9
+
½ xᵀHx + cᵀx s.t. l ≤ x ≤ u,
10
10
11
-
where Q = A + A' + I where A is a random square matrix with density `dens`.
11
+
with H = A + A' or H = A * A' + I (see the `convex` keyword argument) where A is a random square matrix with density `dens`, `l = -e -tₗ` and `u = e + tᵤ` where `tₗ` and `tᵤ` are sampled from a uniform distribution between 0 and 1.
12
12
13
13
## Arguments
14
14
15
15
* `n :: Int`: size of the problem,
16
-
* `dens :: Real`: density of A used to generate the quadratic model.
16
+
17
+
## Keyword arguments
18
+
19
+
* `dens :: Real`: density of `A`` used to generate the quadratic model (default: `1.0e-3`).
20
+
* `convex :: Bool`: true to generate a convex `H` (default: `false`).
17
21
18
22
## Return Value
19
23
20
-
An instance of a `QuadraticModel`
24
+
An instance of a `QuadraticModel`.
21
25
"""
22
-
functionqp_rand_model(n::Int, dens::R=1.0e-3) where {R <:Real}
23
-
A =sprand(R, n, n, dens)
24
-
H =A + A'+ I
26
+
functionqp_rand_model(n::Int; dens::R=1.0e-4, convex::Bool=false) where {R <:Real}
0 commit comments