Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Quadratic Programming Input using python

    Posted Wed February 02, 2022 10:37 PM
    Hi All,
    I am trying to put a quadratic optimization problem with linear constraints in the standard mathematical form using python.

    I was earlier using the CVXOPT but facing some memory issue.

    the standard call CVXOPT using 

    sol = solvers.qp(P,q,G,h,A,b)

    where all inputs are in matrix form.

    Can anyone here please share a python CPLEX code where I can use the matrix form. I don't want to use docplex expressions because parsing taking too much time. I have large number of variables and want to run the optimization process fast.

    kindly share your thoughts.

    If you need more information, kindly post here

    ------------------------------
    Shamik Chaudhuri
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Quadratic Programming Input using python

    Posted Thu February 03, 2022 02:54 AM
    You should have a look at AdvModel.quad_matrix_sum ? This class contains methods which are faster or more complex than the usual Model methods.

    def quad_matrix_sum(self, matrix, dvars, symmetric=False):
    """
    Creates a quadratic expression equal to the quadratic form of a list of decision variables and
    a matrix of coefficients.

    This method sums all quadratic terms built by multiplying the [i,j]th coefficient in the matrix
    by the product of the i_th and j_th variables in `dvars`; in mathematical terms, the expression formed
    by x'Qx.

    :param matrix: A accepts either a list of lists of numbers, a numpy array, a pandas dataframe, or
    a scipy sparse matrix in COO format. T
    The resulting matrix must be square with size (N,N) where N is the number of variables.
    :param dvars: A list or an iterator on variables.
    :param symmetric: A boolean indicating whether the matrix is symmetric or not (default is False).
    No check is done.

    :return: An instance of :class:`docplex.mp.quad.QuadExpr` or 0.

    Note:
    The matrix must be square but not necessarily symmetric. The number of rows of the matrix must be equal
    to the size of the variable sequence.

    The symmetric flag only explores half of the matrix and doubles non-diagonal factors. No actual check is done.
    This flag has no effect on scipy sparse matrix.

    Example:
    `Model.quad_matrix_sum([[[1, 2], [3, 4]], [x, y])` returns the expression `x^2+4y^2+5x*yt`.
    """


    ------------------------------
    Vincent Beraudier
    ------------------------------