MW::QLearner Class Reference
List of all members.
Detailed Description
The QLearner runs various simulations in order to
come up with an evaluation function
It then lends this evaluation function to players in order
to help them make buying decisions
Member Function Documentation
| def MW::QLearner::__init__ |
( |
|
self, |
|
|
|
gameSize, |
|
|
|
useFile = 1, |
|
|
|
exploreFrac = 0.50, |
|
|
|
networks = None | |
|
) |
| | |
Initializes a new QLearning agent, all it has to remember are the
parameters that it uses to evaluate the utility of various situations
| def MW::QLearner::evalAlpha |
( |
|
self, |
|
|
|
rawChange | |
|
) |
| | |
This function represents the amount by which the
coefficients for the evaluation function can change with
each iteration. There is a maxChange value so the
coefficients do not start to swing too wildly.
| def MW::QLearner::measurePerformance |
( |
|
self |
) |
|
This looks at all the trials that were run by the learner
and then returns the average performance of the learner
over all those trials. The first returned number in the
list is the average absolute error, whereas the second is
simply the summed error (measures if there is skew or if
the error is unbiased)
| def MW::QLearner::adjustSkew |
( |
|
self, |
|
|
|
skew | |
|
) |
| | |
This function adjusts for the skew observed in the
evaluation function after it has been tested. By skew
we mean the tendency of the evaluation function to
consistently underestimate or overestimate the rewards.
To do this, you just need to adjust the intercept,
represented by the first parameter
This is deprecated, skew was simply a function of not
running the evaluation function developer enough times
| def MW::QLearner::getDelta |
( |
|
self, |
|
|
|
player, |
|
|
|
num | |
|
) |
| | |
This is a helper to the Widrow-Huff formula,
given a parameter number and a player it determines
a multiple related to how much the evaluation
parameter under evaluation should change by. It
is also used by the evaluation function itself.
For instance, if a player has 2 neighbors and the
switch for the neighbor parameter is set to 2, then
the function should multiply the change by 4
| def MW::QLearner::evalFn |
( |
|
self, |
|
|
|
player | |
|
) |
| | |
This calculates the utility of a particular position
by multiplying each parameter value by the delta
and summing each value
| def MW::QLearner::updateEvalFn |
( |
|
self, |
|
|
|
game | |
|
) |
| | |
Takes in a finished game as a parameter and updates the
evaluation function accordingly, by going through each player
and comparing the reward with the utility
Rule for updating is as follows: param = param +
alpha * (reward + discount * max utility of all poss. actions - curUtil)
* partial derivative
This is the Widrow-Hoff rule
No discount factor since all moves are over a single time step
| def MW::QLearner::developEvalFn |
( |
|
self, |
|
|
|
trials | |
|
) |
| | |
This runs the QLearner for the inputted number of trials,
the more trials run, the better it learns, updating the
evaluation function using the Widrow-Hoff rule as it goes
| def MW::QLearner::testEvalFn |
( |
|
self, |
|
|
|
trials, |
|
|
|
constCost = 0 | |
|
) |
| | |
This simply sets the exploration fraction to zero
and runs the learner, while not continuing to update
the evaluation function. Then, it gathers statistics
from the running of the trials. Thus, this measures
the performance of the learner
| def MW::QLearner::calibrateParams |
( |
|
self |
) |
|
This function does the following in an iterative fashion
It starts of with a certain set of switches, and then
develops an evalFn based on those switches for
1000 trials. Then, it will uses testEvalFn to determine the efficacy
of the function.
To make things simple, it tests each parameter separately
At the end of the function, it sets paramSwitches
to whatever calibrated setting it believes is best
| def MW::QLearner::calibrateEdgeCosts |
( |
|
self |
) |
|
This method calibrates the edge costs by doing the following -
starting edge cost at 0 and raising it incrementally until
the aggregate money spent on edges equals the social wealth
gained through edge purchasing. This helps to answer
a question that I pose in my write-up
The documentation for this class was generated from the following file:
- C:/Documents and Settings/Tony/Desktop/workspace/MW/src/MW.py