Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Issue with simulator engine compilation #250

Open
CDarlow opened this issue Jan 10, 2025 · 10 comments
Open

Potential Issue with simulator engine compilation #250

CDarlow opened this issue Jan 10, 2025 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@CDarlow
Copy link

CDarlow commented Jan 10, 2025

I recent updated my iOS to Sequoia (14.2) (I typically delay doing so as it disrupts the stability of several programmes until updates can be made). As expected, this disrupted my Pmetrics build, and requiring reinstallation (including update of GCC).

I managed to reinstall Pmetrics and PMbuild successfully (although I had to create a Makevars file to force compilation with GCC). PMtest reverts an error message:

Error in NPex$data$write("data.csv") : attempt to apply non-function
In addition: Warning message:
In data(NPex, package = "Pmetrics", envir = environment()) :
data set ‘NPex’ not found

although I recall it doing with the same/similar message with my previous build without any issues.

I'm now having trouble with the simulator using files and code that previously worked fine. In particular, when I run a simulator (using v2.0 code) I get this error message, with the simulation abortion of each simulated subject:

At line 8460 of file SIMeng_114.f (unit = 5, file = 'stdin')

Fortran runtime error: End of file

A simout file is created, but the input values are all assigned the value boundaries of the first parameter i.e.:

POPMAX 7.00000000 TO 9.00000000
Ka 7.00000000 TO 9.00000000
V1 7.00000000 TO 9.00000000
V2 7.00000000 TO 9.00000000
CL1 7.00000000 TO 9.00000000
CL2 7.00000000 TO 9.00000000
KCP1 7.00000000 TO 9.00000000
KPC1 7.00000000 TO 9.00000000
KCP2 7.00000000 TO 9.00000000
KPC2 7.00000000 TO 9.00000000
Kgs 7.00000000 TO 9.00000000
Kks 7.00000000 TO 9.00000000
E50_1s 7.00000000 TO 9.00000000
E50_2s 7.00000000 TO 9.00000000

When it should be (taken from a pre-reinstall simout file with the same code, model, datafile):

POPMAX 7.00000000 TO 9.00000000
Ka 0.100000000 TO 2.00000000
V1 0.100000000E-02 TO 0.200000000
V2 0.100000000E-03 TO 0.100000000
CL1 0.100000000E-02 TO 0.100000000E-01
CL2 0.100000000E-02 TO 0.150000000E-01
KCP1 0.100000000E-01 TO 20.0000000
KPC1 0.100000000E-01 TO 40.0000000
KCP2 0.100000000E-01 TO 30.0000000
KPC2 0.100000000E-01 TO 30.0000000
Kgs 0.100000000E-01 TO 0.500000000
Kks 0.100000000E-01 TO 0.800000000
E50_1s 8.00000000 TO 15.0000000
E50_2s 5.00000000 TO 15.0000000

The SIMpase element of the v2.0 simulation command understandably fails as there is no simulated output data in this SIMout file following the simulation abortion. Other previously successfully simulated (and simpler) models also have the same issue when I try to re-run them.

Is this an issue with compilation of the simulation engine?

Thank you in advance.

@mhovd
Copy link
Contributor

mhovd commented Jan 13, 2025

Thanks for raising this issue.
Regarding the first error concerning the missing NPex-object, that is a temporary issue that should not affect Pmetrics, and will be resolved in a later update. For now its just a nuisance.

As for the simulator, I think this is model-related. Could you try simulating with a simple model, e.g. two-compartment?
Also, if you are able to share the model file, either publicly or by e-mail, that could assist in debugging the issue.

@CDarlow
Copy link
Author

CDarlow commented Jan 14, 2025

Thank you for the quick response.

Reassuring re: PMtest - I will ignore for now. It was partly this that made me suspect a compilation issue.

On re-running simulation this week (without any alteration to the code/model/data) the duplication of parameter windows, this seems to have resolved with a system restart (for both this and other models). However, the error message:

At line 8460 of file SIMeng_114.f (unit = 5, file = 'stdin')

Fortran runtime error: End of file

As additional information, In the aborted simulation file terminates with the following:

********** THE FOLLOWING ARE THE RESULTS OF THIS RUN ********

  -17 <-- SEED NO. FOR THE FOLLOWING SIMULATION. 

