(This doesn't directly answer the Title question, but perhaps it gives you an idea of how it could be modeled.)
Physical
If everything is strictly physical, then free-will, consciousness, self-awareness, and other aspects of the mind are illusions, nothing but artefacts of electrochemical brain activity.
Everything we do, all our decisions, are determined by physical actions (electrical, chemical, and even mechanical).
Our decisions are causal and certain, though being a result of our immediate physical state, they are not necessarily predictable.
Consider an animal, such as a mouse.
Its brain continually receives various inputs:
- low blood sugar: hunger — look for food!
- smell: food — its nearby, find it.
- sight: round object with bells on it — familiar.
- memory: a similar object was soon followed by the appearance of a cat — run away!
- etc.
Some part of the brain receives all of these signals, each with its own level of urgency, and it reduces them to a single course of action:
- If the hunger is low, and the smell is weak, the cat memory will win and the mouse will go somewhere else.
- If the hunger is high and the smell is strong, the danger signal will be overruled, and the mouse will look for the food.
A decision has been made, but no thinking was required; the inputs could have been reduced to mathematical values and a formula applied to determine the best action to take.
(Consider the simplicity of Conway's Game of Life, or how little it takes to simulate the behaviour of schools of fish or flocks of birds.)
The same mechanism controls the actions of all animals, though at a much simpler level in some and at a much more complex level in others.
This includes humans, who have the most complex circuits, including an additional one that we call consciousness.
It's like a feed-back loop that observes the automatic decision making process, adds running commentary, and remembers it for future use.
It doesn't make decisions, but it does rationalize them.
Between stimulus and response there is a space. In that space is our power to choose our response. In our response lies our growth and our freedom.
But again, even this is still a result of purely physical reactions that could be mathematically modeled.
Even if one modeled some version of free-will choices, ultimately it would reduce to the final decision being made randomly (whether by the flip of a coin or the parity of the current time in microseconds).
Beyond Physical:
Some people though, believe that there is also a super-natural component to the human mind, one that cannot be explained in physical terms.
Free-will not only allows our minds to observe and rationalize, it also allows it to intervene.
All the sensory inputs, including memory, may strongly indicate one course of action, but the mind is able to override this gut-instinct natural choice, and it can decide to do something different (perhaps simply by providing a much stronger input to the decision making mechanism).
It may later rationalize or explain its choice, and it may store this decision and its result in memory, but the fact is that this added non-physical component caused the person to do one thing when all natural instincts and experience were saying to do otherwise.
This of course still doesn't explain how the free-will decision was made.
This super-natural aspect is central to effectively all religions.
Some call it a "soul", some call it a "spirit", some an "inner self", some a "thetan", and some an "ego" (as opposed to the instinctual "id").
Various beliefs exist about it:
- Ancient Israelites believed in only one life, followed by non-existence.
- Catholics believe in only one life, but that after death the immortal soul is either eternally rewarded or eternally punished for one's behaviour.
- Some Christians believe that one's spirit must be improved by consciously building a character like God's.
- Hindus believe that after physical death, it is reincarnated in a better or worse host, depending upon karma accumulated in the current life.
- Buddhists believe in reincarnation, and that experiencing physical suffering and losing personal desires eventually leads to nirvana.
- Scientologists also believe in reincarnation, and that one must work to clear bad memories acquired from previous lives.
- etc.
The one common factor seems to be a goal of doing the best that one can do to improve oneself as a person, to build one's character so that it always makes the morally best choice.