Algorithms

Other types

PiecewiseAffineApprox.PWAFuncType
PWAFunc{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.approxFunction
approx(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_curvatureFunction
enforce_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.evaluateFunction
evaluate(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.pwaffineFunction
pwaffine(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