Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind.optimization Module Reference

Concepts

concept  dedekind::optimization::SuitableForAxisAlignedFastPath
 Carrier requirements for the bit-ops fast-path kernel.
concept  dedekind::optimization::HasUnitRangeEntries
 Pack-level concept: every halfspace has entries in {−1, 0, +1}.
concept  dedekind::optimization::IsAxisAlignedPolytope
 Pack-level concept: every halfspace is axis-aligned.

Classes

struct  dedekind::optimization::Edge
 A directed edge of the graph: tail → head (node indices). More...
struct  dedekind::optimization::Relax< S, Cap, CostFn >
 Fold step of the single-source semiring closure: relax the potential at e.head through the edge e, d(v) ← d(v) ⊕ d(u) ⊗ c(u,v). More...
struct  dedekind::optimization::CriticalPathState< S, Cap >
 Fold accumulator of annotate: the transient potential net paired with the critical-path predecessor map it induces. More...
struct  dedekind::optimization::CriticalPathStep< S, Cap, CostFn >
 Fold step of annotate: relax through e and, when the candidate wins the (selective) join, record e.tail as e.head's predecessor. More...
struct  dedekind::optimization::Halfspace2D< T, a, b, c >
 2D halfspace a·x + b·y ≤ c, entries as NTTPs. More...
struct  dedekind::optimization::HalfspaceTriple< T >
 Value-level halfspace carrier (a, b, c) for the bridge kernel. Paired with the NTTP carrier Halfspace2D: an instance of Halfspace2D<T, a, b, c> destructures into a HalfspaceTriple <T>{a, b, c} for the uniform value-vector the kernel consumes. The two structures share one role — the halfspace — split across the type/value boundary the bridge straddles. More...
struct  dedekind::optimization::VertexCandidate< T >
 Reduction output: optimum coordinates with a feasibility flag. More...
struct  dedekind::optimization::LPSolutionPredicate< T >
 :expressions predicate carrying the LP's runtime optimal locus as (point, feasible) value-level state. More...
struct  dedekind::optimization::Singleton2DPredicate< T, x_val, y_val >
 :expressions predicate for the LP's unique optimal vertex at NTTP coordinates. More...
struct  dedekind::optimization::Polytope2D< T, cx, cy, Hs >
 Polytope context: the (cx, cy, Hs...) pack reified as a type. More...
struct  dedekind::optimization::Halfspace2DPredicate< T, a, b, c >
 :expressions predicate for one 2D halfspace a·x + b·y ≤ c. More...
