virtualcell / vcell

Virtual Cell Framework
http://vcell.org/
Other
66 stars 20 forks source link

Multiple Trajectory stochastic runs are incorrect with local runs on Mac #819

Closed lesloew closed 1 year ago

lesloew commented 1 year ago

See BioModel "Stochastic versus Deterministic", Application "Stochastic", Sim "1 molecule of each". Server runs seems fine. local run on Mac is very flaky.

CodeByDrescher commented 1 year ago

Something to do with how the data is put back together? Frank did some funky stuff with the multiple runs.

CodeByDrescher commented 1 year ago

image

CodeByDrescher commented 1 year ago

(Left) is the local run; (Right) is the server + windows run.

CodeByDrescher commented 1 year ago

Seems to be a parallelization process gone wrong.

jcschaff commented 1 year ago

Wrote C++ unit test for the VCellStoch solver - decomposed the solver into a library and executable and added a unit test. Tested the solver on Macos - works as expected.

jcschaff commented 1 year ago

https://github.com/virtualcell/vcell-solvers/tree/vcellstoch-testing

jcschaff commented 1 year ago

determined that problem was incorrect macos native solver (C++ executable)

tested macos solvers from archived installers from past few years, same problem - but was difficult to determine which version of solver as they didn't report their version correctly.

refactored Stochastic solver for testability

The nonspatial stochastic solver VCellStoch_x64, when compiled for Macos for local execution, gives incorrect results. It was not clear what the problem was, so the following was done.

  1. upgraded to C++14 spec and fixed many small problems.
  2. decomposed VCellStoch into a VCellStochLib (a static library) and VCellStoch_x64 the executable invoked by VCell
  3. unit tests were created against VCellStochLib to exercise end-to-end test of failing simulation - simulation completed, but results were incorrect.

still wrong solutions, refactored further to isolate problem

  1. refactored/simplified the "recently" added 'non-histogram' statistics code into a testable C++ class MultiTrialStats
  2. tests identified small errors, but primary problem remained.

"the fix": upgraded random number generator to built-in C++11 Mersenne Twister

  1. random seeds were not being implemented properly on macos with modern compiler
  2. fixed problem - tested model and expected results from this issue (2 molecules, 50000 trials).

added GitHub repo versioning to all solver executables (for all platforms)

fixed Macos builds on GitHub CI and released as v0.0.43 (mac only)

updated Java code to pull v0.0.43 for local mac solvers.

image
jcschaff commented 1 year ago

see vcell-solvers PR #24 and vcell-solver release v0.0.43 for newly fixed native solvers for Macos.

jcschaff commented 1 year ago

deployed on Alpha and Release sites as release 7.5.0.59