Compute constraint values for each tag_outcomes, used for the optimisation algorithm. The computation is based on constraint coefficients, where the basis to multiply the coefficients are total contribution (either raw or standardized).
Arguments
- data_total_contrib
A dataframe where total contribution (raw or standardised) for each
tag_outcome
is stored- data_constr_coef
A dataframe of lower and upper constraint coefficients for each
tag_outcome
Examples
diet_selected <- select_diet(data_diet = all_diet,
tag_food = c('Bread', 'Vegetables', 'Red meat'))
cpu_selected <- select_perunit(data_perunit_contrib = contrib_per_unit,
tag_food = c('Bread', 'Vegetables', 'Red meat'),
tag_outcome = c('energy', 'protein', 'ghge'))
tc <- compute_total_contrib(data_diet = diet_selected,
data_perunit_contrib = cpu_selected)
constr_coef_df <- set_constr_coef(tag_outcome = c('energy', 'protein', 'ghge'),
coef_lwr = rep(0.9, 3),
coef_upr = rep(1.0, 3))
# reduce ghge to 0.9
constr_coef_df_red <- reduce_constr(data_constr_coef = constr_coef_df,
tag_outcome_reduce = 'ghge',
coef_reduce = 0.9)
compute_constr(data_total_contrib = tc$total_contrib,
data_constr_coef = constr_coef_df_red)
#> tag_outcome total_contrib coef_constrlwr coef_construpr constr_lwr
#> 1 energy 3327.249302 0.90 1.0 2994.524372
#> 2 protein 41.442989 0.90 1.0 37.298690
#> 3 ghge 2.006292 0.81 0.9 1.625096
#> constr_upr
#> 1 3327.249302
#> 2 41.442989
#> 3 1.805662