This does not solve for the full solution, just the targeting queue, individual position on queue.
ffp_opt_sobin_rev(
ar_queue_optimal,
ar_bin_observed,
ar_A,
ar_alpha,
ar_beta,
fl_rho
)
optimal targeting array index of ranking from 1 to N targetting queue
observed vector of binary zeros and ones
float array of expected effect of provision for each i of N
float array of planner bias
string name of the A_i variable, any nonlinear or linear evaluated expected outcome
float preference for equality for the planner, negative infinity to 1
an float value for resource equivalent variation, see Theorem 1
https://fanwangecon.github.io/PrjOptiAlloc/reference/ffp_opt_sobin_rev.html https://fanwangecon.github.io/PrjOptiAlloc/articles/ffv_opt_sobin_rev.html
library(tibble)
library(dplyr)
library(tidyr)
fl_rho <- -1
ar_alpha <- c(0.1,1.5,2.5,4 ,9,1.2,3,2,8)
ar_A <- c(0.5,1.5,3.5,6.5,1.9,3,4,6,4)
ar_beta <- rep(0, length(ar_A)) + 1/length(ar_A)
mt_alpha_A <- cbind(ar_alpha, ar_A, ar_beta)
ar_st_varnames <- c('alpha', 'A', 'beta')
tb_alpha_A <- as_tibble(mt_alpha_A) %>% rename_all(~c(ar_st_varnames))
tb_alpha_A
#> # A tibble: 9 x 3
#> alpha A beta
#> <dbl> <dbl> <dbl>
#> 1 0.1 0.5 0.111
#> 2 1.5 1.5 0.111
#> 3 2.5 3.5 0.111
#> 4 4 6.5 0.111
#> 5 9 1.9 0.111
#> 6 1.2 3 0.111
#> 7 3 4 0.111
#> 8 2 6 0.111
#> 9 8 4 0.111
ar_rho <- c(-1)
for (it_rho_ctr in seq(1,length(ar_rho))) {
fl_rho <- ar_rho[it_rho_ctr]
ls_ranks <- ffp_opt_sobin_target_row(tb_alpha_A[1,], fl_rho, ar_A, ar_alpha, ar_beta)
it_rank <- ls_ranks$it_rank
ar_it_rank <- ls_ranks$ar_it_rank
ar_fl_rank_val <- ls_ranks$ar_fl_rank_val
cat('fl_rho:', fl_rho, 'ar_it_rank:', ar_it_rank, '\n')
}
#> fl_rho: -1 ar_it_rank: 3 2 5 8 1 7 6 9 4
ar_bin_observed <- c(0,1,0,1,0,0,1,1,0)
ar_queue_optimal <- ar_it_rank
ffp_opt_sobin_rev(ar_queue_optimal, ar_bin_observed, ar_A, ar_alpha, ar_beta, fl_rho)
#> [1] 0.25