Algorithms
Other types
PiecewiseAffineApprox.Plane
— TypePlane{D}
A D-dimensional hyperplane (αᵀx = β).
PiecewiseAffineApprox.FunctionEvaluations
— TypeFunctionEvaluations{D}
A structure holding a set of points and the associated function values for a function f:ℜᴰ → ℜ.
PiecewiseAffineApprox.PWAFunc
— TypePWAFunc{C<:Curvature,D}
A piecewise linear function that can be either convex and concave represented by a set of (hyper)planes.
If the curvature of the function is convex, the piecewise linear Function is defined as the pointwise maximum over the planes. A concave pwa function is handled by storing its negative and negating when evaluting.
Functions
PiecewiseAffineApprox.approx
— Functionapprox(input::FunctionEvaluations{D}, c::Curvature, a::Algorithm)
Return PWAFunc{Convex,D} or PWAFunc{Concave,D} depending on c
, approximating the input
points in D
dimensions
approx(input::FunctionEvaluations, c::Convex, a::Cluster)
Approximate using a heuristic that works for general dimensions.
Additional keyword arguments:
trials
: number of restarts (default = 20)itlim
: max refining iterations in each trial (default = 50),
approx(input::FunctionEvaluations, c::Convex, a::Progressive)
Approximate using a progressive fitting heuristic that adds planes until a specified error tolerance is met.
This algorithm requires that the data points provided are samples from a convex function.
approx(input::FunctionEvaluations, c::Convex, a::FullOrder)
Approximate using full order fitting that adds planes for all sample points.
This algorithm requires that the data points provided are samples from a convex function.
approx(f::Function, bbox::Vector{<:Tuple}, c::Curvature, a::Algorithm; kwargs...)
Approximate the function using a uniform sampling over the bounding box bbox
Additional keyword arguments:
nsample
: the number of points used in each dimension (default = 10)
PiecewiseAffineApprox.enforce_curvature
— Functionenforce_curvature(f::FunctionEvaluations, curvature::Curvature, optimizer, metric = :l1)
Create a slightly perturbed version of the function values to ensure that the data points can be interpolated by a convex/concave piecewise affine function.
Enforcing the curvature is performed using a linear optimization problem that adjust the function values and tries to minimize the total deviation. The total deviation can be measured in different metrics specified by the metric
parameter. This function can be useful as a pre-step for running the full-order and progressive fitting heuristics that require data points that are convex/concave in this sense.
PiecewiseAffineApprox.evaluate
— Functionevaluate(pwa::PWAFunc{Convex,D}, x) where {D}
Evaluate the convex piecewise linear function at the point x.
evaluate(pwa::PWAFunc{Concave,D}, x) where {D}
Evaluate the concave piecewise linear function at the point x.
PiecewiseAffineApprox.pwaffine
— Functionpwaffine(m::JuMP.Model, x::Tuple, pwa::PWAFunc{C,D}; z=nothing, kwargs...) where {C,D}
Add constraints to JuMP-model m
for JuMP-variable z
as a piecewise linear function/approximation pwa
of JuMP-variables x