'What counstants to choose to get correct answer with Rolling Horizon Planning Setting?

I wrote code to find a prod. amount during a rolling horizon. It works for a 12 weeks period but I want to solve it for 1 full year so that number of weeks is 52 weeks. Recommend where I should get an answer (books,forums).

Code:

from pyomo.environ import *

model = ConcreteModel()
model.T = RangeSet(12)  
#for 1 year period use - 52 range 

#Parameters
i0 = 5.0
c = 4.6
h_pos = 0.7
h_neg =1.2
P =5.0

d = {1: 5.0, 2: 7.0, 3: 6.2, 4: 3.1, 5: 1.7, 6: 4.0, 7: 1.2, 8: 9, 9:1.8, 10:6.7, 11:12, 12:3.2}
# this parameter should be changed!


          

model.y = Var(model.T, domain = Binary)
model.x = Var(model.T, domain=NonNegativeReals)
model.i =Var(model.T)
model.i_pos=Var(model.T, domain =NonNegativeReals)
model.i_neg=Var(model.T, domain=NonNegativeReals)

#Inventory Balance: subtract 
def inventory_rules(m,t):
        if t == m.T.first():
            return m.i[t] == i0 +m.x[t] - d[t]
        return m.i[t] == m.i[t-1] + m.x[t] - d[t]
model.inventory = Constraint(model.T, rule =inventory_rules)

def pos_neg_rule(m,t):
    return m.i[t] == m.i_pos[t] - m.i_neg[t]
model.pos_neg =Constraint(model.T, rule=pos_neg_rule)

def prod_indicator_rule(m,t):
    return m.x[t] <= P*m.y[t]
model.prod_indicator =Constraint(model.T, rule = prod_indicator_rule)


model.obj1=Objective(expr=sum(c*model.y[t] + h_pos*model.i_pos[t] + h_neg*model.i_neg[t] for t in model.T), sense=minimize)
solver = SolverFactory ('glpk')
solver.solve(model)

for t in model.T:
        print('Period: {0}, Prod.Amount: {1}'.format(t, value(model.x[t])))

I've got only one production amount, so that on my output, I see:

Period: 1, Prod.Amount: 5.0 
Period: 2, Prod.Amount: 5.0 
Period: 3, Prod.Amount: 5.0 
Period: 4, Prod.Amount: 5.0 
Period: 5, Prod.Amount: 5.0 
Period: 6, Prod.Amount: 5.0 
Period: 7, Prod.Amount: 5.0 
Period: 8, Prod.Amount: 5.0 
Period: 9, Prod.Amount: 5.0 
Period: 10, Prod.Amount: 5.0 
Period: 11, Prod.Amount: 5.0

At the 12 weeks period, I sometimes get a different prod.amount.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source