Main Content

# solve

Class: FunctionApproximation.Problem
Package: FunctionApproximation

Solve for optimized solution to function approximation problem

## Syntax

```solution = solve(problem) ```

## Description

`solution = solve(problem)` solves the optimization problem defined by the `FunctionApproximation.Problem` object, `problem`, and returns the optimized result, `solution`, as a `FunctionApproximation.LUTSolution` object.

## Input Arguments

expand all

Optimization problem specified as a `FunctionApproximation.Problem` object defining the function or Math Function block to approximate, or the Lookup Table block to optimize, and other parameters and constraints to use during the optimization process.

## Output Arguments

expand all

Approximation solution, returned as a `FunctionApproximation.LUTSolution` object.

## Examples

expand all

Create a `FunctionApproximation.Problem` object, specifying a math function to approximate.

`problem = FunctionApproximation.Problem('log')`
```problem = FunctionApproximation.Problem with properties FunctionToApproximate: @(x)log(x) NumberOfInputs: 1 InputTypes: "numerictype(1,16,10)" InputLowerBounds: 0.6250 InputUpperBounds: 15.6250 OutputType: "numerictype(1,16,13)" Options: [1×1 FunctionApproximation.Options]```

Use default values for all other options.

Use the `solve` method to generate an approximation of the function.

`solution = solve(problem)`
```| ID | Memory (bits) | ConstraintMet | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 0 | 64 | 0 | 2 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 1.178125e+00 | | 1 | 1984 | 1 | 122 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 4.192649e-03 | | 2 | 1024 | 0 | 62 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 1.416713e-02 | | 3 | 1968 | 1 | 121 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 4.192649e-03 | | 4 | 64 | 0 | 2 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.138984e+00 | | 5 | 416 | 1 | 13 | 16 | 16 | ExplicitValues | 7.812500e-03, 7.310789e-03 | Best Solution | ID | Memory (bits) | ConstraintMet | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 5 | 416 | 1 | 13 | 16 | 16 | ExplicitValues | 7.812500e-03, 7.310789e-03 | solution = FunctionApproximation.LUTSolution with properties ID: 5 Feasible: "true"```

You can then use the `approximate` method to generate a subsystem containing the lookup table approximation.

Introduced in R2018a

## Support Get trial now