How to model exponential relations between two variables?
回答済みHello,
I want to model a dynamic pricing model with exponentially falling demand at a rising price (see picture). Demand is always above 0, as well as the price.


The price and the demand are variables. a and b are parameters.
I modeled in python with gurobi:
m = gp.Model("test")
price = m.addVar(vtype=GRB.CONTINUOUS, name="price", lb=0)
demand = m.addVar(vtype=GRB.CONTINUOUS, name="demand")
help = m.addVar(vtype=GRB.CONTINUOUS, name="help")
help_2 = m.addVar(vtype=GRB.CONTINUOUS, name="help_2")
m.update()
obj = price*20*demand
m.setObjective(obj, GRB.MAXIMIZE)
a = 10
b = 0.038
m.addConstr(a*help == demand)
m.addConstr(-b*price == help_2)
m.addGenConstrExp(help_2, help)
m.update()
m.params.FuncPieces = 1
m.params.FuncPieceLength = 1e-3
m.optimize()
As a result I get:
- price = 0
- demand = 10
- result obj. = 0 (which is not the maximum, as with a rising price, the objective could increase)
Where is the problem?
Additional:
If I model a linear demand curve it works perfectly fine and determines the optimal price.
Constraint that works:
m.addConstr(a - b * price[t, j] == demand[t, j, q])
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Jessica,
The default lower bound for variables in Gurobi is set to 0. However, in the exponential formulation, the variable \(\texttt{help_2}\) can become negative. Thus, setting
help_2 = m.addVar(vtype=GRB.CONTINUOUS, name="help_2", lb=-GRB.INFINITY)
should resolve the issue. Additionally, you should set an upper bound on variable \(\texttt{price}\). This is because a piecewise-linear approximation can only be performed correctly, if there are finite bounds given. Setting an upper bound of \(100\) for variable \(\texttt{price}\) seems good enough.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント