-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatible dimensions in building constraints #25
Comments
Please provide a full reproducible example. The above is syntactically wrong, and incomplete. |
Here. for example, is what I get after fixing the syntax.
|
Thanks for your reply. I'm sorry for these mistakes.
The chunk above is reproducible and complete. The point concerned is why can't I just use
The error Thanks for your help! |
This appears to be a bug, most likely a dimension being dropped in the indexing (
|
Thanks for your help! Looking forward to the future version of CVXR. |
Fixed in version 0.97. |
Hi! Thanks for your (and your team) amazing work in CVXR package. I use this package for some control purposes, and an Error appeared when I try to build constraints about state-space equations.
` library(CVXR)
A <- matrix(c(2,-1,1,0.2),byrow = T,nrow = 2)
B <- matrix(c(1,0),byrow = T,nrow = 2)
N <- 7
Q <- diag(2)
R <- 2
N <- 7
x0 <- matrix(c(3,1),byrow = T)
u <- Variable(rows = 1, cols = N)
x <- Variable(rows = 2, cols = N)
objective <- Minimize(sum(Q %% x) + sum(R %% u))
constraints <- list(u >= -1,
u <= 1 ,
x >= -5,
x <= 5,
x[,1] == x0,
#x[,2:N] == A %% x[,1:(N-1)] + B %% u[,1:(N-1)]
x[,2] == A %% x[,1] + B %% u[,1]) `
Error in mul_shapes(size(object@args[[1]]), size(object@args[[2]])) : Incompatible dimensions
.If I use the second last lines (
#x[,2:N] == A %*% x[,1:(N-1)] + B %*% u[,1:(N-1)]
), the console proceed with an Error like above. I have to use the for loop to complete modeling (add constraints one by one). And the dimensions in the second last lines seem compatible.By the way, I have another try on the building constraints for the one-dimension state-space equation in the way like
x[2:N] == A %*% x[1:(N-1)] + B %*% u[1:(N-1)]
, it works. Therefore, I am not sure the problem lies in syntax or the matrix multiplication bug.Thanks for your help!
The text was updated successfully, but these errors were encountered: