euba / BacArena

agent based modelling
GNU General Public License v3.0
26 stars 11 forks source link

Parallelization and hidden GLPK #152

Closed maringos closed 4 years ago

maringos commented 5 years ago

Dear All,

I am suspecting that if someone sets the solver CPLEX for BacArena and runs simulations in parallel as proposed in the vignette, the parallelization forgets CPLEX and runs with GLPK. I have noticed it in a HPC batch system, where my GLPK was broken, but CPLEX was OK. When the code reached the parallelization point, it returned a GLPK error - like it was running with GLPK. Calling CPLEX inside the loop solved the issue and increased the speed.

I look forward to your opinion. Kind Regards, Georgios

euba commented 4 years ago

I'm not sure if this was the problem, but when you want to simulate with a particular solver, you need to set the solver with sybil::SYBIL_SETTINGS("SOLVER","cplexAPI") within the definition of the parallel processes. So:

simlist <- parLapply(cl, 1:replicates, function(i){
  sybil::SYBIL_SETTINGS("SOLVER","cplexAPI")
  #some functions here
})

instead of:

sybil::SYBIL_SETTINGS("SOLVER","cplexAPI")
simlist <- parLapply(cl, 1:replicates, function(i){
  #some functions here
})

otherwise the default solver (GLPK) of sybil will be used in each initialized core, no matter what you did outside of the parLapply loop. That's the normal behaviour.

Best, Eugen

maringos commented 4 years ago

thanks for the clarification :)