aux
index
/home/hennich/.tmp/SONC_polynomial_optimization/python/aux.py

Define constants and basic functions.

 
Modules
       
LP_exact
collections
numpy
sympy

 
Functions
       
binomial(n, k)
Compute binomial coefficient as integer.
bitsize(arg)
Compute the bit size of a number or a collection of numbers.
 
Call:
        size = bitsize(arg)
Input:
        arg: number (int/np.int/float) or collection (np.array/list/...) in arbitrary nesting
Output:
        size: (summed up) bit size of arg
dt2sec(dt)
Convert a datetime.timedelta object into seconds.
 
Call:
        res = dt2sec(dt)
Parameters:
        dt: datetime.timedelta object
Output:
        res: a float, representing the seconds of dt
flatten(l)
Flatten a list of irregular depth to a generator.
flatten2(x)
Flatten a list of irregular depth to a list.
get_type(array)
Determine common data type for given arrray.
 
Possible results: int, np.float, sympy.Rational, object
is_psd(C)
Check whether matrix C is positive semidefinite, by checking the eigenvalues.
linsolve(A, b)
Solve a linear equation system for a possible singular matrix.
parse(number)
Parse a number from string to the correct datatype.
 
Call:
        res = parse(number)
Input:
        number: string, representing a number
Output:
        res: number as int/float/sympy.Rational
to_fraction(number, eps=1.1920928955078125e-07, bound=0)
Round a given number to a fraction with given accuracy.
 
Call:
        frac = to_fraction(number[, eps][, bound])
Input:
        number: float/agebraic number (any arithmetic expression that can be handled by sympy), number to be converted into a fraction
        eps [optional, default: aux.EPSILON]: desired absolute accuracy
        bound [optional, default: 0]: number, in which direction to round
                0 : closest
                -1: rounded down
                1 : rounded up
Output:
        frac: symbolic fraction, such that |frac - number| < eps
unify_status(status)
Give a uniform representation for different status flags.
 
The following are equivalent:
1 = Solved = optimal
0 = Inaccurate = optimal_inaccurate
-1 = no solution

 
Data
        DB_NAME = 'runs.db'
DIGITS = 23
EPSILON = 1.1920928955078125e-07
FAULT_DATA = {'C': array([], shape=(1, 0), dtype=float64), 'opt': inf, 'solver_time': 0, 'status': 'no solution', 'time': 0, 'verify': -1}
SAVE_PATH = '../instances/'
VERBOSE = False
binom = <ufunc 'binom'>
symlog = <numpy.vectorize object>
sympy_flag = True