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

Export or print updated model code #1177

Open
RichardHooijmaijers opened this issue Mar 12, 2024 · 4 comments
Open

Export or print updated model code #1177

RichardHooijmaijers opened this issue Mar 12, 2024 · 4 comments

Comments

@RichardHooijmaijers
Copy link

I have a case where I want to update a model with for instance new parameter values. I also want to print or save this updated model code, but struggling to do so. For instance:

library(mrgsolve)
# Load a model
mod  <- house()
# Update a parameter 
mod2 <- param(mod,CL=2)

# This will all print the original model code
mod2$code 
mrgsolve:::code(mod2)  
see(mod2, raw=TRUE)
# This line does not work, also the example in the help file fails
# mrgsolve:::render(mod2)

Is there a way to print the entire model code where the new parameter value (CL=2) is included?
Thanks!

@jimm3134
Copy link

jimm3134 commented May 3, 2024

workaround -
use mrgsolve:::code(mod2) to print to the console, then select that code with your mouse and copy it to a document for printing.

@RichardHooijmaijers
Copy link
Author

Hi @jimm3134 thanks for your reply. I used mrgsolve:::code(mod2) in my example. And although this prints the model, it is the original model. I would like to know if there is a way which shows the updated model (e.g. where CL is set to 2)

@kylebaron
Copy link
Collaborator

Hi @RichardHooijmaijers - I'm sorry for the delay responding to your question. There isn't currently a way to write the updated object back to the model specification format. The best you can do is save the object to, say, .rds file and then read it back in when needed. mrgsolve:::code() (or mod@code) always goes back to the original model code. I am working on a feature to write the different model components out in .json format to be read back in; that would also preserve updated components of the model. But it would give you a version of the model code that is transportable and readable.

Kyle

@RichardHooijmaijers
Copy link
Author

Hi @kylebaron thanks for clarifying! I really like the idea of using json format including options for updated components. Will keep an eye out for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants