Main Content

FunctionApproximation.Options Class

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 one or more Name,Value pair arguments. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Properties

expand all

Maximum tolerance of the absolute value of the difference between the original output value and the output value of the approximation, specified as a non-negative scalar.

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 lookup table is AUTOSAR compliant, specified as a numeric or logical 1 (true) or 0 (false). When this property is set to 1 (true), the generated lookup table is a Curve 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 a AUTOSAR Blockset license when you use the approximate or replaceWithApproximate methods.

This property is not supported when the ApproximateSolutionType property is set to 'MATLAB'.

Data Types: logical

Spacing of breakpoint data, specified as one of the following 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.

Data Types: char

Whether to display details of each iteration of the optimization, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 (true) results in information in the command window at each iteration of the approximation process. A value of 0 (false) does not display information until the approximation is complete.

Data Types: logical

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 approximate, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 (true) results in the approximate 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 approximate, the function to approximate must be one-dimensional and BreakpointSpecification must be set to EvenSpacing or EvenPow2Spacing.

This property is not supported when the ApproximateSolutionType property is set to 'MATLAB'.

Data Types: logical

When an input falls between breakpoint values, 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 the ApproximateSolutionType property is set to 'MATLAB'.

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 1 (true) or 0 (false). By setting this property to 0 (false) and allowing off-curve table values, you may be able to reduce the memory of the lookup table while maintaining the same error tolerances, or maintain the same memory while reducing the error tolerances.

Data Types: logical

Maximum tolerance of the relative difference between the original output value and the output value of the approximation, specified as a non-negative scalar.

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 iterations of the optimization in parallel, specified as a numeric or logical 1 (true) or 0 (false). 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 the ApproximateSolutionType property is set to 'MATLAB'.

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