COV MATRIX IS NOT POS-DEF; PROGRAM STOPS.

I'm happy to share my model via email (it isn't one I am able to share publicly), but the simulation ran with the model unaltered perfectly fine before the iOS upgrade and reinstallation.
(The simulation engine now works fine with other models after the system reset)

@mhovd
Copy link
Contributor

mhovd commented Jan 14, 2025

COV MATRIX IS NOT POS-DEF; PROGRAM STOPS.
This error is a little strange. Do you use covariates in your simulation?
I believe that the error may be due either to the augmentation of the covariance matrix when a covariate is used, an error in the simulator, or model misspecification.

If you can send your model file to my e-mail at [email protected] I can take a look when I get the chance.

@CDarlow
Copy link
Author

CDarlow commented Jan 14, 2025

Thank you - I will send an email.

To answer your questions - I did not use any covariates, nor augment the covariance matrix of the primary parameters estimates, which were pulled from a fitted run.

@CDarlow
Copy link
Author

CDarlow commented Jan 15, 2025

I have emailed you the model, but just to update, I have managed to get the simulator to run with this model and a manually specified poppar with mean parameter estimates and the diagonal on covariance matrix only, and the simulator has run ok.

@mhovd
Copy link
Contributor

mhovd commented Jan 15, 2025

Thanks for the model and the update - I'm happy to hear you got it to run!
I took a quick look at the model, and possibly I think that the error is due to some combination of parameter values that causes the extra functions to fail. Could you perhaps try restricting the boundaries to the relevant parameter ranges, if you haven't done so already? I.e. look at the population parameter distributions, and see if any of the space can be trimmed.

Also, I don't know if you are aware, but we have been rewriting the Pmetrics backend from scratch in Rust. Depending on your requirements, we could assist in writing the model file in Rust so that you can run it with Pmetrics, as the translator is not finished yet. Given it's complexity I would need some help from @Siel, but it should be manageable if you so desire,

@mhovd mhovd self-assigned this Jan 15, 2025
@mhovd mhovd added the bug Something isn't working label Jan 15, 2025
@CDarlow
Copy link
Author

CDarlow commented Jan 16, 2025

possibly I think that the error is due to some combination of parameter values that causes the extra functions to fail.

I don't think this is neccesarily the case. First, the simulations terminate before any parameter values are simulated (see attached simout file).
simout1.txt

Moreover, when I manually creating a poppar with the mean parameter estimates and diagonal covariances with limits=NULL, the simulation runs and generates sim outputs that widely vary and into nonsensical ranges (e.g. negative Cl and V) without crashing the simulator.

Also, I don't know if you are aware, but we have been rewriting the Pmetrics backend from scratch in Rust. Depending on your requirements, we could assist in writing the model file in Rust so that you can run it with Pmetrics, as the translator is not finished yet. Given it's complexity I would need some help from @Siel, but it should be manageable if you so desire,

Thank you for the offer. This isn't a priority for me now (unless a Rust translated model runs more stably in Pmetrics), but I may get in touch about this later.

@mhovd
Copy link
Contributor

mhovd commented Jan 16, 2025

Could you perhaps try with some slightly different boundaries? The main error appears to be due to the covariance matrix being non-positive definite, and sometimes that can be enough to solve the issue.

@CDarlow
Copy link
Author

CDarlow commented Jan 17, 2025

As an update, I re-ran the model with significantly tighter margins, but the simulator still crashed with the same error.

As I said, I'm able to run the simulator with manually inputted diagonal covariances only (with off-diagonals covariances as zero), which is sufficient for my immediate purposes. Manually inputted full covariance matrix (obviously) leads to the same error.

@CDarlow
Copy link
Author

CDarlow commented Jan 17, 2025

To add further, the simulator works with a full covariance matrix provided I fixed the non-positive definite covariance matrix manually (negative eigenvalues very small (~-1e10^-8 or ^-9). Is this potentially a bug in the in-programme option to fix the covariance matrix as part of the simulator engine i.e., the option 2 in the below that arises?

Choose one of the following:

  1. end simulation
  2. fix covariance
  3. set covariances to 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants