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

forward declaration - harmonic mean fn More...

#include <harmonic_mean.hpp>

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

Public Types

using ConvexBase = Atom< Meta, HarmonicMean< Meta, Child >, Child >
 bring into scope the concave fn alias / helpers
 
using Space = dom_space_t< meta_dom_t< Meta > >
 alias to extract space type
 
- Public Types inherited from convex::Atom< Meta, HarmonicMean< 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 HarmonicMean (const Child &child_in)
 CTOR.
 
constexpr HarmonicMean (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
 canonicalization impl
 
- Public Member Functions inherited from convex::Atom< Meta, HarmonicMean< 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 HarmonicMean< 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 {-1}
 
- Public Attributes inherited from convex::Atom< Meta, HarmonicMean< 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, HarmonicMean< 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>
requires (dom_size_v<meta_dom_t<Meta>> == 2)
struct convex::HarmonicMean< Meta, Child >

forward declaration - harmonic mean fn

harmonic mean f(x) = 2xy / (x + y) is convex where dom f = R^2_++

Definition at line 46 of file harmonic_mean.hpp.

Member Typedef Documentation

◆ ConvexBase

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

bring into scope the concave fn alias / helpers

Definition at line 48 of file harmonic_mean.hpp.

◆ Space

template<typename Meta , typename Child >
using convex::HarmonicMean< Meta, Child >::Space = dom_space_t<meta_dom_t<Meta> >

alias to extract space type

Definition at line 54 of file harmonic_mean.hpp.

Constructor & Destructor Documentation

◆ HarmonicMean() [1/2]

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

CTOR.

Parameters
child

Definition at line 64 of file harmonic_mean.hpp.

◆ HarmonicMean() [2/2]

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

CTOR.

Parameters
child
map

Definition at line 74 of file harmonic_mean.hpp.

Member Function Documentation

◆ add()

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

add

Parameters
scalar
Returns
harmonic mean fn

Definition at line 149 of file harmonic_mean.hpp.

References convex::dom_size_v.

◆ canonicalize_impl()

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

canonicalization impl

(1) f(x) = 2 x y / (x + y) C = { (x, y, t) | 2 x y / (x + y) >= t, x > 0, y > 0 } 2xy >= t(x + y)

RSOC let u = t / sqrt(2), v = x - t/2, w = y - t/2 t^2 / 2 <= 2(x - t/2)(y - t/2) t^2 <= 4[xy - xt/2 - yt/2 + t^2/4] 0 <= 4xy - 2t(x + y) + t^2... 2xy >= t(x + t)

[ 0 0 1/sqrt(2) ] [ x; y; t ] + [ 0; b; b ] -> (u, v, w) [ a0 0 -1/2 ] [ 0 a1 -1/2 ]

(2) -f(x) = -2 x y / (x + y) RSOC let u = -t/sqrt(2), v = x + t/2, w = y + t/2

[ 0 0 -1/sqrt(2) ] [ x; y; t ] + [ 0; b; b ] -> (u, v, w) [ a0 0 1/2 ] [ 0 a1 1/2 ]

Parameters
builder
Returns
new builder

Definition at line 183 of file harmonic_mean.hpp.

References convex::CONCAVE, and convex::dom_size_v.

◆ eval()

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

eval impl

Parameters
xin dom f
Returns
y in R_++ or R_–

Definition at line 105 of file harmonic_mean.hpp.

References convex::CONCAVE, and convex::dom_size_v.

◆ monotonicity()

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

mono

Returns
monotonicity

Definition at line 83 of file harmonic_mean.hpp.

References convex::CONCAVE, convex::NONDEC, and convex::NONINC.

◆ mul()

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

mul

Returns
harmonic mean fn

Definition at line 122 of file harmonic_mean.hpp.

References convex::CONVEX, and convex::dom_size_v.

◆ operator()()

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

eval via operator overload

Parameters
pointx
Returns
result

Definition at line 96 of file harmonic_mean.hpp.

Member Data Documentation

◆ idx

template<typename Meta , typename Child >
const int convex::HarmonicMean< Meta, Child >::idx {-1}

Definition at line 226 of file harmonic_mean.hpp.

◆ lift_map

template<typename Meta , typename Child >
affine::AffineMap<LiftedVarMat<T> > convex::HarmonicMean< Meta, Child >::lift_map

member vars

Definition at line 225 of file harmonic_mean.hpp.

◆ Tag

template<typename Meta , typename Child >
constexpr CurvatureType convex::HarmonicMean< Meta, Child >::Tag = meta_curv_v<Meta>
staticconstexpr

curvature tag

Definition at line 57 of file harmonic_mean.hpp.


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