Questions tagged [cvxr]

39 questions
0
votes
0 answers

how come I got negative weights despite the no-short sales constraint in the portfolio optimization problem?

I used the CVXR library to find the weights of a minimum variance portfolio consisting of 183 assets. (1) min(w) (1/2)*((w)^T)*sigma*(w) (2) s.t. …
0
votes
1 answer

Positive Semidefinite and Hermitian Matrix Variable in CVXR

How do I restrict a matrix variable to be both Positive Semidefinite and Hermitian in CVXR? When I try to add both attributes, I get an error saying that I can only have one attribute. Here is what I tried: theta <- Variable(rows = 3, cols = 3, PSD…
Clayton
  • 1
  • 1
0
votes
0 answers

Sum of many CVXR problems very slow

I'm using CVXR in R to solve a convex problem. My problem is the sum of a convex expression over many matrices: (my actual expression isn't the sum of squares, but a more complicated convex expression) library(CVXR) set.seed(1) mats = array(rnorm(16…
0
votes
0 answers

In CVXR package in R, I am getting error like "attempt to apply non-function"

I have a convex objective function named "obj_lasso". The minimisation is with respect to a vector v1 of dimension (p=7). The minimisation is going for 500 iterations. That is, at each iteration, it should return a vector v1. For that I am using…
0
votes
1 answer

How to represent a sum of quadratic over linear functions in CVXR?

My objective function is a sum of n quadratic over linear terms. Here is how the problem looks like: I know that the denominators of each of these n terms is positive and m<
0
votes
1 answer

Relaxation of bilinear term in objective function - using CVXR and McCormick envelopes

I have an objective function with some constraints which I want to minimize. I want to use the R package CVXR and the McCormick envelopes. Let's check the code: library(CVXR) # if necessary x <- Variable(1) y <- Variable(1) w <-…
tueftla
  • 369
  • 1
  • 3
  • 16
0
votes
2 answers

Problems with DCP rules in CVXR

I am using the CVXR modelling package to solve a convex optimization problem. I know for sure that the problem is convex and that it follows the DCP rules, but if I check the DCP rules using CVXR it returns False. However, if I take the exact same…
0
votes
0 answers

Solving a system equation with R

This is the Markowitz's efficient portfolio problem, but the "original". I need to maximize the return of a portfolio subject to a level of risk. I have a vector mu of returns: mu [,1] [,2] [,3] [,4] …
0
votes
0 answers

Can I use a for loop to specify constraints in a linear problem using cvxr?

Suppose I have a LP problem, in which: w is a constant column vector of dimension r a is a constant column vector of dimension r p is a constant column vector of dimension T d is a matrix variable of dimensions (r,T) I have to insert the…
0
votes
1 answer

Pass a string for objective function in CVXR

I am trying to write a wrapper function around CVXR, such that the 'objective' and 'constraint' can be passed by a function. I using the following example: Example: x1 <- Variable(1) # a scalar x2 <- Variable(1) # a scalar objective <-…
Anubhav Dikshit
  • 1,729
  • 6
  • 25
  • 48
0
votes
2 answers

Optimize with indexing in linear programming

I have encountered several optimization problems that involve identifying one or more indices in a vector that maximizes or minimizes a cost. Is there a way to identify such indices in linear programming? I'm open to solutions in mathprog, CVXR,…
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54
0
votes
1 answer

Having troubles with CVX's DCP for R

I am facing the following challenge for which I don't seem to find a solution: Basically, I want to program some code for StoNED - Stochastic non-smooth envelopment of data. I started with this: # dim(G) is 35x15 # dim(X) is 5x15 # dim(y) is 5x1 #…
0
votes
1 answer

CVXR Iteration Limit

Using R, I am running a mixed integer optimization which uses the ECOS_BB solver option when using the standard solve or psolve functions for CVXR. How can I set the max iterations? I have looked everywhere. None of the ECOS_BB native options do…
0
votes
1 answer

Base Apply and Elementwise Function CVXR

Is there a way to use base::apply and a CVXR elementwise function to apply an elementwise function to every column of a matrix? Assuming the length of the vector matches the number of rows of the matrix, I'd like to be able to make my objective…
0
votes
1 answer

Writing an objective function in CVXR

I am trying to solve the following problem in CVXR. Here y is an n by m matrix, x is n by G by m and b is m by G. b<- Variable(m,G) b_transpose <- t(b) expr<-sapply(1:m, function(i) x[,,i] %*% b_transpose[,i]) obj<- sum_squares(y-expr) prob<-…
TBC
  • 1