A 5/3 spool valve (as seen on the left) performs such that P is an input, T is an exhaust, and A & B are outputs.
We developed a Python script to take an initial, user-provided guess as to the size of the prime circle of the cam, and subsequently would run through a series of calculations to optimize the size according to machine design principles.