|
| 1 | +using BenchmarkTools |
| 2 | +using AirspeedVelocity |
| 3 | +using ComputerAdaptiveTesting |
| 4 | +using Random: Xoshiro, sample |
| 5 | +using StatsBase: sample |
| 6 | +using FittedItemBanks |
| 7 | +using FittedItemBanks.DummyData: dummy_full, SimpleItemBankSpec, StdModel4PL |
| 8 | +using ComputerAdaptiveTesting.Aggregators |
| 9 | +using PsychometricsBazaarBase.Optimizers |
| 10 | +using PsychometricsBazaarBase.Integrators: even_grid |
| 11 | +using ComputerAdaptiveTesting.NextItemRules: mirtcat_quadpts |
| 12 | +using ComputerAdaptiveTesting.NextItemRules: DistributionExpectationBasedItemCriterion, |
| 13 | + PointExpectationBasedItemCriterion |
| 14 | +using ComputerAdaptiveTesting.NextItemRules |
| 15 | +using ComputerAdaptiveTesting.Responses |
| 16 | + |
| 17 | +const SUITE = BenchmarkGroup() |
| 18 | + |
| 19 | +SUITE["next_item_rules"] = BenchmarkGroup() |
| 20 | + |
| 21 | +#prepare_0(ability_estimator) |
| 22 | +function prepare_4pls(group) |
| 23 | + rng = Xoshiro(42) |
| 24 | + (; item_bank, abilities, responses) = dummy_full( |
| 25 | + rng, |
| 26 | + SimpleItemBankSpec(StdModel4PL(), OneDimContinuousDomain(), BooleanResponse()); |
| 27 | + num_questions = 20, |
| 28 | + num_testees = 1 |
| 29 | + ) |
| 30 | + integrator = even_grid(-6.0, 6.0, mirtcat_quadpts(1)) |
| 31 | + optimizer = AbilityOptimizer(OneDimOptimOptimizer(-6.0, 6.0, NelderMead())) |
| 32 | + |
| 33 | + dist_ability_estimator = PriorAbilityEstimator() |
| 34 | + ability_estimators = [ |
| 35 | + ("mean", MeanAbilityEstimator(dist_ability_estimator, integrator)), |
| 36 | + ("mode", ModeAbilityEstimator(dist_ability_estimator, optimizer)) |
| 37 | + ] |
| 38 | + response_idxs = sample(rng, 1:20, 10) |
| 39 | + |
| 40 | + for (est_nick, ability_estimator) in ability_estimators |
| 41 | + next_item_rule = ItemStrategyNextItemRule( |
| 42 | + ExhaustiveSearch1Ply(), |
| 43 | + PointExpectationBasedItemCriterion(ability_estimator, |
| 44 | + AbilityVarianceStateCriterion( |
| 45 | + integrator, distribution_estimator(ability_estimator))) |
| 46 | + ) |
| 47 | + next_item_rule = preallocate(next_item_rule) |
| 48 | + tracked_responses = TrackedResponses(BareResponses(ResponseType(item_bank)), |
| 49 | + item_bank, |
| 50 | + NullAbilityTracker()) |
| 51 | + group["$(est_nick)_point_mepv_bare"] = @benchmark ($next_item_rule)( |
| 52 | + $tracked_responses, $item_bank) |
| 53 | + bare_responses = BareResponses( |
| 54 | + ResponseType(item_bank), |
| 55 | + response_idxs, |
| 56 | + # XXX: Not sure why this is needed (seems to not be needed else) |
| 57 | + collect(responses[response_idxs, 1]) |
| 58 | + ) |
| 59 | + tracked_responses = TrackedResponses( |
| 60 | + bare_responses, |
| 61 | + item_bank, |
| 62 | + NullAbilityTracker()) |
| 63 | + group["$(est_nick)_point_mepv_10"] = @benchmark ($next_item_rule)( |
| 64 | + $tracked_responses, $item_bank) |
| 65 | + end |
| 66 | + return group |
| 67 | +end |
| 68 | + |
| 69 | +SUITE["next_item_rules"]["4pl"] = prepare_4pls(BenchmarkGroup()) |
0 commit comments