-
Notifications
You must be signed in to change notification settings - Fork 12
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
Concurrent simulation batch #513
Conversation
Here is a proposal how to use simulation batches:
|
@PavelBal The build is failing |
@msevestre Yes, it is using the old Core... And if I replace the libraries, it fails because of PK-Sim. |
ok let me check this out |
I am update the lib now to make sure we are using the right version of everything. Let' see |
I was trying to fix this and it was not letting me push lol.. I understand now |
Codecov Report
@@ Coverage Diff @@
## develop #513 +/- ##
===========================================
+ Coverage 88.37% 88.43% +0.06%
===========================================
Files 72 72
Lines 1359 1418 +59
===========================================
+ Hits 1201 1254 +53
- Misses 158 164 +6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the API is nice. I am wondering about a few things
1-the ptr
2-the dispose
R/error-checks.R
Outdated
if (is.null(object)) { | ||
if (nullAllowed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (nullAllowed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, nice shortcut.
if (is.null(value)) { | ||
if (nullAllowed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this? Is this more readable to have two ifs instead of one? Not sure.
Also we have the same conde in ValidateIsInteger. I always try to exit early. Here, you are adding complexity I believe because of the imbricated ifs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me some time to understand why I did it... I try to avoid testing for nullAllowed
if value
is not NULL
. Probably completely insignificant, and actually much better to test
if (is.null(value) && nullAllowed)
Will do it this way.
UPDATE:: Actually no, I tried to avoid testing for is.null(value)
twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msevestre You decide which approach to take.
R/utilities-simulation.R
Outdated
for (simBatchIdx in seq_along(simulationBatches)) { | ||
simBatch <- simulationBatches[[simBatchIdx]] | ||
# Put the simulation into sim pointer id <-> sim map | ||
simId <- deparse(rClr::clrGetExtPtr(simBatch$ref)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHAT IS THIS? LEt's please have a batch return an id or sthg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D Yes then we need to add an ID field to OSPSuite.R.Services.SettingsForConcurrentRunSimulationBatch
in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I added one and it's being used now. Please review
simulationResults[which(resultsIdSimulationIdMap == simId)] | ||
}) | ||
# Not sure this is required | ||
rClr::clrCall(simulationRunner, "Dispose") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an issue here. If this object is returned via a Task, it might be singleton and should NOT Be disposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I don't have experience with this. Removing the dispose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might need this. A task should not be disposable. It might be something I need to discuss with @abdelr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in short,if this is disposable, we should get a new instance everytime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I checked. Dispose is fine and should be call in that case explicitly. Not a big deal if not but it will release stuff immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msevestre There are some open questions left - e.g. SimBatch should return an ID must be first implemented in Core. Please see my answers.
R/error-checks.R
Outdated
if (is.null(object)) { | ||
if (nullAllowed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, nice shortcut.
if (is.null(value)) { | ||
if (nullAllowed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me some time to understand why I did it... I try to avoid testing for nullAllowed
if value
is not NULL
. Probably completely insignificant, and actually much better to test
if (is.null(value) && nullAllowed)
Will do it this way.
UPDATE:: Actually no, I tried to avoid testing for is.null(value)
twice.
if (is.null(value)) { | ||
if (nullAllowed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msevestre You decide which approach to take.
#' ids[[1]] <- simulationBatch1$addRunValues(parameterValues = c(1, 2), initialValues = 1) | ||
#' ids[[2]] <- simulationBatch1$addRunValues(parameterValues = c(1.6, 2.4), initialValues = 3) | ||
#' ids[[3]] <- simulationBatch2$addRunValues(parameterValues = c(4, 2), initialValues = 4) | ||
#' ids[[4]] <- simulationBatch2$addRunValues(parameterValues = c(2.6, 4.4), initialValues = 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just an example with multiple batches. But as it is dontrun
anyways, I update the example with two different simulations.
R/utilities-simulation.R
Outdated
for (simBatchIdx in seq_along(simulationBatches)) { | ||
simBatch <- simulationBatches[[simBatchIdx]] | ||
# Put the simulation into sim pointer id <-> sim map | ||
simId <- deparse(rClr::clrGetExtPtr(simBatch$ref)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D Yes then we need to add an ID field to OSPSuite.R.Services.SettingsForConcurrentRunSimulationBatch
in core.
simulationResults[which(resultsIdSimulationIdMap == simId)] | ||
}) | ||
# Not sure this is required | ||
rClr::clrCall(simulationRunner, "Dispose") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I don't have experience with this. Removing the dispose.
@msevestre OK I think this is ready to merge. |
No description provided.