How do I limit the sum of the elements in a vector to less than a constant

Sorry for taking so long to respond. Just a few quick thoughts, correct me if this doesn’t address your problem:

You can verify this by using print statements (e.g. something like (if(log_A_3[t,j,3] < 0) { print(" < 0 "); } )

You could have a parameter real<upper=log_max> log_A_sum and then only N-1 parameters for the element, computing the last so that the constraints are met. This however can imply a weird prior on the computed element. Check out the discussion on Test: Soft vs Hard sum-to-zero constrain + choosing the right prior for soft constrain for some related ideas.

Best of luck with your model!