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; silent_solver = true)
problem.optval
3.148033231556878
evaluate(x)
25-element Vector{Float64}:
 0.020901121099967997
 0.02666222117596998
 0.03088782039619239
 0.05861220537603577
 0.054492153095905466
 0.026452470373400913
 0.03366533200110643
 0.06379295051142282
 0.0732298486161135
 0.023134122623949573
 ⋮
 0.02771720054711823
 0.04956861628241955
 0.041579170917077385
 0.042602981070413874
 0.03239761861431652
 0.05250042472814261
 0.059608200560583545
 0.04838519217526633
 0.060744302256584566

This page was generated using Literate.jl.