Skip to content

Commit

Permalink
Merge pull request #78 from jeremiahpslewis/jpsl/hook-fix
Browse files Browse the repository at this point in the history
Add more detailed testsets, hook cleanup
  • Loading branch information
jeremiahpslewis authored Mar 30, 2024
2 parents 75ab8e2 + 4cf461a commit a091ac9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
[compat]
AlgebraOfGraphics = "0.6"
CSV = "0.10"
Chain = "0.6"
CairoMakie = "0.11"
Chain = "0.6"
CircularArrayBuffers = "0.1.12"
DataFrameMacros = "0.4"
DataFrames = "1.6"
Expand Down
21 changes: 11 additions & 10 deletions src/DDDC2023/hooks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,32 @@ struct DDDCTotalRewardPerLastNEpisodes <: AbstractHook
end

function Base.push!(h::DDDCTotalRewardPerLastNEpisodes,
env::E,
memory::DDDCMemory,
player::Player
) where {E<:AbstractEnv}
push!(h.rewards, reward(env, player))
reward::Float64,
memory::DDDCMemory
)
push!(h.rewards, reward)
push!(h.demand_state_high_vect, memory.demand_state == :high)
return
end

function Base.push!(
h::DDDCTotalRewardPerLastNEpisodes,
::PostActStage,
agent::P,
env::E,
env::DDDCEnv,
player::Player,
) where {P<:AbstractPolicy,E<:AbstractEnv}
push!(h, env, env.memory, player)
) where {P<:AbstractPolicy}
push!(h, reward(env, player), env.memory)
return
end

function Base.push!(
hook::DDDCTotalRewardPerLastNEpisodes,
stage::Union{PreEpisodeStage,PostEpisodeStage,PostExperimentStage},
agent::P,
env::E,
env::DDDCEnv,
player::Player,
) where {P<:AbstractPolicy,E<:AbstractEnv}
) where {P<:AbstractPolicy}
push!(hook, stage, agent, env)
return
end
Expand Down
29 changes: 18 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,22 @@ using AlgorithmicCompetition:
using Distributed

@testset "AlgorithmicCompetition.jl" begin
include("alpha_beta.jl")
include("stochastic_demand_stochastic_information.jl")
include("competitive_equilibrium.jl")
include("hooks.jl")
include("explorer.jl")

include("tabular_approximator.jl")
include("q_learning.jl")
include("policy.jl")
include("integration.jl")
include("aiapc_conversion_check.jl")
@testset "Paramter tests" begin
include("alpha_beta.jl")
include("stochastic_demand_stochastic_information.jl")
include("competitive_equilibrium.jl")
end
@testset "RL.jl structs" begin
include("hooks.jl")
include("explorer.jl")
include("tabular_approximator.jl")
include("q_learning.jl")
include("policy.jl")
end
@testset verbose = true "Integration tests" begin
include("integration.jl")
end
@testset "Output tests" begin
include("aiapc_conversion_check.jl")
end
end

0 comments on commit a091ac9

Please sign in to comment.