struct  dedekind::optimization::Polytope2DPredicate< T, Hs >
 :expressions predicate for the meet of N 2D halfspaces: a polytope as a single conjunctive predicate, with the halfspace pack carried at the type level so downstream combinators (argmax , and anything else dispatching on the polytope's structure) can extract it. More...
struct  dedekind::optimization::LinearFunctional< T, cx_, cy_ >
 Linear functional U : F → T with NTTP-typed coefficients. Carries the objective as type parameters so argmax can call the NTTP-driven implementation detail::maximize_set directly without smuggling the values through function parameters. More...

Functions

template<std::size_t Nodes, std::size_t Cap, typename Pred>
constexpr FiniteSeq< Edge, Cap > dedekind::optimization::ext (Pred edge)
 Materialise an intensional graph rule extensionally: the edge sequence { (u,v) : edge(u,v) } over nodes 0 … Nodes−1, in topological (tail-ascending) order. Where a rule becomes elements.
template<typename S, std::size_t Cap, typename Edges, typename CostFn>
requires dedekind::category::IsSemiring< S, typename dedekind::algebra::semiring_ops<S>::add, typename dedekind::algebra::semiring_ops<S>::mult>
constexpr S dedekind::optimization::semiring_closure (std::size_t source, std::size_t sink, const Edges &edges, CostFn cost)
 Single-source semiring closure: fold the edge sequence into the potential net, return its value at the sink. The semiring ops are the carrier's canonical semiring_ops.
template<typename S, std::size_t Cap, typename Edges, typename CostFn>
requires dedekind::algebra::IsTropical< S, typename dedekind::algebra::semiring_ops<S>::add, typename dedekind::algebra::semiring_ops<S>::mult>
constexpr FiniteNet< std::size_t, Cap > dedekind::optimization::annotate (std::size_t source, const Edges &edges, CostFn cost)
 Collapse the edge relation to the critical-path FUNCTION pred : V → V (each node's predecessor on the longest path). Gated on IsTropical (idempotent ⊕). Precondition beyond the gate: ⊕ must be selective (its result is one of its two operands), which is what makes argmax — and hence a single-valued pred — well defined. MaxPlus satisfies this; IsTropical alone does not guarantee it (a non-selective dioid such as powerset-union would yield a third value and need a set-valued pred). FIXME(#769): tighten the gate to a selectivity concept.
template<std::size_t Cap>
constexpr FiniteSeq< Edge, Cap > dedekind::optimization::critical_path (const FiniteNet< std::size_t, Cap > &pred, std::size_t source, std::size_t sink)
 Iterate the pred net back from sink to source: the critical path as an edge sequence. A functional graph — one way between any two nodes — ready to fold for cost or query for criticality.
template<typename T>
constexpr auto dedekind::optimization::lp_runtime_solution_set (dedekind::linear_algebra::Vec2V< T > point, bool feasible)
 Lift a runtime optimal locus into a :expressions Set whose predicate carries (point, feasible) at the value level. Mirrors lp_singleton_set / lp_empty_set on the runtime path: the Set is a singleton {point} when feasible, empty when not, with the same Set type either way.
template<typename T>
requires dedekind::algebra::HasRingOperators<T>
constexpr auto dedekind::optimization::maximize_with_values (std::span< const HalfspaceTriple< T > > halfspaces, T cx, T cy)
template<typename T>
requires SuitableForAxisAlignedFastPath<T>
constexpr auto dedekind::optimization::maximize_axis_aligned_with_values (std::span< const HalfspaceTriple< T > > halfspaces, T cx, T cy)
 Runtime entry for the bit-ops fast-path kernel. Same shape as maximize_with_values ; the NTTP entry maximize statically gates this path via HasUnitRangeEntries and IsAxisAlignedPolytope , but the runtime entry is also reachable directly, so the kernel defensively validates each halfspace and collapses the result to the empty Set (the output Set's LPSolutionPredicate carries feasible == false at the value level) on:
template<typename T>
requires dedekind::algebra::HasRingOperators<T>
constexpr auto dedekind::optimization::maximize_cramer_with_values (std::span< const HalfspaceTriple< T > > halfspaces, T cx, T cy)
 Power-user runtime entry that forces the generic Cramer kernel and bypasses the mechanical dispatch in maximize_with_values . Same shape and requires as maximize_with_values ; sibling of maximize_axis_aligned_with_values on the Cramer side.
template<typename T, T x_val, T y_val>
constexpr auto dedekind::optimization::lp_singleton_set ()
 Lift an NTTP (x*, y*) into a :expressions Set whose predicate carries the singleton structurally. Mirrors halfspace_set on the input side; together they make the §3 ↔ §5 bridge symmetric — Set goes in, Set comes out.
template<typename T>
constexpr auto dedekind::optimization::lp_empty_set ()
 The empty optimum: Ø over Vec2V<T>, the output of argmax when the LP is infeasible — a value, not a compile event.
template<typename T, T cx, T cy, typename... Hs>
requires (sizeof...(Hs) >= 2) && dedekind::algebra::HasRingOperators<T>
constexpr auto dedekind::optimization::lp_extract (Polytope2D< T, cx, cy, Hs... >)
 ε / extract for the LP comonadic context. Provided as a free function so callers can write lp_extract(polytope) at the call site.
template<typename T, T a, T b, T c>
constexpr auto dedekind::optimization::halfspace_set (Halfspace2D< T, a, b, c >)
 Lift a Halfspace2D NTTP value into a :expressions Set whose predicate carries the halfspace structurally.
template<typename T, T a1, T b1, T c1, T a2, T b2, T c2>
constexpr auto dedekind::optimization::structured_and (Halfspace2DPredicate< T, a1, b1, c1 >, Halfspace2DPredicate< T, a2, b2, c2 >)
 Halfspace + halfspace → polytope of two halfspaces.
template<typename T, typename... Hs, T a, T b, T c>
constexpr auto dedekind::optimization::structured_and (Polytope2DPredicate< T, Hs... >, Halfspace2DPredicate< T, a, b, c >)
 Polytope + halfspace → polytope with the halfspace appended.
template<typename T, T a, T b, T c, typename... Hs>
constexpr auto dedekind::optimization::structured_and (Halfspace2DPredicate< T, a, b, c >, Polytope2DPredicate< T, Hs... >)
 Halfspace + polytope → delegate to the canonical direction.
template<typename T, typename... Hs1, typename... Hs2>
constexpr auto dedekind::optimization::structured_and (Polytope2DPredicate< T, Hs1... >, Polytope2DPredicate< T, Hs2... >)
 Polytope + polytope → concatenate the halfspace packs. Without this overload, a right-associative meet (H1 & H2) & (H3 & H4) would fall through to the lambda meet in :expressions::operator& ; the whole point of structured_and is that the structural collapse must not depend on how the source bracketed the meet.
template<typename T, typename L, typename... Hs, T cx, T cy>
requires (sizeof...(Hs) >= 2) && dedekind::algebra::HasRingOperators<T>
constexpr auto dedekind::optimization::argmax (const dedekind::sets::Comprehension< dedekind::sets::𝔸< dedekind::linear_algebra::Vec2V< T >, L >, Polytope2DPredicate< T, Hs... > > &, LinearFunctional< T, cx, cy >)
 argmax(G, U) on a polytope-Set and a linear functional.

Files

file  src/main/modules/dedekind/optimization/optimization.cppm
 Mathematical programming — optimum as a typed constant.
file  src/main/modules/dedekind/optimization/closure.cppm
 Single-source graph closure over a semiring, as a fold over its edges.
file  src/main/modules/dedekind/optimization/lp.cppm
 Linear programming with the optimum as a typed constant.