Decision Optimization

 View Only
  • 1.  Memory Error through multiple optimizations

    Posted Thu May 25, 2023 11:18 AM
    I am a student and I am currently analyzing an optimization written in Cplex. My plan is to run the optimization through a forloop many times. After each model evaluation everything should be reset, so that the next optimization can be started again, uninfluenced by the previous one. 
    So in the for-loop some input parameters are changed, then the model is generated and solved with opl.generate and solve. At the end of the for-loop I try to close with opl.end, mod.end and all files in which the solution is written with .close. Everything is working if I start the optimization again manually each 9 hours (around 10 optimizations run smoothly in that time). But I would like to have all 100 optimizations run without getting into that memory error. 
    My question is: 
    how can i document well what happens and so what goes wrong? 
    how can I clear the memory throughly between optimizations? 
    alternatively, how can I run multiple optimizations one after the other in an automated way (over 100)?
    Thank you very much for the help!


  • 2.  RE: Memory Error through multiple optimizations

    Posted Fri May 26, 2023 10:23 AM

    Dear Jo

    Did you consider forking a process for each solve? Uploading... Upload file  
    This would ensure that all system resources are actually freed when the process dies.
    I hope this helps.

    Renaud Dumeur

  • 3.  RE: Memory Error through multiple optimizations

    Posted Fri June 02, 2023 06:30 AM

    Dear Renaud,

    Thank you a lot for that idea.

    Would it be possible to explain what you mean by forking a process for each solve and how I can find out how to do it?  I tried to look it up, but it is still not clear to me. 

    Thanks :)

  • 4.  RE: Memory Error through multiple optimizations

    Posted Thu June 08, 2023 03:46 AM

    Dear Jo,

    Please refer to which describes the fork() system call. Basically, it allows to create a child process in which you could perform a solve. Of course, because the child process doesn't share memory with the parent, the child process must communicate its result to the parent via a file (or a pipe). 

    I hope this helps.


    Renaud Dumeur