akreon-convex
Typed convex modeling, conic canonicalization, and primal-dual optimization in C++26.
Loading...
Searching...
No Matches
convex::LogSumExp< Meta, Child > Struct Template Reference

forward declaration - log sum exp fn More...

#include <log_sum_exp.hpp>

Inheritance diagram for convex::LogSumExp< Meta, Child >:
[legend]

Public Types

using ConvexBase = Atom< Meta, LogSumExp< Meta, Child >, Child >
 bring into scope the convex fn alias / helpers
 
- Public Types inherited from convex::Atom< Meta, LogSumExp< Meta, Child >, Child >
using Domain = meta_dom_t< Meta >
 Atom input domain.
 
using Codomain = meta_codom_t< Meta >
 Atom output codomain.
 
using ChildrenT = std::tuple< atom_decay_t< Cs >... >
 Tuple of decayed child atom types.
 
using T = dom_type_t< Domain >
 Scalar field for the atom domain.
 
using PointT = dom_point_t< Domain >
 Point type accepted by the atom domain.
 

Public Member Functions

constexpr LogSumExp (const Child &child_in)
 CTOR.
 
constexpr LogSumExp (const Child &child_in, const affine::AffineMap< LiftedVarMat< T > > &map_in)
 CTOR.
 
constexpr MonotonicityType monotonicity () const
 mono
 
constexpr T operator() (const PointT &x) const
 eval via operator overload
 
constexpr T eval (const PointT &x) const
 eval impl
 
template<T Scalar>
constexpr auto mul () const
 mul
 
constexpr auto add (T beta) const
 add
 
template<AtomType Type, conic::BuilderLike Builder>
constexpr auto canonicalize_impl (const Builder &builder) const
 canonicalize impl
 
- Public Member Functions inherited from convex::Atom< Meta, LogSumExp< Meta, Child >, Child >
constexpr Atom ()
 Construct a leaf atom with no children.
 
constexpr Atom (ChildrenT child_in)
 Construct an atom with normalized children.
 
constexpr void validate_fn_domain (const auto &child) const
 Validate DCP composition for a function child.
 
constexpr void validate_domain () const
 Validate child domains, signs, curvature, and composition rules.
 
constexpr auto canonicalize (const Builder &builder) const
 Dispatch canonicalization to the derived atom.
 
constexpr const LogSumExp< Meta, Child > & self () const
 Return this object as the CRTP-derived atom type.
 

Public Attributes

affine::AffineMap< LiftedVarMat< T > > lift_map
 member vars
 
const int idx {-2}
 
- Public Attributes inherited from convex::Atom< Meta, LogSumExp< Meta, Child >, Child >
ChildrenT children
 Tuple of normalized child atoms.
 

Static Public Attributes

static constexpr CurvatureType Tag = meta_curv_v<Meta>
 curvature tag
 
- Static Public Attributes inherited from convex::Atom< Meta, LogSumExp< Meta, Child >, Child >
static constexpr std::size_t N
 Domain dimension.
 
static constexpr std::size_t M
 Codomain dimension.
 
static constexpr CurvatureType Curvature
 Curvature declared by atom metadata.
 
static constexpr VarType DomSign
 Domain sign declared by atom metadata.
 
static constexpr VarType CodomSign
 Codomain sign declared by atom metadata.
 

Detailed Description

template<typename Meta, typename Child>
struct convex::LogSumExp< Meta, Child >

forward declaration - log sum exp fn

log sum exp = smooth max function

lse(x) = log(sum_i^n(e^{x_i})) which is a smooth mapping from R^n to R

Warning
Partial modeling implementation. Canonicalization requires the exponential cone; end-to-end solver support is in progress.
See also
Support and Roadmap

Definition at line 50 of file log_sum_exp.hpp.

Member Typedef Documentation

◆ ConvexBase

template<typename Meta , typename Child >
using convex::LogSumExp< Meta, Child >::ConvexBase = Atom<Meta, LogSumExp<Meta, Child>, Child>

bring into scope the convex fn alias / helpers

Definition at line 52 of file log_sum_exp.hpp.

Constructor & Destructor Documentation

◆ LogSumExp() [1/2]

template<typename Meta , typename Child >
constexpr convex::LogSumExp< Meta, Child >::LogSumExp ( const Child &  child_in)
inlineexplicitconstexpr

CTOR.

Parameters
child

Definition at line 65 of file log_sum_exp.hpp.

◆ LogSumExp() [2/2]

template<typename Meta , typename Child >
constexpr convex::LogSumExp< Meta, Child >::LogSumExp ( const Child &  child_in,
const affine::AffineMap< LiftedVarMat< T > > &  map_in 
)
inlineexplicitconstexpr

