Contenido principal

FunctionApproximation.Options Class

R2026b

Namespace: FunctionApproximation

Specify additional options to use with FunctionApproximation.Problem object

Description

The FunctionApproximation.Options object contains additional options for defining a FunctionApproximation.Problem object.

Construction

options = FunctionApproximation.Options() creates a FunctionApproximation.Options object to use as an input to a FunctionApproximation.Problem object. The output, options, uses default property values.

options = FunctionApproximation.Options(Name=Value) creates a FunctionApproximation.Options object with property values specified by name-value arguments. You can specify name-value arguments in any order as Name1=Value1,...,NameN=ValueN.

Properties

expand all

Absolute tolerance between the original and approximated output values, specified as a nonnegative scalar.

When you specify multiple input functions in a FunctionApproximation.Problem object, you can set a unique AbsTol value for each input function by specifying the tolerances as an ordered vector.

Example: options.AbsTol = 2^-8

Example: options.AbsTol = [2^-8,2^-7]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Whether to allow updating of the model diagram during the approximation process, specified as a numeric or logical 1 (true) or 0 (false). This property is only relevant for FunctionApproximation.Problem objects that specify a Lookup Table block, or a Math Function block as the item to approximate.

Data Types: logical

How to output optimized lookup table, specified as 'Simulink' or 'MATLAB'. When this property is set to 'Simulink', the approximate method produces a Simulink® subsystem containing the optimized lookup table. When this property is set to 'MATLAB', the approximate method outputs the optimized lookup table as a MATLAB® function.

Generating an optimized lookup table as a MATLAB function is not supported when:

  • The AUTOSARCompliant property is set to true

  • The UseParallel property is set to true

  • The HDLOptimized property is set to true

  • The InterpolationMethod property is set to 'None'

Note

The Simulink block and MATLAB function lookup table approximations generated by the FunctionApproximation namespace may not be exactly numerically equivalent. However, both solution forms are guaranteed to meet all constraints specified in the optimization problem.

Example: options.ApproximateSolutionType ='MATLAB';

Data Types: char

Whether the generated block is an AUTOSAR block, specified as a numeric or logical 0 (false) or 1 (true). When this property is set to 1 (true), the generated lookup table is a Curve block or Map block from the AUTOSAR Blockset. When this property is set to 1 (true), the data type of the table data must equal the output data type of the block.

Setting this property to 1 (true) checks out an AUTOSAR Blockset license when you use the approximate or replaceWithApproximate methods.

This property is not supported when:

  • ApproximateSolutionType is set to 'MATLAB'.

  • Multiple functions are specified in the FunctionApproximation.Problem object.

Data Types: logical

Spacing of breakpoint data, specified as one of these values.

Breakpoint SpecificationDescription
ExplicitValuesLookup table breakpoints are specified explicitly. Breakpoints can be closer together for some input ranges and farther apart in others.
EvenSpacingLookup table breakpoints are evenly spaced throughout.
EvenPow2SpacingLookup table breakpoints use power-of-two spacing. This breakpoint specification boasts the fastest execution speed because a bit shift can replace the position search.

For more information on how breakpoint specification can affect performance, see Effects of Spacing on Speed, Error, and Memory Usage.

Spacing using ExplicitValues is not supported when you specify multiple functions in the FunctionApproximation.Problem object.

Data Types: char

How to display details of each iteration of the optimization, specified as one of the following

  • 'Full' or 1 - displays information in the command window at each iteration of the approximation process.

  • 'Short' or 2 - displays fewer information categories in the command window at each iteration of the approximation process.

  • 'None' or 0 - displays no information until optimization is complete.

Data Types: char | string | enumerated

Whether to allow the optimizer to explore half-precision data types for table data and breakpoints, specified as a numeric or logical 1 (true) or 0 (false).

Data Types: logical

Whether to generate an HDL-optimized approximation, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 (true) results in the approximation being a subsystem consisting of a prelookup step followed by interpolation that functions as a lookup table with explicit pipelining to generate efficient HDL code.

To generate an HDL-optimized approximation, the function to approximate must be one-dimensional, and BreakpointSpecification must be set to EvenSpacing or EvenPow2Spacing.

