Convex analysis basics dev

Sat, 14 Dec 2024 09:31:27 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 14 Dec 2024 09:31:27 -0500
branch
dev
changeset 58
1a38447a89fa
parent 57
1b3b1687b9ed
child 59
9226980e45a7

Convex analysis basics

src/convex.rs file | annotate | diff | comparison | revisions
src/lib.rs file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/convex.rs	Sat Dec 14 09:31:27 2024 -0500
@@ -0,0 +1,50 @@
+/*!
+Some convex analysis basics
+*/
+
+use crate::mapping::{Apply, Mapping};
+
+/// Trait for convex mappings. Has no features, just serves as a constraint
+///
+/// TODO: should constrain `Mapping::Codomain` to implement a partial order,
+/// but this makes everything complicated with little benefit.
+pub trait ConvexMapping<Domain> : Mapping<Domain> {}
+
+/// Trait for mappings with a Fenchel conjugate
+///
+/// The conjugate type has to implement [`ConvexMapping`], but a `Conjugable` mapping need
+/// not be convex.
+pub trait Conjugable<Domain> : Mapping<Domain> {
+    type DualDomain;
+    type Conjugate<'a> : ConvexMapping<Self::DualDomain> where Self : 'a;
+
+    fn conjugate(&self) -> Self::Conjugate<'_>;
+}
+
+/// Trait for mappings with a Fenchel preconjugate
+///
+/// In contrast to [`Conjugable`], the preconjugate need not implement [`ConvexMapping`],
+/// but a `Preconjugable` mapping has be convex.
+pub trait Preconjugable<Domain> : ConvexMapping<Domain> {
+    type PredualDomain;
+    type Preconjugate<'a> : Mapping<Self::PredualDomain> where Self : 'a;
+
+    fn preconjugate(&self) -> Self::Preconjugate<'_>;
+}
+
+/// Trait for mappings with a proximap map
+///
+/// The conjugate type has to implement [`ConvexMapping`], but a `Conjugable` mapping need
+/// not be convex.
+pub trait HasProx<Domain> : Mapping<Domain> {
+    type Prox<'a> : Mapping<Domain, Codomain=Domain> where Self : 'a;
+
+    /// Returns a proximal mapping with weight τ
+    fn prox_mapping(&self, τ : Self::Codomain) -> Self::Prox<'_>;
+
+    /// Calculate the proximal mapping with weight τ
+    fn prox(&self, z : Domain, τ : Self::Codomain) -> Domain {
+        self.prox_mapping(τ).apply(z)
+    }
+}
+
--- a/src/lib.rs	Fri Dec 13 22:37:12 2024 -0500
+++ b/src/lib.rs	Sat Dec 14 09:31:27 2024 -0500
@@ -42,5 +42,6 @@
 pub mod nalgebra_support;
 pub(crate) mod metaprogramming;
 pub mod direct_product;
+pub mod convex;
 
 pub use types::*;

mercurial