I want to "debug" my pyomo model. The output of the model.pprint()
method looks helpful but it is too long so the console only displays and stores the last lines. How can I see the first lines. And how can I store this output in a file
(I tried pickle, json, normal f.write
but since the output of .pprint()
is of type NONE
I wasn't sucessfull until now. (I am also new to python and learning python and pyomo in parallel).
None of this works : '''
with open('some_file2.txt', 'w') as f:
serializer.dump(x, f)
import pickle
object = Object()
filehandler = open('some_file', 'wb')
pickle.dump(x, filehandler)
x = str(instance)
x = str(instance.pprint())
f = open('file6.txt', 'w')
f.write(x)
f.write(instance.pprint())
f.close()
Use the filename
keyword argument to the pprint
method:
instance.pprint(filename='foo.txt')