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

Fill out plugin for tools to implement events inside the model #1149

Merged
merged 14 commits into from
Jan 17, 2024
Merged

Conversation

kylebaron
Copy link
Collaborator

@kylebaron kylebaron commented Jan 3, 2024

Summary

Housekeeping

  • self is an object with typedatabox; it is a struct that we use to shuttle information from the model back to mrgsolve; adding a push() method with signature evdata to push these event objects into a vector that will be processed by mrgsolve
  • Move evt namespace out from under mrgsolve
  • Add typedef evt::ev as an alias for evdata; I'm going to start shaping these to be more like the R version
  • In modelheader.h and model_include.R, needed to switch around how the header file gets included; there will need to be some more refactoring of the include order; will take that up once this PR is merged; but for now, the tests show that mrgsolve-evtools.h is getting included

New api

Signature rules

  • self always comes first if it is in the signature
  • ev comes first if self is not in the signature
  • For doses, <amt> comes first, then <compartment>; <rate> comes after <compartment>

Two functions to implement doses now; they return nothing and there is no opportunity to interact with the object that implements the doses

  • void evt::bolus(self, <amt>, <compartment>): do a bolus dose right now
  • void evt::infuse(self, <amt>, <compartment>, <rate>): do an infusion right now

Two functions to construct dose objects; the object is returned to allow user to customize a bit

  • evt::ev bolus(<amt>, <compartment>): return an object for a bolus dose
  • evt::ev infuse(<amt>, <compartment>, <rate>): return an object for an infusion

Some functions to help working with returned objects

  • void retime(<ev>, <time>): set the time of the dose; this also sets now to false
  • void now(<ev>): set now to true
  • void push(self, <ev>): push an event object back to mrgsolve to process

Also added a push member function to self; this could be overloaded eventually to push different types of stuff back. This will always be available, regardless of whether or not you load the plugin.

There will definitely be more coming on this front. But I'm pretty sure on these items. I'd like to review this and merge and see how things go for what's next.

@kylebaron kylebaron marked this pull request as draft January 5, 2024 21:55
@kylebaron kylebaron marked this pull request as ready for review January 5, 2024 21:58
@kylebaron kylebaron requested a review from kyleam January 10, 2024 23:25
Copy link
Contributor

@kyleam kyleam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New api

Nice. Thanks for laying that out in detail.

Move evt namespace out from under mrgsolve

Just to make sure I'm understanding correctly: that's a breaking change, correct?

It looks like this was only added in the 1.0.1 release (99f2aed, gh-934), so is the expectation that the one function (push) didn't get much use in the wild?

expect_identical(as.data.frame(a), as.data.frame(b))
})

local_edition(2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this local_edition call unnecessary? The file-level edition set by the local_edition call on line 9 should be automatically reset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok; I wasn't sure about the scope for the editions.

@kylebaron
Copy link
Collaborator Author

Thanks, @kyleam. Yeah, this is a breaking change. We could easily leave the mrgsolve::evt::push() function in the code and not have it be breaking for now.

I don't think there is currently a way to have this properly error right now (proper from R's perspective) ... in order to notify the user of the change. The other thing I could try is grepping this out of the model code and warning there.

I'll put the code back in and think about how to handle this in the future.

@kylebaron
Copy link
Collaborator Author

so is the expectation that the one function (push) didn't get much use in the wild?
Yeah; that previous addition was just a small start to what I'm doing now; didn't get documented anywhere, except for the PR.

I put that function back for now and will think of a way to pull it back someday.

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

Successfully merging this pull request may close these issues.

None yet

2 participants