CountItem(cp);
208 Testing Systems with Complex State
reward += ((double)newC / (double)(newC + oldC));
}
return reward;
}
}
Notice the special case when GetCoverage always returns a bag with a single
coverage point p, for example, if GetVocabularyCoverage is being used as the
GetCoverage function. The reward will in this case be 1/(1 + m), where m is the
number of times that p has been visited before.
Finally, we need to override the method DoAction that records that a given action
is taken, because it needs to update the state variable coveragePoints by including
all the newcoverage points and by increasing the counts of all the previously covered
coverage points.
partial class CustomStrategy
{
public override void DoAction(Action a)
{
coveragePoints = coveragePoints.Union(GetCoverage(CurrentState, a));
base.DoAction(a);
}
}
In order to illustrate the effect of using GetVocabularyCoverage, let us add the
statement
Console.WriteLine("reward: " + bestRewardSoFar + " actions: "
+ bestActionsSoFar);
right before the return statement of the SelectAction method. We also need to
provide a creator method for the custom strategy. Assume also that the custom
strategy has been compiled into an assembly CustomStrategy.dll and uses the
namespace CustomStrategy. Consider the following settings for ct defined in a
settings file named args.txt.
# references
/r:BagModel.
Pages:
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281