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

Provide functions to create polynomials in sparse notation.

 
Modules
       
aux
numpy
random
scipy

 
Functions
       
create_poly(n, degree, terms, A=None, hull_size=None, seed=None, negative=False, inner=0)
Create a multivariate polynomial in sparse notation.
 
Call:
        A, b = create_poly(n, degree, terms[, A])
Input:
        n: non-negative integer
        degree: non-negative integer
        terms: non-negative integer
        A (optional, default None): (`n` x `terms`)-array of integers
Output:
        A: (`n+1` x `terms`)-array of integers, each column representing an exponent of the polynomial
        b: array of length `terms`, each element representing a coefficient of the poylnomial
 
If no matrix is given, then a new one is created, otherwise the one given is used.
It is reordered, such that the first columns form the convex hull.
For these, the coefficients are positive, the other coefficients are negative.
create_simplex_polynomial(n, degree, terms, seed=None, negative=False)
Create a multivariate polynomial in sparse notation, whose convex hull is a simplex.
 
Note: Here we get an arbitrary simplex, while in create_standard_simplex_polynomial() we have the scaled standard simplex.
 
Call:
        A,b = create_simplex_polynomial(n, degree, terms[, seed])
Input:
        n: non-negative integer, number of variables
        degree: non-negative integer, degree of the result
        terms: non-negative integer, number of terms
        seed (optional, default None): seed for the random number generator
Output:
        A: (`n+1` x `terms`)-array of integers, each column representing an exponent of the polynomial
        b: array of length `terms`, each element representing a coefficient of the poylnomial
 
The result is None, if the parameters do not allow a valid SONC-instance, e.g.
        - terms <= n+1 (no simplex)
        - degree <= n (no interior point)
        - degree odd (can always become negative)
create_standard_simplex_polynomial(n, degree, terms, seed=None, negative=False)
Create a multivariate polynomial in sparse notation, whose convex hull is the standard simplex of "edge length = degree".
 
Call:
        A,b = create_standard_simplex_polynomial(n, degree, terms[, seed])
Input:
        n: non-negative integer, number of variables
        degree: non-negative integer, degree of the result
        terms: non-negative integer, number of terms
        seed (optional, default None): seed for the random number generator
Output:
        A: (`n+1` x `terms`)-array of integers, each column representing an exponent of the polynomial
        b: array of length `terms`, each element representing a coefficient of the poylnomial
 
The result is None, if the parameters do not allow a valid SONC-instance, e.g.
        - terms <= n+1 (no simplex)
        - degree <= n (no interior point)
        - degree odd (can always become negative)
make_affine(A, zeros=True)
Add a column of zeroes and a row of ones to input A.
 
Call:
        res = make_affine(A)
Input:
        A: an (`m` x `n`)-matrix of non-negative integers
Output: 
        res: an (`m+1` x `n+1`)-matrix, which is A expanded by a zero-column to the left and a one-row on top
motzkin()
Create Motzkin-Polynomial in sparse notation.
 
Call:
        A, b = motzkin()
Output:
        A: matrix, containing the (affine) exponents
        b: coefficients