Column vector filled by a variable

49 views
Skip to first unread message

Daneshvar Amrollahi

unread,
Mar 6, 2021, 3:26:16 PM3/6/21
to mosek
I am trying to implement the following constraint in MOSEK Fusion API for C++:

B.x + x[5] >= 0

B is a matrix and x is a variable defined like this: 
x = M->variable("x", 8, Domain::unbounded());
It is guaranteed that the dimensions for matrix multiplication match. 

What I mean by x[5] here is x->index(5)

B.x is a matrix and I can't simply add it with the single value x[5] using the Expression class. I think I need to create a column vector (matrix with 1 column) filled by x->index(5) and then add it with the result of Mul(B, x) but I don't know how to create a matrix filled by a variable. 

Can someone help me write this constraint?

Michal Adamaszek

unread,
Mar 6, 2021, 3:41:18 PM3/6/21
to mosek
The column vector of length N you want can be constructed for example as

Expr::repeat(x->index(5), N, 0)



Alternatively it seems you could write the whole expression as

Expr::Mul(C, x)

where C = B + (matrix of 1s in the 5th column)


This section is a general overview of what can be done in Fusion:


Michal

Reply all
Reply to author
Forward
0 new messages