LinA.jl Documentation

LinA.LinearizeFunction
Linearize(expr_fct::Ef,x1::Real,x2::Real, e::ErrorType; bounding = Best() ::BoundingType, ConcavityChanges = [Inf]::Array{Float64,1})

Makes an optimal piecewise Linear approximation of expr_fct from x1 to x2. The result will be an array of LinearPiece. Note that the array is directly callable as a function.

Arguments

  • expr_fct : function to linearize from R to R (either an expression or a native julia function)
  • x1 : from
  • x2 : to
  • e : error type either Absolute() or Relative()

Optional Arguments

  • bounding : Under() for an underestimation, Over() for an overestimation, Best() for estimation that can go under or over the function. By default, it uses Best()
  • ConcavityChanges : Concavity changes in the function. If not given, they will be computed automatically which, in rare cases, can lead to precision errors if the concavity is asymptotic to zero.
Note

It is also possible to specify which algorithm to use between HeuristicLin() and ExactLin() by simply adding it after the error type. By default LinA uses the heuristic.

Note

If the function is given by a expression, the variable is assume to be x

Example

julia> pwl = Linearize(:(x^2),0,2,Absolute(0.1))
3-element Vector{LinA.LinearPiece}:
 0.894427190999916 x -0.1 from 0.0 to 0.894427190999916
 2.683281572999748 x -1.7000000000000006 from 0.894427190999916 to 1.7888543819998326
 4.736067977499794 x -5.372135954999589 from 1.7888543819998326 to 2.0

julia> pwl(1)
0.9832815729997475
source
LinA.LinearBoundingFunction
LinearBounding(expr_fct::Ef,x1::Real,x2::Real, e::ErrorType; ConcavityChanges = [Inf]::Array{Float64,1} )

Makes an optimal piecewise Linear underestimation and overestimation of expr_fct from x1 to x2. For certain error types, it can saves a lot of overhead over calling Linearize two times.

Arguments

  • expr_fct : function to linearize (either an expresion or a native julia function)
  • x1 : from
  • x2 : to
  • e : error type. Both Absolute() and Relative() are implemented.

Optional Arguments

  • ConcavityChanges : Concavity changes in the function. If not given, they will be computed automatically which, in rare cases, can lead to precision errors if the concavity is asymptotic to zero.
source
LinA.LinearizeConvexFunction
LinearizeConvex(x1,x2,lower::Function,upper::Function,du::Function)

Makes an optimal piecewise Linear approximation from x1 to x2 of a convex corridor

Arguments

  • lower : function at the bottom of the corridor
  • upper : function on top of the corridor
  • du : derivative of the upper function
source
LinA.CorridorFromInfoFunction
CorridorFromInfo(x1::Real,x2::Real,expr_fct::Ef,e::ErrorType,bounding::BoundingType)

Create a corridor from an error type and bounding style. This corridor is a tuple (start,end,lowerBound, upperbound, derivative of the Upper bound)

Arguments

  • x1 : from
  • x2 : to
  • expr_fct : function to linearize (either an expresion or a native julia function)
  • e : error type. Both Absolute() and Relative() are implemented
  • bounding : Under() for an underestimation, Over() for an overestimation, Best() for estimation that can go under or over the function.
source
LinA.ExactPieceFunction
ExactPiece(start::Real,maximum::Real,lower,upper)

Computes the maximal linear piece starting at start which lies in between lower and upper. Works for any continuous lower and upper.

Arguments

  • start : from
  • maximum : maximal end point of the linear segment
  • lower : lower bound of the corridor
  • upper : upper bound of the corridor
source
LinA.RelativeType

Relative error from the function (in percentage)

!!! warning
For a relative error to be well defined, the function needs to have no zeros!
source
LinA.isContinuousFunction

isContinuous(pwl, ε = 1e-5)

Determine whether a pwl function is continuous up to a numerical precision of ε.

Arguments

  • plw : pwl function
  • ε : numerical precision
source
LinA.CplexBreakpointsFunction

CplexBreakpoints(pwl, ε = 1e-5)

Outputs the breakpoints needed for CPLEX to natively model PWL functions.

Arguments

  • plw : pwl function
  • ε : numerical precision
source