Skip to content

Instantly share code, notes, and snippets.

View lkapelevich's full-sized avatar

Lea Kapelevich lkapelevich

View GitHub Profile
@lkapelevich
lkapelevich / hashcrash.cpp
Last active August 14, 2023 12:13
crash for highs hash on win64
#include "util/HighsHash.h"
#include "util/HighsHashTree.h"
int main() {
std::vector<int> cliqueids = {
731180 ,
730863 ,
51467 ,
728644 ,
179865 ,
109009 ,
using Revise, Random
import JuMP, Hypatia, LinearAlgebra
ones3by3 = [1, sqrt(2), sqrt(2), 1, sqrt(2), sqrt(2), sqrt(2), sqrt(2), 1];
m = JuMP.Model(()->Hypatia.Optimizer(rescale=false));
JuMP.@constraint(m, ones(9) in JuMP.MOI.HermitianPositiveSemidefiniteConeTriangle(3))
JuMP.optimize!(m);
@assert JuMP.backend(m).optimizer.model.optimizer.solver.model.h ≈ ones3by3
@lkapelevich
lkapelevich / cbfstats.jl
Created April 27, 2022 13:46
cone stats from cblib instances
using MathOptInterface
MOI = MathOptInterface
MOIF = MOI.FileFormats
using DelimitedFiles
cblib_dir = "C:\\Users\\lkape\\cblib\\cblib.zib.de\\download\\all"
open("cblib.csv", "w") do io
for s in readdir(cblib_dir)
dest = MOIF.Model(format = MOIF.FORMAT_CBF)
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:
@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"))
@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 / 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 = [
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 / 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]
# 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);