cvxopt

Minimax optimization in PICOS

梦想与她 提交于 2019-12-10 12:06:37
问题 I have a generic question on how to solve optimization problems of the Min-Max type, using the PICOS package in Python. I found little information in this context while searching the PICOS documentation and on the web as well. I can imagine a simple example of the below form. Given a matrix M, find x* = argmin_x [ max_y x^T M y ], where x > 0, y > 0, sum(x) = 1 and sum(y) = 1. I have tried a few methods, starting with the most straightforward idea of having minimax , minmax keywords in the

The integer linear programming(ILP) function in CVXOPT returns non integers

我们两清 提交于 2019-12-08 14:37:39
I wanted to optimize a function using ILP implementing by CVXOPT , GLPK in python. I wrote this code, but it gives me non integer solution especially 0.5. Could anyone help me? import math import numpy as np import cvxopt from cvxopt import glpk from cvxopt import matrix G = np.array([ [-1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -1., 0., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -1., 0., 1., -1., 0., 1., 1., 0., 0., -1., 0., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., -1., 0., 0., 0., 0.,

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

scipy sparse matrix to cvxopt spmatrix?

北战南征 提交于 2019-12-05 06:08:20
I need to convert a scipy sparse matrix to cvxopt's sparse matrix format, spmatrix, and haven't come across anything yet (the matrix is too big to be converted to dense, of course). Any ideas how to do this? Mtap1 The more robust answer is a combination of hpaulj's answer and OferHelman's answer . def scipy_sparse_to_spmatrix(A): coo = A.tocoo() SP = spmatrix(coo.data.tolist(), coo.row.tolist(), coo.col.tolist(), size=A.shape) return SP Defining the shape variable preserves the dimensionality of A on SP. I found that any zero columns ending the scipy sparse matrix would be lost without this

Stochastic Optimization in Python

a 夏天 提交于 2019-12-04 22:17:39
问题 I am trying to combine cvxopt (an optimization solver) and PyMC (a sampler) to solve convex stochastic optimization problems . For reference, installing both packages with pip is straightforward: pip install cvxopt pip install pymc Both packages work independently perfectly well. Here is an example of how to solve an LP problem with cvxopt : # Testing that cvxopt works from cvxopt import matrix, solvers # Example from http://cvxopt.org/userguide/coneprog.html#linear-programming c = matrix([-4

sum of absolute values constraint in semi definite programming

纵然是瞬间 提交于 2019-12-04 13:33:16
问题 I want to further my real world semi definite programming optimization problem with a constraint on sum of absolute values. For example: abs(x1) + abs(x2) + abs(x3) <= 10. I have searched internet and documentation but could not find a way to represent this. I am using python and cvxopt module. 回答1: Your constraint is equivalent to the following eight constraints: x1 + x2 + x3 <= 10 x1 + x2 - x3 <= 10 x1 - x2 + x3 <= 10 x1 - x2 - x3 <= 10 -x1 + x2 + x3 <= 10 -x1 + x2 - x3 <= 10 -x1 - x2 + x3

Stochastic Optimization in Python

混江龙づ霸主 提交于 2019-12-03 14:41:00
I am trying to combine cvxopt (an optimization solver) and PyMC (a sampler) to solve convex stochastic optimization problems . For reference, installing both packages with pip is straightforward: pip install cvxopt pip install pymc Both packages work independently perfectly well. Here is an example of how to solve an LP problem with cvxopt : # Testing that cvxopt works from cvxopt import matrix, solvers # Example from http://cvxopt.org/userguide/coneprog.html#linear-programming c = matrix([-4., -5.]) G = matrix([[2., 1., -1., 0.], [1., 2., 0., -1.]]) h = matrix([3., 3., 0., 0.]) sol = solvers

sum of absolute values constraint in semi definite programming

风流意气都作罢 提交于 2019-12-03 08:26:06
I want to further my real world semi definite programming optimization problem with a constraint on sum of absolute values. For example: abs(x1) + abs(x2) + abs(x3) <= 10. I have searched internet and documentation but could not find a way to represent this. I am using python and cvxopt module. Your constraint is equivalent to the following eight constraints: x1 + x2 + x3 <= 10 x1 + x2 - x3 <= 10 x1 - x2 + x3 <= 10 x1 - x2 - x3 <= 10 -x1 + x2 + x3 <= 10 -x1 + x2 - x3 <= 10 -x1 - x2 + x3 <= 10 -x1 - x2 - x3 <= 10 I haven't used cvxopt , so I don't know if there is an easier way to handle your

CVXOPT QP Solver: TypeError: 'A' must be a 'd' matrix with 1000 columns

ぃ、小莉子 提交于 2019-12-01 17:11:20
I'm trying to use the CVXOPT qp solver to compute the Lagrange Multipliers for a Support Vector Machine def svm(X, Y, c): m = len(X) P = matrix(np.dot(Y, Y.T) * np.dot(X, X.T)) q = matrix(np.ones(m) * -1) g1 = np.asarray(np.diag(np.ones(m) * -1)) g2 = np.asarray(np.diag(np.ones(m))) G = matrix(np.append(g1, g2, axis=0)) h = matrix(np.append(np.zeros(m), (np.ones(m) * c), axis =0)) A = np.reshape((Y.T), (1,m)) b = matrix([0]) print (A).shape A = matrix(A) sol = solvers.qp(P, q, G, h, A, b) print sol Here X is a 1000 X 2 matrix and Y has the same number of labels. The solver throws the following

CVXOPT QP Solver: TypeError: 'A' must be a 'd' matrix with 1000 columns

限于喜欢 提交于 2019-12-01 16:14:27
问题 I'm trying to use the CVXOPT qp solver to compute the Lagrange Multipliers for a Support Vector Machine def svm(X, Y, c): m = len(X) P = matrix(np.dot(Y, Y.T) * np.dot(X, X.T)) q = matrix(np.ones(m) * -1) g1 = np.asarray(np.diag(np.ones(m) * -1)) g2 = np.asarray(np.diag(np.ones(m))) G = matrix(np.append(g1, g2, axis=0)) h = matrix(np.append(np.zeros(m), (np.ones(m) * c), axis =0)) A = np.reshape((Y.T), (1,m)) b = matrix([0]) print (A).shape A = matrix(A) sol = solvers.qp(P, q, G, h, A, b)