OptimResult will append data to file when writing x.
pass params by reference where possible