You can set the precision of fmincon
in Matlab by setting the OptimalityTolerance
option. This parameter sets the tolerance for the convergence of the algorithm, and therefore controls the precision of the solution.
The default value of OptimalityTolerance
is 1e-6, which should work for most applications. However, you may need to adjust this value if you require higher or lower precision.
To set the OptimalityTolerance
to a different value, you can add an option to the call to fmincon
, like this:
main.m128 chars3 lines
In this example, we create an options object using the optimoptions
function, and set the OptimalityTolerance
to 1e-8
. We then pass this object as the last argument to fmincon
.
Note that setting a smaller value for OptimalityTolerance
may result in longer computation time, as the algorithm has to work harder to find a more precise solution. Conversely, setting a larger value may result in a less precise solution.
gistlibby LogSnag