From 77ed3e08944489f70284e93e4975dd932037d097 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 6 Jan 2025 10:24:05 +1300 Subject: [PATCH] Add support for Base.log1p --- src/reformulations/log1p.jl | 6 ++++++ test/test_atoms.jl | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/reformulations/log1p.jl diff --git a/src/reformulations/log1p.jl b/src/reformulations/log1p.jl new file mode 100644 index 000000000..acf3d2f8e --- /dev/null +++ b/src/reformulations/log1p.jl @@ -0,0 +1,6 @@ +# Copyright (c) 2014: Madeleine Udell and contributors +# +# Use of this source code is governed by a BSD-style license that can be found +# in the LICENSE file or at https://opensource.org/license/bsd-2-clause + +Base.log1p(x::AbstractExpr) = log(1 + x) diff --git a/test/test_atoms.jl b/test/test_atoms.jl index f198c7a02..1f48f325a 100644 --- a/test/test_atoms.jl +++ b/test/test_atoms.jl @@ -2272,6 +2272,20 @@ function test_inner_product() return end +### reformulations/log1p + +function test_log1p() + target = """ + variables: t, x + minobjective: 1.0 * t + 0.0 + [1.0 * t, 1.0, 1.0 * x + 1.0] in ExponentialCone() + """ + _test_reformulation(target) do context + return log1p(Variable(1)) + end + return +end + ### reformulations/norm function test_norm()