Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dominique <[email protected]>
  • Loading branch information
geoffroyleconte and dpo authored Mar 16, 2024
1 parent 0153a89 commit 83bf3aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/qp_rand_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ using .QuadraticModels
Return an instance of a `QuadraticModel` representing
½ xᵀHx + cᵀx s.t. l ≤ x ≤ u,
min cᵀx + ½ xᵀHx s.t. l ≤ x ≤ u,
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.
with H = A + A' or H = A * A' (see the `convex` keyword argument) where A is a random square matrix with density `dens`, `l = -e - tₗ` and `u = e + tᵤ` where `e` is the vector of ones, and `tₗ` and `tᵤ` are sampled from a uniform distribution between 0 and 1.
## Arguments
Expand All @@ -17,15 +17,15 @@ with H = A + A' or H = A * A' + I (see the `convex` keyword argument) where A is
## Keyword arguments
* `dens :: Real`: density of `A`` used to generate the quadratic model (default: `1.0e-4`).
* `convex :: Bool`: true to generate a convex `H` (default: `false`).
* `convex :: Bool`: true to generate positive definite `H` (default: `false`).
## Return Value
An instance of a `QuadraticModel`.
"""
function qp_rand_model(n::Int; dens::R = 1.0e-4, convex::Bool = false) where {R <: Real}
A = sprandn(R, n, n, dens)
H = convex ? (A * A') : (A + A') #+ I
H = convex ? (A * A') : (A + A')
c = randn(R, n)
l = -one(R) .- rand(R, n)
u = one(R) .+ rand(R, n)
Expand Down

0 comments on commit 83bf3aa

Please sign in to comment.