Skip to content

Instantly share code, notes, and snippets.

View lkapelevich's full-sized avatar

Lea Kapelevich lkapelevich

View GitHub Profile
bd = BenchmarkData(Xdata = Xdata(MvNormal, NoCorrelation),
wdist = BinChoice(),
noisedist = Normal(),
SNR = 20.0,
nfeatures = 1000,
sparsity = 10,
nrange = collect(100:20:500)
)
m = RelaxDualSubgradient(gamma = 1.0, ConstantStepping(1e-3))
results = benchmark(bd, m)
using JLD
using SparseArrays
a = sprand(100, 100, 0.1)
JLD.save("a.jld", "a", a)
write(
"test.jl",
"""
using JLD
using SparseArrays
write(
"test2.jl",
"""
using LinearAlgebra, Random
a = rand(10, 10)
b = Symmetric(a * a')
f = cholesky(b)
"""
)
# JLD in https://drive.google.com/file/d/1ixztoXBV7qKPW6BQ8VNRPzzbj01Txw2B/view?usp=sharing
using JLD, ECOS, MathOptFormat, MathOptInterface
const MOI = MathOptInterface
const MOIB = MathOptInterface.Bridges
const MOIU = MathOptInterface.Utilities
model = MathOptFormat.read_from_file(joinpath(cblib_dir, "LogExpCR-n20-m400.cbf.gz"))
cache = MOIU.UniversalFallback(MOIU.Model{Float64}());
MOI.copy_to(cache, model);
@lkapelevich
lkapelevich / seg.jl
Last active September 20, 2020 03:47
segfault backtrace from calls to printf
# script:
import Pkg
Pkg.add(url="https://github.com/lkapelevich/SegExample.jl")
using SegExample
SegExample.foo()
# backtrace:
(gdb) r
Starting program: /home/ptah/julia/usr/bin/julia-debug /home/ptah/.julia/dev/seg.jl
[Thread debugging using libthread_db enabled]
Pkg.add(url = "https://github.com/chriscoey/Hypatia.jl")
import Hypatia.Cones
cone = Cones.MatrixEpiPerSquare{Float64, Float64}(1, 1)
Cones.setup_data(cone)
pt = Cones.set_initial_point(zeros(3), cone)
Cones.load_point(cone, pt)
Cones.is_feas(cone)
Cones.grad(cone)
Cones.correction(cone, ones(3))
@lkapelevich
lkapelevich / mlog_derivatives.jl
Last active January 12, 2021 22:58
MWE for inaccurate gradient of matrix logarithm
using LinearAlgebra
import GenericLinearAlgebra
import ForwardDiff
import Random
Random.seed!(1)
d = 5
rand_W = randn(d, d)
rand_W = rand_W * rand_W'
bad_W = [
@lkapelevich
lkapelevich / ncperspective.jl
Last active April 3, 2022 23:42
derivatives for non commutative perspective
# cf https://math.stackexchange.com/questions/540361/derivative-or-differential-of-symmetric-square-root-of-a-matrix
using ForwardDiff
using LinearAlgebra
using GenericLinearAlgebra
d = 3
V = randn(d, d)
V = Hermitian(V * V' + I)
W = randn(d, d)
@lkapelevich
lkapelevich / analyze_polynorm.jl
Created October 22, 2021 12:55
updated analyze.jl script for the polynorm problem
#=
analyze natvsext benchmark results
see natvsext/README.md
=#
using Printf
using CSV
using DataFrames
include(joinpath(@__DIR__, "../../examples/Examples.jl"))
using JuMP
import Hypatia
import Hypatia.PolyUtils
using LinearAlgebra
n = 2
halfd = 2
k = 3 # number of functions defining nonnegativity domain
# try good interpolation points from [-1, 1]^n: