In python script, I have a loop, each loop I solve an ampl optimization problem. I want to store all variables for each optimization as follows: (k is the number of the current loop)
ampl.eval('display _varname, _var > ("/home/monpc/optimal_sizing/ampl_results/solution" & k & ".out");')
However I got this error:
File "/home/monpc/optimal_sizing/main.py", line 593, in <module>
ampl.eval('display _varname, _var > ("/home/monpc/optimal_sizing/ampl_results/solution" & k & ".out");')
File "/home/monpc/anaconda3/lib/python3.9/site-packages/amplpy/ampl.py", line 263, in eval
self._error_handler_wrapper.check()
File "/home/monpc/anaconda3/lib/python3.9/site-packages/amplpy/ampl.py", line 697, in check
raise exp
File "/home/monpc/anaconda3/lib/python3.9/site-packages/amplpy/ampl.py", line 681, in error
self.error_handler.error(exception)
File "/home/monpc/anaconda3/lib/python3.9/site-packages/amplpy/errorhandler.py", line 25, in error
raise exception
AMPLException: line 1 offset 0
syntax error
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ampl+uns...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ampl/85b93471-dc4e-43ad-9614-0e19e122fbd9n%40googlegroups.com.