Add external custom function in CVXPY as a dynamic constraint

213 views
Skip to first unread message

LoukasK

unread,
Dec 8, 2017, 8:54:26 AM12/8/17
to cvxpy
Dear all,

Is it possible to add as a dynamic constraint an external custom function in CVXPY working with boolean variables? In particular, i have a numpy matrix C (size m x n):

X = Bool(m , n)
objective = Minimize(sum_entries(mul_elemwise(C,X))) 
constraints = []
constraints.append(sum_entries(X) == 3)

Instead of 'X' in constraint parenthesis i want to add 'mycustomfunction(X)' in order to work as a dynamic constraint added to the objective but obviously, i am getting the error
"ValueError: not enough values to unpack (expected 2, got 0)" as X is 'None' yet if i am saying it correctly.

Thank you in advance for your help.

Steven Diamond

unread,
Dec 15, 2017, 3:39:14 PM12/15/17
to cvxpy
Your cvxpy problem in the end must only involve cvxpy objects (and constants). No function handles. I don't entirely understand what you want but mycustomfunction(X) needs to return a cvxpy object.
Reply all
Reply to author
Forward
0 new messages