All of the examples can be found in Jupyter notebook form here.

# Entropy Maximization

Here is a constrained entropy maximization problem:

$$$\begin{array}{ll} \text{maximize} & -\sum_{i=1}^n x_i \log x_i \\ \text{subject to} & \mathbf{1}' x = 1 \\ & Ax \leq b \end{array}$$$

where $x \in \mathbf{R}^n$ is our optimization variable and $A \in \mathbf{R}^{m \times n}, b \in \mathbf{R}^{m}$.

To solve this, we can simply use the entropy operation Convex.jl provides.

using Convex, SCS

n = 25;
m = 15;
A = randn(m, n);
b = rand(m, 1);

x = Variable(n);
problem = maximize(entropy(x), sum(x) == 1, A * x <= b)
solve!(problem, () -> SCS.Optimizer(verbose=false))
problem.optval
3.2188144025654712
evaluate(x)
25-element Array{Float64,1}:
0.04040570522253729
0.03938729855176759
0.03967543323024522
0.040123554549838805
0.03961159246812087
0.03946486742141815
0.039981461479990835
0.040784876899694365
0.04010956275107137
0.0404146663667184
⋮
0.03974407592228153
0.040659216443562636
0.040092097548798056
0.039917302830636985
0.03973200551901963
0.04041461323700922
0.03989044362212431
0.039936280758497214
0.039184911974667454