I want to maximize Ax = b
where A
is an m
-by-n
matrix and x
is an n
-vector. The constraints on x
are that its entries sum to 1
and that A x >= 0
.
Asked
Active
Viewed 6,176 times
-1

Jesica
- 15
- 1
- 8
-
Rodrigo de Azevedo No in fact I want to maximize the summation of this vector elements. Max( sigma (bi)) – Jesica Jun 05 '18 at 13:36
-
@Rodrigo de Azevedo No in fact I want to maximize the summation of this vector elements. Max( sigma (bi)) – – Jesica Jun 05 '18 at 13:36
-
No, sorry the editor has changed my notations. The summation on the x vector is 1. summation(xi) = 1. – Jesica Jun 05 '18 at 14:00
-
No I dont want to maximize x, I want to maximize Ax. – Jesica Jun 05 '18 at 14:31
-
It's still unclear to me what you want to maximize. Maximizing ```Ax``` is ambiguous. – sascha Jun 05 '18 at 15:28
-
No Maximization on the summation of elements. – Jesica Jun 05 '18 at 15:30
1 Answers
3
Using CVXPY instead:
from cvxpy import *
import numpy as np
m = 30
n = 10
# generate random data
np.random.seed(1)
A = np.random.randn(m,n)
b = np.random.randn(m)
# optimization variable
x = Variable(n)
# build optimization problem
prob = Problem( Maximize(sum(A*x)), [ sum(x) == 1, A*x >= 0 ])
# solve optimization problem and prints results
result = prob.solve()
print x.value
This optimization problem is unbounded and, thus, there is no optimal solution.

Rodrigo de Azevedo
- 1,097
- 9
- 17
-
Thank you very much, I had problem in installing cvxpy in python in my operating system. That was why I was using cvxopt. I think I need to solve the issue with installation first and then try this piece of code. – Jesica Jun 05 '18 at 15:29
-
-
Ok, I ran your script but in the line x = Variable(n) it gives me error. AttributeError: 'int' object has no attribute '_root'. – Jesica Jun 05 '18 at 16:14
-
-