API
PiecewiseLinearFunctions.PiecewiseLinearFunction
PiecewiseLinearFunctions.PiecewiseLinearFunction
PiecewiseLinearFunctions.compose
PiecewiseLinearFunctions.compute_slopes
PiecewiseLinearFunctions.convex_lower_bound
PiecewiseLinearFunctions.convex_meet
PiecewiseLinearFunctions.is_convex
PiecewiseLinearFunctions.is_convex_sequence
PiecewiseLinearFunctions.remove_redundant_breakpoints
PiecewiseLinearFunctions.PiecewiseLinearFunction
— Typestruct PiecewiseLinearFunction{T<:AbstractFloat}
Fields
x::Vector{T} where T<:AbstractFloat
: x coordinates of the breakpointsy::Vector{T} where T<:AbstractFloat
: y coordinates of the breakpointsleft_slope::AbstractFloat
: slope of the function to the left of the first breakpointright_slope::AbstractFloat
: slope of the function to the right of the last breakpoint
PiecewiseLinearFunctions.PiecewiseLinearFunction
— MethodEvaluate the piecewise linear function f
at x
.
PiecewiseLinearFunctions.compose
— Methodcompose(
f::PiecewiseLinearFunction{T},
g::PiecewiseLinearFunction{T};
postprocess_breakpoints
) -> PiecewiseLinearFunction
Compute the composition f ∘ g of two piecewise linear functions. By default, the function removes redundant breakpoints in the output as a post processing step.
This method can also be called using Base.∘
PiecewiseLinearFunctions.compute_slopes
— Methodcompute_slopes(
f::PiecewiseLinearFunction
) -> Vector{<:AbstractFloat}
Compute all the slopes of the piecewise linear function, from left to right.
PiecewiseLinearFunctions.convex_lower_bound
— Methodconvex_lower_bound(
f::PiecewiseLinearFunction{T}
) -> PiecewiseLinearFunction
Compute the tightest convex lower bound of a piecewise linear function, using a convex hull algorithm.
PiecewiseLinearFunctions.convex_meet
— Methodconvex_meet(
f::PiecewiseLinearFunction{T},
g::PiecewiseLinearFunction{T}
) -> PiecewiseLinearFunction
Compute the convex meet of two piecewise linear functions, i.e. the tightest convex lower bound.
PiecewiseLinearFunctions.is_convex
— Methodis_convex(f::PiecewiseLinearFunction; eps) -> Any
Check if a piecewise linear function is convex.
PiecewiseLinearFunctions.is_convex_sequence
— Methodis_convex_sequence(f, i1, i2, i3) -> Any
Check if the sequence of points (p1, p2, p3) forms a convex sequence.
PiecewiseLinearFunctions.remove_redundant_breakpoints
— Methodremove_redundant_breakpoints(
f::PiecewiseLinearFunction;
atol
) -> PiecewiseLinearFunction
Return a new piecewise linear function with redundant breakpoints removed.