  Upcoming observations from the Simons Observatory have been projected to
constrain the tensor-to-scalar ratio, $r$, at the level of $\sigma(r)=$0.003.
Here we describe one of the forecasting algorithms for the Simons Observatory
in more detail, based on cleaning CMB polarization maps using a parametric
model. We present a new code to perform this end-to-end forecast, and explore
the assumptions in greater detail. If spatial uniformity of the spectral energy
distribution of synchrotron radiation and thermal dust emission is assumed over
the region planned for observations, covering almost a fifth of the sky, a bias
of order 1--3$\sigma$ in $r$ is projected for foreground models consistent with
current data. We find that by masking the most contaminated regions of sky, or
by adopting more parameters to describe the spatial variation in spectral index
for synchrotron and dust, such a bias can be mitigated for the foreground
models we consider. We also explore strategies for testing whether the cleaned
CMB polarization maps contain residual foreground contamination, including
cross-correlating with maps tracing the foregrounds. This method also has
applications for other CMB polarization experiments.
