I am writing a Pyomo model and trying to code the following mathematical constraint:
$$ \sum_{i=1}^I\sum_{j=1}^J\sum_{t=1}^T 5I_{ijt} + 10L_{ijt}I_{ijt} $$ where $L_{ijt}$ is binary.
However, I am hoping that I could get someone to clarify if what I have written in my model makes sense:
def objective_rule(model):
return sum (sum (sum (model.obj[i,j,t] for i in model.Iset ) for j in model.Jset ) for t in model.Tset )
model.damages = Objective(rule=objective_rule, sense=minimize)
def obj_rule(model, i,j,t):
return model.obj[i,j,t] == 5*model.inf_b4treat[i,j,t] + 10 *model.level1[i,j,t]*model.inf_b4treat[i,j,t]
model.object = Constraint(model.Iset, model.Jset, model.Tset, rule=obj_rule)
I am getting a couple of strange results and having debugged my model I am thinking that it might be due to my objective function not being formatted properly. To clarify, the reason that I chose to create an additional object called model.obj[i,j,t] is so that I could access the objective function values after I solve the model.
I would appreciate any corrections.
sum(model.obj[i,j,t] for i in model.Iset for j in model.Jset for t in model.Tset)but it should be the same. Can you provide additional information on the other variables? What type are they and what bounds do they have? – JakobS Sep 19 '19 at 11:07