cvxpy

How to write several constraint in cvxpy?

这一生的挚爱 提交于 2019-12-11 06:55:54
问题 I want to add many constraint in a optimization problem under cvxpy. In matlab I can do so by adding a line subject to and then use for loop to generate the constraints. How can I do the same work in cvxpy, as there is no 'subject to' concepts in cvxpy. any suggestion please? 回答1: In Python constraints is a list. You can use for loop to append/extend it like this (and CVXPY functions make it easier). import cvxpy as cvx samples = 10 x = cvx.Variable(samples) y = range(1, samples+1)

How to take the square root of quad_form output in CVXPY?

旧街凉风 提交于 2019-12-11 00:55:34
问题 I am trying to solve a problem that involves \sqrt{w^t \Sigma w} in the objective function. To compute w^t \Sigma w , I use the quad_form function. How do I take its square root? When in the code I try to write risk = sqrt(quad_form(w, E)) I am getting a DCP rule error but I am pretty sure it is convex given the other constraints I have. So the question is not really about maths but the actual implementation of the convex program. The problem I am trying to solve is ret = mu.T*w risk = sqrt

Conda Not Installing Latest Version

时间秒杀一切 提交于 2019-12-08 02:28:40
问题 I'm installing cvxpy from cvxgrp. Looking a the link it clearly shows version 1.01 for win-64. However when I go to run the install conda install -c cvxgrp cvxpy it downloads and installs "cvxpy-0.4.10". Updating "all" does not seem to help. I checked conda info and it shows "platform : win-64". conda info Is there a conflict? How can I get the latest version? 回答1: If you look at the list of files for version 1.01, you'll see that the win-64 build is only for Python 2.7. The installation

Passing CPLEX Parameters to CVXPY

寵の児 提交于 2019-11-29 17:01:38
How do i pass tolerances and other parameters through CVXPY when using the CPLEX solver? from cvxpy import Problem, Minimize from cvxpy.settings import CPLEX costs = ... constraints = ... prob = Problem(Minimize(costs), constraints) prob.solve(solver=CPLEX, ...) I see a page of CPLEX Parameters though it is unclear which ones apply to my quadratic problem. Also, the CVXPY documentation has pass through options for other solvers but not CPLEX. This will change in the future (see this pull request), but with cvxpy 1.0.6, you can do the following (NOTE: this is undocumented behavior; see below

Python constrained non-linear optimization

自作多情 提交于 2019-11-27 13:48:38
问题 What's the recommended package for constrained non-linear optimization in python ? The specific problem I'm trying to solve is this: I have an unknown X (Nx1), I have M (Nx1) u vectors and M (NxN) s matrices. max [5th percentile of (ui_T*X), i in 1 to M] st 0<=X<=1 and [95th percentile of (X_T*si*X), i in 1 to M]<= constant When I started out the problem I only had one point estimate for u and s and I was able to solve the problem above with cvxpy . I realized that instead of one estimate for