Solves a linear programming model for resource allocation in agro-pastoral systems.

ram_optimize(profit, resource_use, availability)

Arguments

profit

Numeric vector. Profit (or objective coefficient) for each activity.

resource_use

Matrix. Rows = resources, Columns = activities. Each entry gives the use of resource per activity unit.

availability

Numeric vector. Total available amount for each resource (must match number of rows in resource_use).

Value

A list with:

optimal_activities

Named vector of optimal activity levels

max_profit

Optimal value of the objective function

status

Status code from lpSolve (0 = success)

Examples

profit <- c(20, 25)
resource_use <- matrix(c(1, 2, 2, 3, 3, 0), nrow = 3, byrow = TRUE)
rownames(resource_use) <- c("land", "labor", "feed")
colnames(resource_use) <- c("grazing", "haymaking")
availability <- c(100, 200, 300)
names(availability) <- rownames(resource_use)
ram_optimize(profit, resource_use, availability)
#> $optimal_activities
#>   grazing haymaking 
#>       100         0 
#> 
#> $max_profit
#> [1] 2000
#> 
#> $status
#> [1] 0
#>