QPALM main
Proximal Augmented Lagrangian method for Quadratic Programs
Loading...
Searching...
No Matches
examples/julia/qpalm_julia_demo.jl
1using QPALM
2using LinearAlgebra
3using SparseArrays
4using Random
5
6# Generate a random QP
7Random.seed!(0)
8n, m = 10, 20
9act = 5
10F = randn(n, n-1)
11Q = sparse(F*F' + 1e-3*I)
12A = sparse(randn(m, n))
13x_star = randn(n)
14y_star = [rand(act); zeros(m-act)]
15q = -Q*x_star - A'*y_star
16b = [A[1:act, :]*x_star; A[act+1:end, :]*x_star + rand(m-act)]
17
18# Set up the QPALM problem
19model = QPALM.Model()
20params = Dict{Symbol,Any}(:max_iter=>100)
21QPALM.setup!(model, Q=Q, q=q, A=A, bmax=b; params...)
22
23# Solve the problem
24results = QPALM.solve!(model)
25
26# Print the results
27println(results.info.status)
28println(results.x)
29println(results.y)