tee: multiple output destinations
The tee driver duplicates output into up to 6 files simultaneously. It is particularly useful for creating output log files while still being able to watch progress output on screen. If we wish to maintain screen display and at the same time log the output in the file burglarsol.txt for the example burglar2ff.mos from Section Alternative text data file formats we may use the following Mosel code:
fopen("tee:burglarsol.txt&", F_OUTPUT+F_APPEND) writeln("Solution:\n Objective: ", getobjval) forall(i in ITEMS) writeln(" take(", i, "): ", getsol(take(i))) fclose(F_OUTPUT)
The tee driver also works with the library functions, such as to duplicate all the output generated by a model (output to a file and on screen, Mosel C libraries):
XPRMsetdefstream(mod, XPRM_F_WRITE, "tee:burglarlog.txt&");
Analogously with other library interfaces, such as the Mosel Java library:
mod.setDefaultStream(XPRM.F_OUTPUT, "tee:burglarlog.txt&");