I'm writing some code to perform markov chain monte carlo (MCMC) in python for parameter estimation of SBML based ODEs. The implementation is complete and works until I try and perform more than 126 iterations. The error I get when using more than 126 iterations is:
File "insert_copasi_parameters.py", line 68, in _read_copasiML_as_string
with open(self.copasi_file) as f:
IOError: [Errno 24] Too many open files: 'D:\\MPhil\\Model_Building\\Models\\Exercises\\COPASI_API\\_temp.cps'
The integration of ODE's is computed using some software called COPASI. This software requires an xml. The module 'insert_copasi_parameters' takes some randomly sampled parameters and puts them into the xml (which is the .cps file being complained about above).
The actual method the algorithm fails on ('_read_copasiML_as_string') is a simple with
block. i.e.
def _read_copasiML_as_string(self):
with open(self.copasi_file) as f:
return f.read()
An ODE trajectory is then calculated by the software and parsed back into python to continue with the algorithm. Since I'm using a with
block these files should be getting opened and then closed again after every iteration. Not only this, the `temp.cps' file above is actually a copy of the original that gets deleted between runs. I appreciate its hard without seeing the actual code (which is too long for SO) but can anybody suggest where this error coming from?
Thanks in advance