Skip to contents

Make objective function based on current diet, used as inputs for the optimization.

Usage

f_make_objective_function(diet0, method = "ss")

Arguments

diet0

A vector of diet intake

method

Specify method to use to compute the objective function values. So far only 'ss' (sum of squares) is implemented.

Value

A function to be used in the optimization

Examples

# a demo example with 3 foods intakes
funobj <- f_make_objective_function(diet0 = c(187, 200, 55))
# to evaluate a new diet
funobj(x = c(187, 200, 50))
#> [1] 25