Created
November 27, 2018 09:07
-
-
Save mosekadmin/af6b5aa0a07b2c17d4765dec2428438e to your computer and use it in GitHub Desktop.
Compact log-sum-exp in MOSEK 9 Fusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Models log(sum(exp(Ax+b))) <= 0. | |
# Each row of [A b] describes one of the exp-terms | |
def logsumexp(M, A, x, b): | |
u = M.variable(A.shape[0]) | |
M.constraint( Expr.sum(u), Domain.lessThan(1.0)) | |
M.constraint( Expr.hstack(u, | |
Expr.constTerm(A.shape[0], 1.0), | |
Expr.add(Expr.mul(A, x), b)), Domain.inPExpCone()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment