If you mean how the AI decides whether to engage a particular army stack, then it seems as though the AI factors in pretty much everything you've listed. For example, I had a 2/1/0 stack in an occupied province with a pretty good general. The AI had a 3/1/0 stack, also with a pretty good general. That was the AI's entire force on the continent. The AI didn't attack. My general died; AI immediately moved to attack. When I put a new commander in charge of that stack, the AI stopped mid-move and decided to wait again.
The deciding factor seems to be the odds of success. The AI won't willingly walk into battles it knows it will lose, and it will usually try to avoid taking unnecessary casualties. However, the AI seems to only consider the number of pips, rather than their distribution, which can be exploited in some situations.
The AI should in theory do the same for fleets, but AI control of fleets is rather wonky. For example, I've noticed that the AI will very rarely stop its ships mid-move, which can lead to all sorts of silly results and makes ambushing AI fleets extremely easy. Once you see an AI-controlled fleet start to move in a certain direction, you can usually figure out where they will be a few days later; so long as your fleet doesn't arrive before the AI starts its move into the target province, you can drop on top of the AI.
For example, I blockaded the Straits of Gibraltar with twenty or so heavy ships; AI had a six-ship fleet moving into that same zone when my fleet arrived. An AI army would have stopped. The AI fleet suicided right into my blockade.