convex-optimization

L1 convex optimization with equality constraints in python

隐身守侯 提交于 2021-02-19 04:48:30
问题 I need to minimize L_1(x) subject to Mx = y. x is a vector with dimension b, y is a vector with dimension a, and M is a matrix with dimensions (a,b). After some reading I determined to use scipy.optimize.minimize: import numpy as np from scipy.optimize import minimize def objective(x): #L_1 norm objective function return np.linalg.norm(x,ord=1) constraints = [] #list of all constraint functions for i in range(a): def con(x,y=y,i=i): return np.matmul(M[i],x)-y[i] constraints.append(con) #make

Convex optimization problem does not follow DCP rules

时光总嘲笑我的痴心妄想 提交于 2021-02-10 19:55:51
问题 I am trying to solve the following optimization problem using cvxpy: x and delta_x are (1,N) row vectors. A is a (N,N) symmetric matrix and b is a scalar. I am trying to find a y, such that it minimizes the sum of squares of (y - delta_x) with the constraint (x+y).A.(x+y).T - b = 0. Below is my attempt to solve it. x = np.reshape(np.ravel(x_data.T), (1, -1)) delta_x = np.reshape(np.ravel(delta.T), (1, -1)) y = cp.Variable(delta_x.shape) objective = cp.Minimize(cp.sum_squares(y - delta_x))

Different behaviour between MATLAB fmincon and scipy optimize minimize

a 夏天 提交于 2021-01-29 22:32:42
问题 I'm translating some code from MATLAB to python. This code simulate the behaviour of a model and I want to estimate parameters from it. The problem is that results obtained with python and with MATLAB are very different. I've tought it was related to the difference between the MATLAB's fmincon and the python scipy.optimize.minimize function, but according to this tutorial that I've found on youtube (https://www.youtube.com/watch?v=SwogAa1719M) the results are almost the same,so problems must

Different behaviour between MATLAB fmincon and scipy optimize minimize

我与影子孤独终老i 提交于 2021-01-29 12:30:54
问题 I'm translating some code from MATLAB to python. This code simulate the behaviour of a model and I want to estimate parameters from it. The problem is that results obtained with python and with MATLAB are very different. I've tought it was related to the difference between the MATLAB's fmincon and the python scipy.optimize.minimize function, but according to this tutorial that I've found on youtube (https://www.youtube.com/watch?v=SwogAa1719M) the results are almost the same,so problems must

what is the solution of the following optimization problem with linear and non linear constraints?

眉间皱痕 提交于 2020-05-17 02:57:32
问题 min x subject to: zeta_1>=b zeta_2>=h t*log(1+m_b*zeta_1)>=t_bh (1-t)*log(1+t*m_h*zeta_2)>=t_hb 0<=t<=1 ||y||=1, where zeta_1=(|transpose(a)*y|^2)*x, zeta_2= (|transpose(c)*y|^2)*x. m_b and m_h are parameters. a,c and y are taken from complex numbers and are having dimension N*1. b,h,t_bh and t_hb are constants. I have used the following simulation. tic clc clear all close all %% initialization N=5; alpha=0.5; eta=0.6; sigma_B=10^-8; sigma_H=10^-8; b=0.00001; h=0.00001; h_AB=[]; h_AH=[]; h_BH

Log_sum_exp of a convex function is not dcp compliant?

戏子无情 提交于 2020-01-06 04:42:12
问题 I have a convex function f(b): f(b) = log(pi) - lambda * log( t(r) %*% b) dim(pi) = (n,1), lambda is a scalar constant, dim(r) = (n,n) b is the parameter, dim(b) = (n,1) The call to is_convex(f) is_dcp(f) both return TRUE. However, I don’t understand why the following returns FALSE: is_dcp(log_sum_exp(f)) As far as I understand, log_sum_exp of a convex function is convex? I noticed that both is_convex(f) and is_concave(f) return FALSE. So it seems like CVRX is unable to deduce the convexity

Constraints do not follow DCP rules in CVXPY

痞子三分冷 提交于 2019-12-24 09:41:38
问题 I want to solve this problem using CVXPY but I don't know why I get the following error message: DCPError: Problem does not follow DCP rules. I guess my constraints are not DCP. Is there any way to model this in DCP? n_k = [10000, 20000] request_rate = [15, 10] p_k_1 = np.random.rand(n_k[0]) p_k_2 = np.random.rand(n_k[1]) #params p_k_param_1 = cvx.Parameter(1, n_k[0], sign="positive") p_k_param_1 = np.array(p_k_1) p_k_param_2 = cvx.Parameter(1, n_k[1], sign="positive") p_k_param_2 = np.array

Polygon Decomposition - Removing Concave Points to Form Convex Polygons

我的未来我决定 提交于 2019-12-23 16:43:30
问题 I would like to deconstruct the following polygon shown in blue removing all of the points from the polygon that cause concavity. Currently, what I have been attempting to do is: Take each point out of the polygon Test the point to see if it falls within the polygon created by the rest of the set If true remove the point If false keep the point This works in most cases, but in the previous case the points at (2,3) and (2,4) will not both be removed. In both cases either one of the points will

Julia error using convex package with diagind function

那年仲夏 提交于 2019-12-13 03:09:40
问题 I'm trying to solve the problem d = 0.5 * ||X - \Sigma||_{Frobenius Norm} + 0.01 * ||XX||_{1}, where X is a symmetric positive definite matrix, and all the diagnoal element should be 1. XX is same with X except the diagonal matrix is 0. \Sigma is known, I want minimum d with X. My code is as following: using Convex m = 5; A = randn(m, m); x = Semidefinite(5); xx=x; xx[diagind(xx)].=0; obj=vecnorm(A-x,2)+sumabs(xx)*0.01; pro= minimize(obj, [x >= 0]); pro.constraints+=[x[diagind(x)].=1]; solve!