LPSOLVE-查找最大值 - 具有乘法的公式
我正在寻找一种与我在Excel中成功使用的方式使用LPSOLDEL的方法。我已经计算了各种产品的弹性。根据产品是否是弹性,我想就要问的价格提出建议。
我有以下值:
current.price = 15
sales.lastmonth = 50
elasticity = -1.5
我想通过更改建议的公式来优化销售
。 弹性))
sales.prediction =(sales.lastmonth--((abs ( 尝试以下内容:
# install.packages("lpSolve")
library(lpSolve)
objective.fn <- c(sales.prediction) # determine what the objective is
# constrain sales.lastmonth and current.price
const.mat <- matrix(c(1,1),ncol=1,byrow=T)
const.dir <- c("=","=")
const.rhs <- c(sales.lastmonth, current.price)
lp("max",objective.fn,const.mat,const.dir,const.rhs,compute.sens=TRUE)
有什么建议吗?
-------------
编辑-V2:根据下面的评论,我想补充一下建议的限制。提价应最大25%的25%,低于25%建议我在没有优化的情况下的建议。例如,假设我已经在考虑将价格降低到12.5。这也可能吗?
I'm looking for a way to use lpSolve in a similar way to how I use it succesfully in Excel. I've calculated elasticity for various product. Based on whether a product is elasticity or not elastic I want to give an advice on which price to ask.
I have the following values:
current.price = 15
sales.lastmonth = 50
elasticity = -1.5
And I want to optimize the sales.prediction by changing the suggested.price
Formula:
sales.prediction = (sales.lastmonth - ((abs(elasticity)(suggested.price-current.price))(sales.lastmonth/current.price)))*suggested.price
I've tried the following:
# install.packages("lpSolve")
library(lpSolve)
objective.fn <- c(sales.prediction) # determine what the objective is
# constrain sales.lastmonth and current.price
const.mat <- matrix(c(1,1),ncol=1,byrow=T)
const.dir <- c("=","=")
const.rhs <- c(sales.lastmonth, current.price)
lp("max",objective.fn,const.mat,const.dir,const.rhs,compute.sens=TRUE)
Any suggestions?
-----------
EDIT - V2: Based on the comment below, I would like to add the constraint that the suggested.price should be at max 25% higher of 25% lower than the the suggested price I have in my mind without the optimization. For example, let's say I am already thinking about lowering the price to 12.5. Is that possible as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您只是尝试优化(最大化)此功能,则没有任何约束,因为您的变量是恒定的。如果这是真的,那么您可以
在7.5时进行最大值。
编辑:限制优化的一个简单hack是使用间隔参数,用于您的编辑
Interval = C(Current.Price*0.75,Current.Price*1.25)
。If I understand correctly you are simply trying to optimize (maximize) this function, there are no constraints since your variables are constant. If this is true then you can do
maximum at 7.5.
Edit: a simple hack to limit the optimization is to use the interval argument, for your edit
interval=c(current.price*0.75,current.price*1.25)
.