This property is not supported when:

  • ApproximateSolutionType is set to 'MATLAB'.

  • Multiple functions are specified in the FunctionApproximation.Problem object.

Data Types: logical

Method when an input falls between breakpoint values, specified as one of the values in this table. The lookup table interpolates the output value using neighboring breakpoints.

Interpolation MethodDescription
LinearFits a line between the adjacent breakpoints, and returns the point on that line corresponding to the input.
FlatReturns the output value corresponding to the breakpoint value that is immediately less than the input value. If no breakpoint value exists below the input value, it returns the breakpoint value nearest the input value.
NearestReturns the value corresponding to the breakpoint that is closest to the input. If the input is equidistant from two adjacent breakpoints, the breakpoint with the higher index is chosen.
None

Generates a Direct Lookup Table (n-D) block, which performs table lookups without any interpolation or extrapolation.

Note

When generating a Direct Lookup Table block, the maximum number of inputs is two.

The interpolation method None is not supported when:

  • ApproximateSolutionType is set to 'MATLAB'.

  • Multiple functions are specified in the FunctionApproximation.Problem object.

Data Types: char

The maximum amount of memory the generated lookup table can use, in bits, specified as a scalar integer. You can change the units of the option using the MemoryUnits property.

Data Types: double

Maximum amount of time for the approximation to run, specified in seconds as a scalar number. The approximation runs until it reaches the time specified, finds an ideal solution, or reaches another stopping criteria.

Data Types: double

Units for MaxMemoryUsage property, specified as 'bits', 'bytes', or one of the other enumerated options.

Data Types: char

Whether to constrain table values to the quantized output of the function being approximated, specified as a numeric or logical 0 (false) or 1 (true). By setting this property to 0 (false) and allowing off-curve table values, you can reduce the memory of the lookup table while maintaining the same error tolerances or maintain the same memory while reducing the error tolerances.

When you specify multiple input functions in a FunctionApproximation.Problem object, you can set a unique OnCurveTableValues for each input function by specifying the value as an ordered vector.

Example: options.OnCurveTableValues = [true, false]

Data Types: logical

Relative tolerance between the original and approximated output values, specified as a nonnegative scalar.

When you specify multiple input functions in a FunctionApproximation.Problem object, you can set a unique RelTol for each input function by specifying the tolerances as an ordered vector.

Example: options.RelTol = 2^-8

Example: options.RelTol = [2^-8,2^-7]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Whether to automatically saturate the range of the output of the function to approximate to the range of the output data type, specified as a numeric or logical 1 (true) or 0 (false).

Example: options.SaturateToOutputType = 1;

Data Types: logical

Whether to run optimization iterations in parallel, specified as a numeric or logical 0 (false) or 1 (true). Running the iterations in parallel requires a Parallel Computing Toolbox™ license. If you do not have a Parallel Computing Toolbox license, or if you specify 0 (false), the iterations run in serial.

This property is not supported when:

  • ApproximateSolutionType is set to 'MATLAB'.

  • Multiple functions are specified in the FunctionApproximation.Problem object.

Example: options.UseParallel = true;

Data Types: logical

Specify the word lengths, in bits, that can be used in the lookup table approximate based on your intended hardware. For example, if you intend to target an embedded processor, you can restrict the data types in your lookup table to native types, 8, 16, and 32. The word lengths must be between 1 and 65,535.

Example: options.WordLengths = [8,16,32];

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

Limitations

  • Lookup table objects and breakpoint objects are not supported in a model mask workspace.

Algorithms

When you set BreakpointSpecification to 'ExplicitValues', during the approximation process, the algorithm also attempts to find a solution using 'EvenSpacing' and 'EvenPow2Spacing'. Likewise, when you set BreakpointSpecification to 'EvenSpacing', the algorithm also attempts to find a solution using 'EvenPow2Spacing'. If you set the property to 'EvenPow2Spacing', the algorithm only attempts to find a solution using this spacing.

In cases where the BreakpointSpecification property is set to 'EvenSpacing', but the InputUpperBounds or InputLowerBounds property of the FunctionApproximation.Problem object is equal to the range of the InputTypes, the algorithm does not attempt to find a solution using 'EvenPow2Spacing'.

Version History

Introduced in R2018a

expand all