CTOR.

Parameters
child
map

Definition at line 75 of file log_sum_exp.hpp.

Member Function Documentation

◆ add()

template<typename Meta , typename Child >
constexpr auto convex::LogSumExp< Meta, Child >::add ( T  beta) const
inlineconstexpr

add

Parameters
scalar
Returns
abs fn (updated map)

Definition at line 151 of file log_sum_exp.hpp.

References convex::Atom< Meta, LogSumExp< Meta, Child >, Child >::children, convex::dom_size_v, and convex::LogSumExp< Meta, Child >::lift_map.

◆ canonicalize_impl()

template<typename Meta , typename Child >
template<AtomType Type, conic::BuilderLike Builder>
constexpr auto convex::LogSumExp< Meta, Child >::canonicalize_impl ( const Builder &  builder) const
inlineconstexpr

canonicalize impl

(1) f(x) = log(sum_i(exp(x_i))) K = { (x, t) | log(sum_i(exp(x_i))) <= t } K = { (x, t) | sum_i(exp(x_i)) <= exp(t) } K = { (x, t) | sum_i(exp(x_i)) / exp(t) <= 1 } K = { (x, t) | sum_i(exp(x_i - t)) <= 1 } K = { (x, t, s) | exp(x_i - t) <= s_i, 1^T s <= 1 }

Exp cone : { (u, v, w) | v exp(u/v) <= w, v > 0 } union { (u, 0, w) | u <= 0, w >= 0 }

let u = x_i - t, v = 1, w = s_i... n exp cones 0 <= 1 - 1^T s ... 1 nonneg orthant cone

[ A -1 0 ] [ x; t; s ] + [ b; 1; 0 | 1 ] -> (x_i - t, 1, s_i) + rplus [ 0 0 0 ]

[ 0 0 I ]

[ 0 0 -1^T ]

(2) -f(x) = -log(sum_i(exp(x_i))) K = { (x, t) | sum_i(exp(x_i + t)) <= 1 } K = { (x, t, s) | exp(x_i + t) <= s_i, 1^T s <= 1 }

let u = x_i + t, v = 1, w = s_i... n exp cones 0 <= 1 - 1^T s ... 1 nonneg orthant cone

[ A 1 0 ] [ x; t; s ] + [ b; 1; 0 | 1 ] -> (x_i + t, 1, s_i) + rplus [ 0 0 0 ]

[ 0 0 I ]

[ 0 0 -1^T ]

Parameters
coneblock builder
Returns
cone block builder

Definition at line 197 of file log_sum_exp.hpp.

References convex::Atom< Meta, LogSumExp< Meta, Child >, Child >::children, convex::CONVEX, convex::dom_size_v, convex::LogSumExp< Meta, Child >::idx, convex::LogSumExp< Meta, Child >::lift_map, convex::Atom< Meta, LogSumExp< Meta, Child >, Child >::N, and convex::LogSumExp< Meta, Child >::Tag.

◆ eval()

template<typename Meta , typename Child >
constexpr T convex::LogSumExp< Meta, Child >::eval ( const PointT &  x) const
inlineconstexpr

eval impl

Parameters
pointx in dom f
Returns
y in R

Definition at line 105 of file log_sum_exp.hpp.

References convex::CONVEX, convex::dom_size_v, and convex::LogSumExp< Meta, Child >::Tag.

Referenced by convex::LogSumExp< Meta, Child >::operator()().

◆ monotonicity()

template<typename Meta , typename Child >
constexpr MonotonicityType convex::LogSumExp< Meta, Child >::monotonicity ( ) const
inlineconstexpr

mono

Returns
monotonicity

Definition at line 84 of file log_sum_exp.hpp.

References convex::CONVEX, convex::NONDEC, convex::NONINC, and convex::LogSumExp< Meta, Child >::Tag.

◆ mul()

template<typename Meta , typename Child >
template<T Scalar>
constexpr auto convex::LogSumExp< Meta, Child >::mul ( ) const
inlineconstexpr

◆ operator()()

template<typename Meta , typename Child >
constexpr T convex::LogSumExp< Meta, Child >::operator() ( const PointT &  x) const
inlineconstexpr

eval via operator overload

Parameters
pointx
Returns
result

Definition at line 96 of file log_sum_exp.hpp.

References convex::LogSumExp< Meta, Child >::eval().

Member Data Documentation

◆ idx

template<typename Meta , typename Child >
const int convex::LogSumExp< Meta, Child >::idx {-2}

◆ lift_map

◆ Tag


The documentation for this struct was generated from the following files: