Dear all,
I'm using Mosek Fusion for python to solve this linear programming problem

with the shape of each variable as follows:
s - (n,)
q - (m,)
z - scalar variable
τ - scalar
R - (m, n)
r_bar - (n,)
I have setup the model as:
m, n = R.shape
M = Model('model1')
s = M.variable('s', n)
q = M.variable('q', m, Domain.greaterThan(0))
z = M.variable('z', 1, Domain.greaterThan(0))
objective = Expr.sub(Expr.dot(s, r_bar), Expr.mul(z, tau))
M.objective('objective', ObjectiveSense.Maximize, objective)
M.constraint('cond1'
, Expr.hstack(q, Expr.sub(Expr.mul(z, tau), Expr.mul(s.T, return_matrix))),
Domain.greaterThan(0)
)
M.constraint('cond2', Expr.sum(q), Domain.equalsTo(1))
M.constraint('cond3', Expr.sum(s), Domain.equalsTo(z))
M.constraint('min_weight', Expr.mul(z, min_weight) <= s)
M.constraint('max_weight', s <= Expr.mul(z, max_weight))
M.constraint('cond4', Expr.dot(s,
r_bar) >= Expr.mul(z, tau))
M.solve()
I keep having errors with cond1, where it's setting conditions for each row in q. I tried looping through each row using this constraint but it didn't work either.
for i in range(n_days):
M.constraint(
Expr.hstack(q.index(i), Expr.sub(Expr.mul(z, tau), Expr.dot(s, return_matrix[i, :]))),
Domain.greaterThan(0)
)
Can you please help?