Why Does Pyomo Behavior Change When Passing parameters to constraint function?
问题 This code works correctly. def m(model, i): return model.fd_amt[i] <= getattr(model, 'br_sa_ind')[i] * global_m setattr(model, ind+"_m",Constraint(model.br_standalone_I, rule=m)) But this def m(model, i, ind_name): return model.fd_amt[i] <= getattr(model, ind_name)[i] * global_m setattr(model, ind+"_m",Constraint(rule=m(model,model.model.br_standalone_I, 'br_sa_ind') )) results in this error: ERROR: evaluating expression: No value for uninitialized NumericValue object fd_amt[br_standalone_I]