Closed xrixhon closed 3 years ago
Hi Xavier,
That error comes for the underlying C++ API. Instead of ampl.readData(filename), could you please try ampl.readData(str(filename))?
Best regards, Filipe
Hello Filipe,
Unfortunately, it does not work much better. I'm not sure it comes from the name of the file as, if I comment all the lines of the .dat file, it is read properly. It should come from what's written in the file (like : let decom_allowed ['2015_2020' , '2010_2015' , 'NUCLEAR'] := 1;) but I don't know what it could be exactly and how to solve this?
If you have any other idea, I'd be glad to read and try it.
Thanks for your help,
Best regards,
Xavier
Hi Xavier,
Sorry, I had not noticed the "let" in "let decom_allowed ['2015_2020' , '2010_2015' , 'NUCLEAR'] := 1;". "let" commands are part of models, not data. You can see the data format at https://ampl.com/BOOK/CHAPTERS/12-data.pdf. Instead of ampl.readData('PESTD_data_decom_allowed.dat'), could you please try ampl.read('PESTD_data_decom_allowed.dat')?
Hello Filipe,
Once again it is not the issue :s. Strangely, I've been able to run my code previously with a similar file but from now on, I've got this bug "out of nowhere"? Would you have any other idea to figure it out?
Thanks in advance for your quick response and your support,
Best regards,
Xavier
Hi Xavier,
Could you please send all the files necessary to reproduce this issue to support@ampl.com?
If that is not possible, you can add the following right after instantiating the AMPL object:
ampl._startRecording('session.log')
ampl.setOption('_log_input_only', False)
This will produce a file session.log
that should show what happened right before the exception was thrown.
Hello Filipe,
Thank you so much for your help. Generating the log helped to identify what was the issue. I was allocating the PESTD_data_decom_allowed.dat file before instantiating the parameter used in this file. It resulted in this no-clue-giving error TypeError: basic_string whereas the log file helped to identify the actual issue.
Thanks again for your help and your support,
Best regards,
Xavier
Hello,
When I set up my ampl problem, I encounter an issue reading one specific file called "PESTD_data_decom_allowed.dat" (all the other files seem to be read flawlessly). Here is the error that comes out:
File "/Users/xrixhon/.pyenv/versions/3.7.6/lib/python3.7/site-packages/amplpy/ampl.py", line 559, in readData self._impl.readData(filename)
TypeError: basic_string
I searched through the source code of amplpy but couldn't figure it out. Could you please help me?
To be exhaustive, here are the kind of lines written in the file:
let decom_allowed ['2015_2020' , '2010_2015' , 'NUCLEAR'] := 1;
Thanks in advance,
Best regards,
Xavier