  We apply the Krotov method for open and closed quantum systems with the
objective of finding optimized controls to manipulate qubit/qutrit systems in
the presence of the external environment. In the case of unitary optimization,
the Krotov method is first applied to a quantum system neglecting its
interaction with the environment. The resulting controls from the unitary
optimization are then used to drive the system along with the environmental
noise. In the case of non-unitary optimization, the Krotov method already takes
into account the noise during the optimization process. We consider two
distinct computational task: target-state preparation and quantum gate
implementation. These tasks are carried out in simple qubit/qutrit systems and
also in systems presenting leakage states. For the state-preparation cases, the
controls from the non-unitary optimization outperform the controls from the
unitary optimization. However, as we show here, this is not always true for the
implementation of quantum gates. There are some situations where the unitary
optimization performs equally well compared to the non-unitary optimization. We
verify that these situations corresponds to either the absence of leakage
states or to the effects of dissipation being spread uniformly over the system,
including non-computational levels. For such cases, the quantum gate
implementation must cover the entire Hilbert space and there is no way to dodge
dissipation. On the other hand, if the subspace containing the computational
levels and its complement are differently affected by dissipation, the
non-unitary optimization becomes effective.
