0

I have a problem of the form: Constraints


Where X^_JW:

enter image description here


and delta_R_LV:

enter image description here

Where:

-All uppercase deltas and epsilon are constants

-R_WV is a 3,3 rotation matrix with 1000 samples

-R^_LV is a 3,3 constant rotation matrix

-I is a 3,3 rotation matrix

-Delta_R_LV is a 3,3 matrix we wish to solve for

-X_JLI is a 3,1 vector with 1000 samples

-T_LV is a 3,1 vector we wish to solve for

-T_VW is a 3,1 vector with 1000 samples

-X*_JW is a 3,1 vector with 1000 samples

I am having trouble understanding how to fit the 3,3 matrices with 1000 samples into a 2d form that would make sense to optimize upon. My idea was to flatten over the last dimension in order to then have matrices of dimension 1000,9 but I don't understand how these matrices could operate on a 3,1 vector.

I understand how the examples work for a vector of samples of dim (N,1) and how to turn something like this into a matrix via the example:

objective = cp.Minimize(cp.sum_squares(A*x - b))
constraints = [0 <= x, x <= 1]
prob = cp.Problem(objective, constraints)

# The optimal objective value is returned by `prob.solve()`.
result = prob.solve()
# The optimal value for x is stored in `x.value`.
print(x.value)
# The optimal Lagrange multiplier for a constraint is stored in
# `constraint.dual_value`.
print(constraints[0].dual_value)


x = cp.Variable((1275,3))
objective = cp.Minimize(cvx.sum_squares(A*x - b))
constraints = [0 <= x, x <= 1]
prob = cvx.Problem(objective, constraints)

There is also another example which may be closer to my problem in this link:

http://nbviewer.jupyter.org/github/cvxgrp/cvx_short_course/blob/master/intro/control.ipynb

1 Answers1

0

You can try using list of numpy matrices for R and X. A simpler example for constraint Sum(R*X) = Y for 2 samples of X (1x3), R (3x3) and a vector Y (1x3). This would look like:

R = [np.matrix([[1/3, 2/3, 0], [3/4, 1/4, 0 ], [0, 5/6, 1/6]]),
     np.matrix([[0, 2/3, 1/3], [3/4, 1/4, 0 ], [0, 1/6, 5/6]])]
Y = np.matrix([1, 1, 1])

for i in range(Y.shape[1]):
    constraint += [sum([R[j]*X[t].T for t in range(len(X)) for j in range(len(R))])[i] == Y[0, i]]
Mankind_008
  • 2,158
  • 2
  • 9
  • 15
  • Could you elaborate a bit more? I see what you are getting at, but fail to understand where the sum(R*X) comes in in the constraints – Ian Campbell Moore Jul 18 '18 at 00:01
  • I was referring to the `X^_JW` equality constraints. My example doesn't replicates the constraint, its just an idea of how you create a constraint for your model. – Mankind_008 Jul 18 '18 at 00:22
  • Ah, yes I understand now. I will give it a shot. – Ian Campbell Moore Jul 18 '18 at 00:25
  • All the best. I will have to look closer at your formulation for coming up with a right constraint. Will give it a shot later. Edited my answer for better clarity. – Mankind_008 Jul 18 '18 at 00:29