It's been a while since the OP has replied so I don't think he will mind if we continue this alternate discussion here.
I think I understood you correctly. It's simply a matter of finding all the integrals.
So you have a constant jerk (let's say jerk has the value 'A', this gives the equation:
j = A
Then the acceleration is the integral of this with respect to time, and velocity is the integral of acceleration with respect to time, and distance is the integral of velocity with respect to time. Those equations are respectively,
a = A t + a_{0}
v = \frac{1}{2} A t^{2} + a_{0} t + v_{0}
x = \frac{1}{6} A t^{3} + \frac{1}{2} a_{0} t^{2} + v_{0} t + x_{0}
assuming that your initial acceleration, initial velocity, and initial position are all zero, then the final equation is simply:
x = \frac{1}{6} A t^{3}
Now, I'm also assuming that you allow your model to apply the same jerk of opposite magnitude during the slowdown process, in which case you want to have maximum constant positive jerk for the first half of the trip, and maximum constant negative jerk for the second half.
If this is correct, then you only need to do this calculation for the first half because it should take the same amount of time for the second half.
Now just take that last equation and plug in x=(1/2)distance. You should know what 'A' is, it's your constant jerk value, so the only unknown is 't'.
This is the time it should take to reach half way.
Then if you want to know what the maximum acceleration is at that point, just plug that value for 't' into the second equation:
a = A t + a_{0}
again, you probably want a_{0} to be zero, and that will give you the highest value possible for your acceleration. If your acceleration were to go any higher than this under the distance constraint then you would not be able to stop in time.
So basically in a single formula your max acceleration would be:
a = A^{2/3} (3 d)^{1/3}
Also, for your algorithm, this might be the most efficient way to check what action to take. If you do exactly this calculation and you find that 'a' is greater than your maximum allowed acceleration, then you do not have a distance constraint and this method won't work, it is either an acceleration or velocity constraint and you would solve it a different way which you said you have already figured out. However if 'a' is less than or equal to the maximum allowed acceleration then you have a distance constrain and this calculation will provide you with the correct values.
Just keep in mind that all the equations are for half of the trip. So the max acceleration on the slowdown part would be -a, and the total time would 2*t, and you must make sure that that when finding time x=(1/2)d.
However in that final equation I wrote, 'd' is the full distance, not half the distance.