Be careful when writing your objective and constraint functions. Intermediate iterations can lead to points that are infeasible (do not satisfy constraints). If you write objective or constraint functions that assume feasibility, these functions can error or give unexpected results.
For example, if you take a square root or logarithm of x,
and x < 0, the result is not real. You can
try to avoid this error by setting 0 as a lower
bound on x. Nevertheless, an intermediate iteration
can violate this bound.
Some solver algorithms satisfy bound constraints at every iteration:
fmincon interior-point, sqp,
and trust-region-reflective algorithms
lsqcurvefit trust-region-reflective algorithm
lsqnonlin trust-region-reflective algorithm
fminbnd
If you set a lower bound equal to an upper bound, iterations can violate these constraints.
The following solvers and algorithms can violate bound constraints at intermediate iterations:
fmincon active-set algorithm
fgoalattain solver
fminimax solver
fseminf solver