A derivative work by Judson Wilson, 6/2/2014.
Adapted from the CVX example of the same name, by Joƫlle Skaf, 4/24/2008.
Consider the linear inequality constrained entropy maximization problem: \begin{array}{ll} \mbox{maximize} & -\sum_{i=1}^n x_i \log(xi) \ \mbox{subject to} & \sum{i=1}^n x_i = 1 \ & Fx \succeq g, \end{array} where the variable is $x \in \mathbf{{\mbox{R}}}^{n}$.
This problem can be formulated in CVXPY using the entr
atom.
import cvxpy as cvx
import numpy as np
# Make random input repeatable.
np.random.seed(0)
# Matrix size parameters.
n = 20
m = 10
p = 5
# Generate random problem data.
tmp = np.mat(np.random.rand(n, 1))
A = np.mat(np.random.randn(m, n))
b = A*tmp
F = np.mat(np.random.randn(p, n))
g = F*tmp + np.mat(np.random.rand(p, 1))
# Entropy maximization.
x = cvx.Variable(n)
obj = cvx.Maximize(cvx.sum_entries(cvx.entr(x)))
constraints = [A*x == b,
F*x <= g ]
prob = cvx.Problem(obj, constraints)
prob.solve(solver=cvx.CVXOPT, verbose=True)
# Print result.
print "\nThe optimal value is:", prob.value
print '\nThe optimal solution is:'
print x.value