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.2072251044046554
x.value
25×1 Array{Float64,2}:
 0.04206886425093688 
 0.03457229652244405 
 0.035878056898433805
 0.029020798307983226
 0.052324629391367804
 0.04247007662656345 
 0.03828009010340274 
 0.04047616962048803 
 0.039062862471573354
 0.03640861151656186 
 ⋮                   
 0.05421299208385005 
 0.033986094211083215
 0.04508071889024127 
 0.03871064663612938 
 0.04881740688341207 
 0.03073950762360894 
 0.04238196966674161 
 0.0377729388286942  
 0.03181532194215058 

This page was generated using Literate.jl.