qpecgen package

Submodules

qpecgen.avi module

class qpecgen.avi.Qpecgen100(pname, param)[source]

Bases: qpecgen.base.QpecgenProblem

export_QPCC_data()[source]
make_b_lambda()[source]
make_pi_sigma_index()[source]
return_problem()[source]

qpecgen.base module

Houyuan Jiang, Daniel Ralph, copyright 1997 Matlab code accompanied the paper:

Jiang, H., Ralph D. QPECgen, a MATLAB generator for mathematical programs with Computational Optimization and Applications 13 (1999), 25-59.

Python implementation coded by Patricia Gillett, 2013-2015 See readme.txt for details about the structures of generated problems.

class qpecgen.base.QpecgenProblem(pname, param, qpec_type=-1)[source]

Bases: object

get_Px()[source]
get_Pxy()[source]
get_Py()[source]
make_obj_P()[source]
return_problem()[source]

qpecgen.box module

class qpecgen.box.Qpecgen200(pname, param, qpec_type=200)[source]

Bases: qpecgen.base.QpecgenProblem

Qpecgen200 generates and manages the data for a qpecgen problem of type 200 (BOX-QPEC). In addition to the methods used in problem construction, the make_QPCCProblem() method can be used to export the problem as a QpecgenQPCC, which is a BasicQPCC object in which some qpecgen specific data is also preserved.

export_QPCC_data()[source]
get_dual_vals(x, y)[source]

Computes the values of the lower level problem’s dual variables vectors at the given solution (x, y).

Args:
x, y: an optimal solution to the QPEC.
Returns:

\(\lambda_D^L\): vector of dual variable values for the constraints \(y_D \geq 0\)

\(\lambda_S\): vector of dual variable values for the constraints \(y_S \geq 0\)

\(\lambda_D^U\): vector of dual variable values for the constraints \(y_D \leq y_u\)

make_QPCC_sol()[source]
return_problem()[source]
Args:
(None)
Returns:
problem: a dictionary with keys P, c, d, A, a, u, N, M, q defining the
class qpecgen.box.Qpecgen201(pname, param)[source]

Bases: qpecgen.box.Qpecgen200

This subclass of qpecgen.box.Qpecgen200 generates a more specific type of BOX-QPEC problem known as the FULL-BOX-QPEC. Type 201 is a more specific case of type 200 where x variables are constrained \(x_l \leq x \leq x_u\) and y variables are constrained \(0 \leq y \leq y_u \leq 10\) for integers \(x_l \in [-10, 0]\), \(x_u \in [1, 10]\), \(y_u \in [1, 10]\).

Some class methods (not shown here due to private status) are overridden for this class so that problems are generated with the full box structure. Methods for

qpecgen.helpers module

qpecgen.helpers.adjust_cond(PU, PD, PV, cond)[source]

Constructs the matrix PU*PD*PV after adjusting its condition number to be cond.

This will throw an error if PD is a multiple of the identity matrix because the condition number in that case is always 1 and this adjustment doesn’t change that.

PD also must be a diagonal matrix. If not, raise ValueError.

qpecgen.helpers.choose_num(m)[source]

Chooses a number between 0 and m, inclusive.

qpecgen.helpers.conmat(L, option='v')[source]

Concatenates the matrices L[1]... L[n] into one matrix, arranging them horizontally if option=’h’ and vertically if option=’v’.

qpecgen.helpers.create_name(prefix, size, start=0)[source]

Create a list of names.

If the prefix is “a” and size is 2, the created name list will be [“a0”, “a1”].

Args:
prefix: Prefix of name. size: Size of names. start: If given, the fiest id will be set to it. (Default: 0)
Returns:
List of names.
qpecgen.helpers.eye(n)[source]

Convenience function for an n by n identity matrix.

qpecgen.helpers.gen_general_obj(n, convex, cond, scale)[source]
qpecgen.helpers.maxdiag(M)[source]

Returns the value of the largest diagonal entry of the matrix M

qpecgen.helpers.mindiag(M)[source]

Returns the value of the smallest diagonal entry of the matrix M

qpecgen.helpers.npvec(x)[source]

Convenience function to make sure x is a vertical vector.

qpecgen.helpers.ones(m, n=1)[source]

Convenience function to create an m by n matrix of all ones.

qpecgen.helpers.rand(m, n=1)[source]

Convenience function to create an m by n numpy matrix with each element distributed Uniform(0,1).

qpecgen.helpers.randcst()[source]

Convenience function to get a single Uniform(0,1) value.

qpecgen.helpers.randdiag(n)[source]

Creates an n by n matrix with Uniform(0,1) random numbers on the diag

qpecgen.helpers.randint(low, high, m, n=1)[source]

Convenience function to create an m by n numpy matrix with each element distributed Discrete Uniform in [low, high]

qpecgen.helpers.reconstruct(MU, MD, MV)[source]

Returns the matrix product MU*MD*MV.

qpecgen.helpers.sanitize_params(param, qpec_type=-1)[source]
qpecgen.helpers.schur(P)[source]

g variables in the same order as matlab’s schur decomp to make it easy to verify my translation from matlab to python. Simulates matlab’s schur decomposition function, returning PU, PD, PV s.t. np.dot(PU, np.dot(PD, PV))

qpecgen.helpers.svd(P)[source]

Wrapper for singular value decomposition, returning PU, PD, PV s.t. P = np.dot(PU, np.dot(PD, PV)).

qpecgen.helpers.tweak_diag(MD)[source]

Takes a square matrix MD, shifts every diagonal element so that the smallest diagonal value is 0, and then adds a Uniform(0,1) value to each diagonal element.

qpecgen.helpers.zeros(m, n=1)[source]

Convenience function to create an m by n matrix of all zeroes.

qpecgen.special module

class qpecgen.special.Qpecgen800(param)[source]

Bases: qpecgen.special.QpecgenSpecialLCP

class qpecgen.special.Qpecgen900(param)[source]

Bases: qpecgen.special.QpecgenSpecialLCP

class qpecgen.special.QpecgenSpecialLCP(param, qpec_type=-1)[source]

Bases: qpecgen.base.QpecgenProblem

return_problem()[source]