How to save (pickle) a model instance in pyomo
问题 I want to create a model instance and then save it so I can load and solve at a later time (the initialization takes quite long compared to the solving). When I tried this it gave me the following error. with open('model.pickle', 'w') as f: pickle.dump(instance, f) AttributeError: Can't pickle local object 'Euphemia. init ..obj_expression The objective function is this: def obj_expression(model): curve = sum(model.x[area, hour, Type, index] * model.Q[area, hour, Type, index] * ( model.P1[area