cvxr / CVX

A MATLAB system for disciplined convex programming
Other
226 stars 83 forks source link

DCP Compliant formation #14

Closed talipini closed 5 months ago

talipini commented 2 years ago

Newbie here. Appreciate any insights. I am trying to create a DCP complaint structure. I am trying to create a constraint and minimization that looks at the combination of the valid items selected and the corresponding weights. I understand using the product is not compliant and I was wondering if there is a better way to express this. Appreciate any insights

Specifically, constraint such as


    # cp.sum(cp.multiply(valid_items,wts)) == 1.0 <----- Non DCP compliant product

And minimization object such as


        obj = cp.Minimize(cp.quad_form(wts @ valid_items - base_wts, cov)) <----- Non DCP compliant product

Psuedo Code:

    valid_items = cp.Variable(shape=200, boolean=True)
    wts = cp.Variable(shape=200), nonneg=True)

    # Create two constraints.
    constraints = [
                    cp.sum(valid_items) >=98,
                    cp.sum(valid_items) <=100,
                    # cp.sum(cp.multiply(valid_items,wts)) == 1.0 <----- Non DCP compliant product
                    wts <= 0.2,
                    wts >= 0.0005,
                ]

    obj = cp.Minimize(cp.quad_form(wts @ valid_items - base_wts, cov)) <----- Non DCP compliant product

    ....
mcg1969 commented 5 months ago

Sorry that nobody ever responded to this; we don't look at this repo much. For the benefit of others who come here, please visit https://ask.cvxr.com/ for questions about DCP.