CVXR | An R modeling language for convex optimization problems | Math library
kandi X-RAY | CVXR Summary
kandi X-RAY | CVXR Summary
CVXR provides an object-oriented modeling language for convex optimization, similar to CVX, CVXPY, YALMIP, and Convex.jl. It allows the user to formulate convex optimization problems in a natural mathematical syntax rather than the restrictive standard form required by most solvers. The user specifies an objective and set of constraints by combining constants, variables, and parameters using a library of functions with known mathematical properties. CVXR then applies signed disciplined convex programming (DCP) to verify the problem’s convexity. Once verified, the problem is converted into standard conic form using graph implementations and passed to a cone solver such as ECOS or SCS. CVXR includes several open source solvers in addition to the default OSQP, ECOS and SCS. Recent (1.x+) versions also include support for commercial solvers such as MOSEK, GUROBI and CPLEX. For details and examples, we refer you to Fu, Narasimhan, Boyd (2020). If you use CVXR in your work, please cite this reference. (The R command citation("CVXR", bibtex = TRUE) will also give you a bibtex-formatted entry.).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CVXR
CVXR Key Features
CVXR Examples and Code Snippets
Community Discussions
Trending Discussions on CVXR
QUESTION
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 problem and check it using CVXPY
it returns True
(as expected)
What is happening here? I attach a minimal reproducible example of this behavior in R and Python:
R code usingCVXR
...ANSWER
Answered 2021-Jun-07 at 18:48The problem is the negative eigenvalue in the R matrix. If you fix that by setting it to zero, say, then it satisfies the dcp condition. I have also fixed the syntax errors in the code in the question and removed the redundant :: . Another possibility (not shown) is to use nearest_spd
in the pracma package to adjust the R matrix.
QUESTION
I would like to write the log likelihood of the Dirichlet density as a disciplined convex programming (DCP) optimization problem with respect to the parameters of the Dirichlet distribution alpha
. However, the log likelihood
ANSWER
Answered 2020-Dec-11 at 12:18As you note, np.log(gamma(alpha.sum()))
and -np.log(gamma(alpha)).sum()
have different curvature, so you need to combine them as
QUESTION
I use MOSEK to run a very large linear programming problem in Matlab (32768 unknowns and 691621 constraints). The code is submitted in a Linux based cluster. In the bash file I request the following amount of memory:
...ANSWER
Answered 2020-Sep-09 at 13:04Irrelevant in Matlab.
Irrelevant and imposible in Matlab. The MEX interface feeds the problem into Mosek in one go and takes care of all allocations itself.
For MSK_IPAR_NUM_THREADS to be respected you must restart the whole process i.e. Matlab. See https://docs.mosek.com/9.2/faq/faq.html#mosek-is-ignoring-the-limit-on-the-number-of-threads. However, when you set MSK_IPAR_INTPNT_MULTI_THREAD = 'MSK_OFF' then Mosek will use 1 thread regardless of the number of all threads available i.e. the number printed to the log is just an upper bound. You should be able to see in the task manager/top/whatever other CPU load tracker that only 1CPU is in use.
The basic question is: have you tried to run the problem without any memory limits to see if it works at all and estimate the memory consumption? Does it run on other machines?
QUESTION
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:
...ANSWER
Answered 2020-Jul-18 at 10:21Maybe you can try parse
with eval
like below
QUESTION
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
, CVXPY
, or any other API.
For example, identifying an index is needed for change point problems (find the index at which the function changes), putting distance constraints on the traveling salesman problem (visit city X before cumulative distance Y).
As a simple example, suppose we want to identify the location in a vector where the sum on either side is the most equal (their difference is smallest). In this example, the solution is index 5:
...ANSWER
Answered 2020-Jun-17 at 21:07At the end of the day, if you are selecting things by index, I think you need to work this with a set of corresponding binary selection variables. The fact that you are selecting "things in a row" as in your example problem is just something that needs to be handled with constraints on the binary variables.
To solve the problem you posed, I made a set of binary selection variables, call it s[i]
where i = {0, 1, 2, ..., len(x)}
and then constrained:
QUESTION
I'm trying to minimize this function:
\min_{\mu} \sum_{t=T}^T \| y_t - \mu_t \|2 + \lambda \sum{t=1}^{T-1} \|mu_{t+1}-\mu_{t}\|_2
where: y and mu are p*T matraxis. Everything compiles well until I use the solve() function.
Here is what I coded with y being a p*obs matrix
...ANSWER
Answered 2020-Apr-29 at 08:29Problem
is missing in your code:
QUESTION
Hello I am trying to run the example from here: http://rtutorial.altervista.org/lp_solvers.html
A snippet and test where it goes wrong:
...ANSWER
Answered 2020-Apr-06 at 22:38Try replacing the line C<-c(2,4,3)
with C <- matrix(c(2,4,3), nrow = 1)
. That follows the syntax of the later example on that web page, and then that example works for me. The later example now works for me too, (hat tip Jordan) - replace ‘x3 <- Int(1)’ with ‘x3 <-Variable(1, integer=TRUE)’, though the link will probably be updated shortly.
QUESTION
I'm doing empirical likelihood maximization, and hit an error. The statistics is a bit complex and I describe the error like following.
ProblemSuppose I have multivariate function with domain: ,
And I want to minimize the function in the domain.
Here is the counter plot for my function, the optimum seems to be x = y = 0.5 and z = 0.
...ANSWER
Answered 2019-Dec-15 at 19:10Here is the performance comparison among several approaches
QUESTION
I am trying to map two lists over myEq
with a third numeric input which is not the same length as mus
and Sigmas
.
The equation I want to map over:
...ANSWER
Answered 2019-Nov-23 at 14:25I think what you need to do is first convert mus
to numeric and then for every value in lmd
run myEq
in map2
.
QUESTION
I am trying to apply map2
over a series of lists I have to solve a convex optimisation problem.
With the data I try the following function to solve my equation.
...ANSWER
Answered 2019-Nov-21 at 23:45You are passing the parameters incorrectly. Try
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CVXR
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page