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.1480332350684095
evaluate(x)
25-element Vector{Float64}:
0.02090112150925664
0.026662221322873127
0.03088782116314491
0.05861220536048732
0.05449215264938552
0.02645247054167646
0.03366533267317568
0.06379294998140604
0.0732298484881859
0.02313412240924475
⋮
0.027717200127803588
0.049568617076695645
0.04157917069184767
0.04260298097492467
0.032397618155268273
0.05250042455119695
0.05960820012403955
0.04838519200843289
0.06074430288075965
This page was generated using Literate.jl.