22 const DAP = DecisionFocusedLearningBenchmarks. DynamicAssortment
33end
44
5- @testitem " DynamicAssortment - Benchmark Construction" setup= [Imports, DAPSetup] begin
5+ @testitem " DynamicAssortment - Benchmark Construction" setup = [Imports, DAPSetup] begin
66 # Test default constructor
77 b = DynamicAssortmentBenchmark ()
88 @test b. N == 20
1313 @test ! is_exogenous (b)
1414
1515 # Test custom constructor
16- b_custom = DynamicAssortmentBenchmark (N= 10 , d= 3 , K= 2 , max_steps= 50 , exogenous= true )
16+ b_custom = DynamicAssortmentBenchmark (; N= 10 , d= 3 , K= 2 , max_steps= 50 , exogenous= true )
1717 @test b_custom. N == 10
1818 @test b_custom. d == 3
1919 @test b_custom. K == 2
2828 @test DAP. max_steps (b) == 80
2929end
3030
31- @testitem " DynamicAssortment - Instance Generation" setup= [Imports, DAPSetup] begin
32- b = DynamicAssortmentBenchmark (N= 5 , d= 3 , K= 2 )
31+ @testitem " DynamicAssortment - Instance Generation" setup = [Imports, DAPSetup] begin
32+ b = DynamicAssortmentBenchmark (; N= 5 , d= 3 , K= 2 )
3333 rng = MersenneTwister (42 )
3434
3535 instance = DAP. Instance (b, rng)
5353 @test DAP. prices (instance) == instance. prices
5454end
5555
56- @testitem " DynamicAssortment - Environment Initialization" setup= [Imports, DAPSetup] begin
57- b = DynamicAssortmentBenchmark (N= 5 , d= 2 , K= 2 , max_steps= 10 )
56+ @testitem " DynamicAssortment - Environment Initialization" setup = [Imports, DAPSetup] begin
57+ b = DynamicAssortmentBenchmark (; N= 5 , d= 2 , K= 2 , max_steps= 10 )
5858 instance = DAP. Instance (b, MersenneTwister (42 ))
5959
6060 env = DAP. Environment (instance; seed= 123 )
8080 @test DAP. prices (env) == instance. prices
8181end
8282
83- @testitem " DynamicAssortment - Environment Reset" setup= [Imports, DAPSetup] begin
84- b = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 , max_steps= 5 )
83+ @testitem " DynamicAssortment - Environment Reset" setup = [Imports, DAPSetup] begin
84+ b = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 , max_steps= 5 )
8585 instance = DAP. Instance (b, MersenneTwister (42 ))
8686 env = DAP. Environment (instance; seed= 123 )
8787
107107 @test env. features ≈ expected_features
108108end
109109
110- @testitem " DynamicAssortment - Hype Update Logic" setup= [Imports, DAPSetup] begin
111- b = DynamicAssortmentBenchmark (N= 5 , d= 1 , K= 2 )
110+ @testitem " DynamicAssortment - Hype Update Logic" setup = [Imports, DAPSetup] begin
111+ b = DynamicAssortmentBenchmark (; N= 5 , d= 1 , K= 2 )
112112 instance = DAP. Instance (b, MersenneTwister (42 ))
113113 env = DAP. Environment (instance; seed= 123 )
114114
135135 @test all (hype .== 1.0 ) # Should not affect any item hype
136136end
137137
138- @testitem " DynamicAssortment - Choice Probabilities" setup= [Imports, DAPSetup] begin
139- b = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 )
138+ @testitem " DynamicAssortment - Choice Probabilities" setup = [Imports, DAPSetup] begin
139+ b = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 )
140140 instance = DAP. Instance (b, MersenneTwister (42 ))
141141 env = DAP. Environment (instance; seed= 123 )
142142
167167 @test probs[4 ] ≈ 1.0 # Only no-purchase available
168168end
169169
170- @testitem " DynamicAssortment - Expected Revenue" setup= [Imports, DAPSetup] begin
171- b = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 )
170+ @testitem " DynamicAssortment - Expected Revenue" setup = [Imports, DAPSetup] begin
171+ b = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 )
172172 instance = DAP. Instance (b, MersenneTwister (42 ))
173173 env = DAP. Environment (instance; seed= 123 )
174174
183183 @test revenue == 0.0 # Only no-purchase available with price 0
184184end
185185
186- @testitem " DynamicAssortment - Environment Step" setup= [Imports, DAPSetup] begin
187- b = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 , max_steps= 5 )
186+ @testitem " DynamicAssortment - Environment Step" setup = [Imports, DAPSetup] begin
187+ b = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 , max_steps= 5 )
188188 instance = DAP. Instance (b, MersenneTwister (42 ))
189189 env = DAP. Environment (instance; seed= 123 )
190190
219219 @test_throws AssertionError step! (env, assortment)
220220end
221221
222- @testitem " DynamicAssortment - Endogenous vs Exogenous" setup= [Imports, DAPSetup] begin
222+ @testitem " DynamicAssortment - Endogenous vs Exogenous" setup = [Imports, DAPSetup] begin
223223 # Test endogenous environment (features change with purchases)
224- b_endo = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 , exogenous= false )
224+ b_endo = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 , exogenous= false )
225225 instance_endo = DAP. Instance (b_endo, MersenneTwister (42 ))
226226 env_endo = DAP. Environment (instance_endo; seed= 123 )
227227
232232 @test any (env_endo. d_features .!= 0.0 ) # Delta features should be non-zero
233233
234234 # Test exogenous environment (features don't change with purchases)
235- b_exo = DynamicAssortmentBenchmark (N= 3 , d= 1 , K= 2 , exogenous= true )
235+ b_exo = DynamicAssortmentBenchmark (; N= 3 , d= 1 , K= 2 , exogenous= true )
236236 instance_exo = DAP. Instance (b_exo, MersenneTwister (42 ))
237237 env_exo = DAP. Environment (instance_exo; seed= 123 )
238238
243243 @test all (env_exo. d_features .== 0.0 ) # Delta features should remain zero
244244end
245245
246- @testitem " DynamicAssortment - Observation" setup= [Imports, DAPSetup] begin
247- b = DynamicAssortmentBenchmark (N= 3 , d= 2 , max_steps= 10 )
246+ @testitem " DynamicAssortment - Observation" setup = [Imports, DAPSetup] begin
247+ b = DynamicAssortmentBenchmark (; N= 3 , d= 2 , max_steps= 10 )
248248 instance = DAP. Instance (b, MersenneTwister (42 ))
249249 env = DAP. Environment (instance; seed= 123 )
250250
@@ -266,10 +266,10 @@ end
266266 @test obs1 != obs2 # Observations should differ after purchase
267267end
268268
269- @testitem " DynamicAssortment - Policies" setup= [Imports, DAPSetup] begin
269+ @testitem " DynamicAssortment - Policies" setup = [Imports, DAPSetup] begin
270270 using Statistics: mean
271271
272- b = DynamicAssortmentBenchmark (N= 5 , d= 2 , K= 3 , max_steps= 20 )
272+ b = DynamicAssortmentBenchmark (; N= 5 , d= 2 , K= 3 , max_steps= 20 )
273273
274274 # Generate test data
275275 dataset = generate_dataset (b, 10 ; seed= 0 )
307307 @test sum (greedy_action) == DAP. assortment_size (env)
308308end
309309
310- @testitem " DynamicAssortment - Model and Maximizer Integration" setup= [Imports, DAPSetup] begin
311- b = DynamicAssortmentBenchmark (N= 4 , d= 3 , K= 2 )
310+ @testitem " DynamicAssortment - Model and Maximizer Integration" setup = [Imports, DAPSetup] begin
311+ b = DynamicAssortmentBenchmark (; N= 4 , d= 3 , K= 2 )
312312
313313 # Test statistical model generation
314314 model = generate_statistical_model (b; seed= 42 )
317317
318318 # Test integration with sample data
319319 sample = generate_sample (b, MersenneTwister (42 ))
320- @test hasfield (typeof (sample), :instance )
320+ @test hasfield (typeof (sample), :info )
321321
322322 dataset = generate_dataset (b, 3 ; seed= 42 )
323323 environments = generate_environments (b, dataset)
0 commit comments