Numerical allocation layers (e.g. NumericalMarkowitz) might generate weights that do not satisfy the constraints. There are the following reasons for it
small floating point differences (e.g. w_i=-1e-8 with w>=0 constraint)
algorithm did not converge and the underlying solver did not raise any exception
It can become an issue when using a loss that is not defined for certain values of w.
The cleanest solution would be to have a new allocation layer that would be called after the original allocation layer. Ideally,
it would do the following
Perform checks and potentially raise exception
Rescale weights to satisfy the original constraints
Numerical allocation layers (e.g.
NumericalMarkowitz
) might generate weights that do not satisfy the constraints. There are the following reasons for itIt can become an issue when using a loss that is not defined for certain values of w.
The cleanest solution would be to have a new allocation layer that would be called after the original allocation layer. Ideally, it would do the following