I am having a hard time creating a asymmetric cost function with one parameter
the problem goes that it cost $1 to make juice and you sell it for $3. making too little result in $2 loss per glass could've sold but didn't. Decide to make excess which results in selling 8,9,9,13,13,16 in 6 days. The goal is to find how much to make a day to maximize profit
I tried
juice = data.frame(d=c(1,2,3,4,5,6), s=c(8,9,9,12,12,17)) asym <- function(params, x, y){ le <- (y- {params[1] - params[2]*x) ale <- abs(le) ale[le>0} <-3 * ale[le>0] sum(ale) I am trying to create one parameter instead of two and that looks at the x's which would be the number sold those days. I thinking of just having x as the amount sold, for the only thing in the vector but my issue is how would I create a function that will work when I try to use optim() with just having 1 parameter?
https://stackoverflow.com/questions/66083577/create-asymmetric-cost-function-with-one-parameter February 07, 2021 at 09:03AM
没有评论:
发表评论