-
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
Constraint Problem #18
Comments
You need to use R's semantics for matrix multiplication, i.e. A %% x[,t] + B %% u[,t]. The operator * refers to elementwise multiplication, which requires the operands to have the same dimensions, hence the error. |
Thank you for your quick response. To be sure where the problem lies, I had to comment out the remaining part of the program after the Thanks |
CVXR does not support the combination of pracma library functions with CVXR objects such as your variables, x and u. You should use R's built-in eye, rnorm in place of randn, and CVXR's norm_inf. |
Hi, thank you! The updated R code is:
How could the second-to-last line (concatenating constraints) be represented using CVXR: Thank you very much for your kind assistance. |
You cannot just copy the Python code, you need to understand what it is doing and rewrite it using R's syntax. For instance, you want to sum the problems, which are contained in the list states, so you must use R's Reduce function, i.e. Reduce("+", states). The next line concatenates a new constraint to prob's list of constraints, which is done using c(). I'm closing this thread since none of these are bugs with CVXR. You should work through the examples at http://cvxr.rbind.io/. |
Hi,
I am porting an example of CVXPY using CVXR in R found here: https://groups.google.com/forum/#!topic/cvxpy/5hBSB9KVbuI
The Python Code:
This the R code:
I am getting the following error:
Error in sum_shapes(lapply(object@args, function(arg) { :
Incompatible dimensions
I am suspecting it is from the following statement in the
for
loop because taking that line out shows a different case:constr = list(x[, t+1] == Ax[, t] + Bu[, t], pracma::Norm(u[,t], Inf) <= 1)
Please could you look into this and suggest what could be possibly the cause for this error.
Thank you.
The text was updated successfully, but these errors were encountered: