Skip to content

save_theta produces NULL in the history data result #28

Open

Description

@yanisvdc

Hi, thank you for this package,

When using

library(contextual)

horizon       <- 100L
simulations   <- 100L

bandit        <- ContextualLinearBandit$new(k = 4, d = 3, sigma = 0.3)

# Linear CMAB policies comparison

agents <- list(Agent$new(EpsilonGreedyPolicy$new(0.1), bandit, "EGreedy"),
               Agent$new(ContextualEpsilonGreedyPolicy$new(0.1), bandit, "cEGreedy"),
               Agent$new(ContextualLinTSPolicy$new(0.1), bandit, "LinTS"),
               Agent$new(LinUCBDisjointOptimizedPolicy$new(0.6), bandit, "LinUCB"))

simulation     <- Simulator$new(agents, horizon, simulations, do_parallel = TRUE, 
                                save_context=TRUE, save_theta=TRUE)

history        <- simulation$run()

plot(history, type = "cumulative", rate = FALSE, legend_position = "topleft")

result <- history$data

Why are some of the thetas in the result NULL? I believe that there is no theoretical reason for this and that it should be an error when writing the thetas in the result. Would anyone know how to fix this?

Thanks!

Activity

  1. yanisvdc commented on Feb 24, 2025

    @yanisvdc
    Author

    Solved this by using do_parallel = False

    simulation     <- Simulator$new(agents, horizon, simulations, do_parallel = FALSE,
                                    save_context=TRUE, save_theta=TRUE)
    

    It seems to be an issue with how parallelization returns the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions