I am running the following JModelica script:
#!/usr/local/jmodelica/bin/jm_python.sh
import pyjmi
op = pyjmi.transfer_optimization_problem("BatchReactor", "model.mop")
opt_opts = op.optimize_options()
opt_opts['n_e'] = 40 # Number of elements
opt_opts['IPOPT_options']['tol'] = 1e-10
opt_opts['IPOPT_options']['print_level'] = 8
opt_opts['IPOPT_options']['output_file'] = '/z/out'
res = op.optimize(options=opt_opts)
I had hoped that the results (e.g. time, x1, x2, &c.) would be printed to the file /z/out
. But the file only contains IPOPT verbose debugging/status info.
Is there a way to print the information that would be stored in res
directly to a file? Either by somehow writing res itself or, preferably, having IPOPT/JModelica write the results without having to go through Python?
You may find that using
result_file_name
per another answer here results in an output file which is difficult to understand.The following produces a nicer format:
which looks like this: