Skip to content

Instantly share code, notes, and snippets.

denis-bz

Block or report user

Report or block denis-bz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@denis-bz
denis-bz / glpk-examples-summary
Created Apr 25, 2019
A summary of the problems in glpk-4.65/examples/*.mod
View glpk-examples-summary
# A summary of the problems in glpk-4.65/examples/*.mod
# lp/mip min/max rows cols nnz
assign p lp min 17 64 192
bpp p mip min 11 28 56
cal p lp min 0 0 0
cf12a p lp min 20 40 113
cf12b p lp min 58 41 152
cflsq p lp min 40 40 114
color p mip min 92 48 288
cpp p lp min 30 14 59
@denis-bz
denis-bz / 0-scipy-sparse-solve-time.md
Created Feb 26, 2019
timeit scipy.sparse linear solvers: spsolve qmr lgmres splu spilu minres 2019-02-26 Feb
View 0-scipy-sparse-solve-time.md

timeit scipy.sparse linear solvers: spsolve qmr lgmres splu spilu

Here is a simple test of 5 scipy.sparse solvers of Ax = b, with A = diag*I + sparse random-uniform 4000 x 4000, density 1e-3.

Keywords: sparse linear solver, test case, random matrix, scipy, GMRES, Krylov


@denis-bz
denis-bz / Diff35.md
Last active Jan 19, 2019
3-point and 5-point finite-difference derivative approximations
View Diff35.md

3-point and 5-point finite-difference derivative approximations

Central differences like

diff1 = (f_{t+1} - f{t-1}) / 2,  [0 -1 0 1 0] / 2
diff2 = (f_{t+2} - f{t-2}) / 4,  [-1 0 0 0 1] / 4

approximate the derivative f'(t) much better then the one-sided difference f_{t+1} - f_t; see e.g. Wikipedia

@denis-bz
denis-bz / 0-Optimize-ABXC.md
Created Nov 23, 2018
Nonsmooth optimization: the ABXC test problem
View 0-Optimize-ABXC.md

ABXC nonsmooth optimization problems

ABXC is a range of nonsmooth optimization problems from Curtis et al.; see the problem description and links in abxc.py below. They're hard to optimize, very noisy near minima, and some are infeasible. Here's a plot of scipy.optimize.trust-constr creeping up an infeasible slope:

20nov-plot-abxc

@denis-bz
denis-bz / 0-mopta08-py.md
Last active Nov 3, 2018
Optimizing MOPTA08 (128 variables, 68 constraints) with SLSQP from python
View 0-mopta08-py.md
@denis-bz
denis-bz / Coord-sketch.py
Created Sep 30, 2018
Trivial sketch of a function of n variables: vary one at a time
View Coord-sketch.py
#!/usr/bin/env python2
""" coord_sketch: k * dim func() values, varying one coordinate at a time,
give a cheap starting point for further optimization
especially if func() is monotone, up or down, in each coordinate.
"""
from __future__ import division
import sys
import numpy as np
# from https://github.com/SMTorg/smt Surrogate Modeling Toolbox
@denis-bz
denis-bz / Test-pybobyqa.py
Created Sep 28, 2018
Test Py-BOBYQA sensitivity to rhobeg and rhoend 2018-09-28 Sep
View Test-pybobyqa.py
# Py-BOBYQA example: minimize the Rosenbrock function
# from https://github.com/numericalalgorithmsgroup/pybobyqa
# run this.py [dim= lo= hi= ...] in sh or ipython
# sensitive to rhobeg rhoend:
# $nlopt/bobyqa/bobyqa.c --
# Typically, RHOBEG should be about one tenth of the greatest expected change to a variable,
# while RHOEND should indicate the accuracy that is required in the final values of the variables.
from __future__ import print_function
@denis-bz
denis-bz / Bump.md
Last active Sep 5, 2018
bump.py: Keane's hard-to-optimize function, constrained-random 2018-09-05 Sep
View Bump.md

bump2: an optimization problem from A.J.Keane, https://www.southampton.ac.uk/~ajk/bump.html .

Keywords: optimization, test case, random search, python

Problems in mathematical optimization have several different aspects:

  • contest: whose program reaches minimum __ in cpu time __ and time-to-understand __
  • learning how to explore particular function terrains
  • learning how to constrain.
@denis-bz
denis-bz / Gish.md
Created Jul 10, 2018
Gish: sharing files on gist.github by name 10jul
View Gish.md

Gish: sharing files on gist.github by name

Keywords: file sharing, gist, github, CLI, python, remote file server

gish is a command-line program to copy files between local computers and gist.github.com, using file names or gist ids. An example:

Alice:  gish put @Alice AA.md aa.py bb.py  # upload a gist with 3 files
@denis-bz
denis-bz / noisyUSV.py
Created May 15, 2018
noisyUSV: what is the effect of noise on the covariance of n x d rank r ?
View noisyUSV.py
#!/usr/bin/env python2
""" A = noisyUSV( n, d, r, noise ): U S V + noise, n x d, rank r """
from __future__ import division
import numpy as np
from numpy.linalg import norm
from etc import znumpyutil as nu
__version__ = "2018-05-15 May denis-bz-py t-online de" # scale noise * S.max
You can’t perform that action at this time.