qpecgen package¶
Submodules¶
qpecgen.avi module¶
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.
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.
-
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\)
-
-
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.
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.
mindiag
(M)[source]¶ Returns the value of the smallest diagonal entry of the matrix M
-
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.
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.
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)).