Solved by Bhack in post #5 
              
              
                If you check the other “canned” constrains you can see that you need to just manipulate the weights that are not respecting your constrain. 
In your case I suggest to check this implementation as a baseline to retrieve the indexes of the weights that you want to manipulate: