Pricew*Demandw + Pricesalvage*Inventoryfinal.
I want to optimize the former term on weekly basis and iteratively such that the optimal price for week,w, factors in the subsequent price/demand dynamics for subsequent weeks. The summary the mathematical objective is:
model = AbstractModel()
*******Params and Vars *******************
# Number of weeks
model.Wks = RangeSet(1,12)
# Salvage price
model.Psalv = Param(initialize=15)
# Inventory at end of week, w
model.Inv_end = Var(model.Wks, within=NonNegativeIntegers, bounds=(0,2000), initialize=inv)
# Demand in week, w
model.Wk_dmd = Var(model.Wks, within=NonNegativeIntegers, bounds=(0,2000))
#Price in week , w
model.Pwk = Var(model.Wks, within=NonNegativeReals, initialize=5)
*******Objective*******************
def objective_rule(model):
return sum((model.Wk_dmd[w]*model.Pwk[w] for w in model.Wks) + model.Psalv * model.Inv_end[12])
model.objective = Objective(rule=objective_rule, sense=maximize)
************Constraints**********************
def Dmd_dynamics_rule(model, w):
###Calcs demand for given week###
if w == 1:
return model.Wk_dmd[w] == inv*.15
else:
# Main demand equation
return model.Wk_dmd[w] == model.Wk_dmd[w-1]*.3+og_ct*.001+30*(200/age)+.01*inv+2000/model.Pwk[w] #vars og_ct, age, and inv are global vats
model.Dmd_dynamics = Constraint(model.Wks,rule=Dmd_dynamics_rule)
def Inv_dmd_dynam_rule(model, w):
### Prev w End inv is ceiling to current w demand###
if w > 1:
return (model.Wk_dmd[w] <= model.Inv_end[w-1])
return Constraint.Skip
model.Inv_dmd_dynam =Constraint(model.Wks, rule=Inv_dmd_dynam_rule)
def Price_dynam_rule(model, w):
###Price can not go up, only down###
if w > 1:
return model.Pcrrnt[w] <= model.Pcrrnt[w-1]
return Constraint.Skip
model.Price_dynam = Constraint(model.Wks,rule=Price_dynam_rule)
def Calc_inv(model, w):
### Calculates Ending inventory in week, w ###
if w > 1:
return model.Inv_end[w] == model.Inv_end[w-1] - model.Wk_dmd[w]
return Constraint.Skip
model.Inv_end_dynamics = Constraint(model.Wks, rule=Calc_inv).
A couple takeaways from the solver results that I thought were peculiar:
- Objective is listed as 'None' in the suffix declarations
- 'sense' is showing as 'unknown' though i specify sense=maximize in the objective function
- The solution appears to stop after only 1 iteration through the vars specifying "Maximum Number of Iterations Exceeded". How do I increase this.
- My Inv_End value starts at 7.99673555664e+13 despite an upper bound of 2,000
Here is some additional detail on the solution output below:
= Solver Results =
# ==========================================================
# ----------------------------------------------------------
# Problem Information
# ----------------------------------------------------------
Problem:
- Lower bound: -inf
Upper bound: inf
Number of objectives: 1
Number of constraints: 21
Number of variables: 18
Sense: unknown
# ----------------------------------------------------------
# Solver Information
# ----------------------------------------------------------
Solver:
- Status: warning
Message: Ipopt 3.11.9\x3a Maximum Number of Iterations Exceeded.
Termination condition: maxIterations
Id: 400
Error rc: 0
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
Solution:
- number of solutions: 1
number of solutions displayed: 1
- Status: stoppedByLimit
Message: Ipopt 3.11.9\x3a Maximum Number of Iterations Exceeded.
Variable:
v0:
Id: 0
Value: 7.99673555664e+13
v1:
Id: 1
Value: 6.90382407242e+13
v2:
Id: 2
Value: 6.08140328328e+13
v3:
Id: 3
Value: 5.42863049624e+13
v4:
Id: 4
Value: 4.92201920122e+13
v5:
Id: 5
Value: 1.75848644786e+14
v6:
Id: 6
Value: 409.812936602
v7:
Id: 7
Value: 264.736414547
v8:
Id: 8
Value: 204.692700811
v9:
Id: 9
Value: 175.147505697
v10:
Id: 10
Value: 156.440929811
v11:
Id: 11
Value: 136.42489406
v12:
Id: 12
Value: 1999.99983144
v13:
Id: 13
Value: 1735.26341689
v14:
Id: 14
Value: 1530.57071608
v15:
Id: 15
Value: 1355.42321038
v16:
Id: 16
Value: 1198.98228057
v17:
Id: 17
Value: 1062.55738651
Constraint: No nonzero values
Status description: EXCEEDED MAXIMUM NUMBER OF ITERATIONS\x3a the solver was stopped by a limit that you set!