Find a list of actions that result in desired state
It depends on what the rules are.  For your particular rules, this can be handled very simply by counting the number of events of each type seen in the given time window; then predictActions can easily compute the additional number of each type of action needed.