Extract the number of features in an object.
number_of_features(x)
# S4 method for ProjectProblem
number_of_features(x)
# S4 method for OptimizationProblem
number_of_features(x)
ProjectProblem or OptimizationProblem object.
integer
number of features.
# load data
data(sim_projects, sim_features, sim_actions)
# build problem with default solver
p <- problem(sim_projects, sim_actions, sim_features,
"name", "success", "name", "cost", "name") %>%
add_max_richness_objective(budget = 200) %>%
add_binary_decisions() %>%
add_default_solver()
# print problem
print(p)
#> Project Prioritization Problem
#> actions F1_action, F2_action, F3_action, ... (6 actions)
#> projects F1_project, F2_project, F3_project, ... (6 projects)
#> features F1, F2, F3, ... (5 features)
#> action costs: min: 0, max: 103.22583
#> project success: min: 0.81379, max: 1
#> objective: Maximum richness objective [budget (200)]
#> targets: none
#> weights: default
#> decisions Binary decision
#> constraints: <none>
#> solver: Gurobi [first_feasible (0), gap (0), number_solutions (1), presolve (2), solution_pool_method (2), threads (1), time_limit (2147483647), time_limit (2147483647), verbose (1)]
# print number of features
number_of_features(p)
#> [1] 5