I have the following function which i maximize using optim().
Budget = 2000
X = 4
Y = 5
min_values = c(0.3,0)
start_values = c(0.3,0.5)
max_values = c(1,1)
sample_function <- function(z,Spend){
Output = (z[1]*X*Spend) + (z[2]*Y*Spend)
return(Output)
}
MaxFunction <- optim(par=start_values ,fn= sample_function, method = "L-BFGS-B", lower = min_values , upper= max_values ,control=list(maxit=100000 ,fnscale=-1), Spend= Budget)
However i would like to add some constraints when maximizing such as:
z[1] => 1/3
and
z[1] + z[2] = 1
Any help will much be appreciated since this is linked to a more complicated problem that i'm tackling. Or if there's a different method for solving the problem without using otpim() please let me know.