-
Notifications
You must be signed in to change notification settings - Fork 4
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
Washington's updates to calibration 0.3 and 0.4 - part 1 #200
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6c23ed
Close #164 - Fix multiple runs to enable the model to read files in c…
wsenafranca 90fddab
Close #172 - Remove MultipleRuns:output.
wsenafranca 18f3b03
Fix to remove MultipleRuns:output for sample strategy.
wsenafranca fafdb8f
Close #48 - Redirect every print from models to log files in Multiple…
wsenafranca 082407e
Close #189 - Add MultipleRuns:free to remove unnecessary memory
wsenafranca c80cf02
Review the message shown for output function error #172
wsenafranca 674db42
Review the function to redirect output #48
wsenafranca 6643053
Remove internal call to run model in randomModel #164
wsenafranca b6dd657
Remove freeModel function #164
wsenafranca 7ee24fb
Close #159 - Remove graphics from multiLevel
wsenafranca eb72097
Remove skipRun from doc
wsenafranca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,12 @@ local function redirectPrint(f) | |
return log | ||
end | ||
|
||
local function freeModel(model) | ||
forEachElement(model, function(member) | ||
model[member] = nil | ||
end) | ||
end | ||
|
||
-- function used in run() to test the model with all the possible combinations of parameters. | ||
-- params: Table with all the parameters and it's ranges or values indexed by number. | ||
-- Example: params = {{id = "x", min = 1, max = 10, elements = nil, ranged = true, step = 2}, | ||
|
@@ -396,6 +402,11 @@ local function factorialRecursive(data, params, a, variables, resultTable, addFu | |
testAddFunctions(resultTable, addFunctions, data, m, summaryResult) | ||
testDir:setCurrentDir() | ||
table.insert(resultTable.simulations, stringSimulations) | ||
if data.free then | ||
freeModel(m) | ||
m = nil | ||
collectgarbage() | ||
end | ||
end | ||
|
||
if data.summary and type(data.summary) == "function" then | ||
|
@@ -519,6 +530,11 @@ local function factorialRecursive(data, params, a, variables, resultTable, addFu | |
testAddFunctions(resultTable, addFunctions, data, m, summaryResult) | ||
testDir:setCurrentDir() | ||
table.insert(resultTable.simulations, stringSimulations) | ||
if data.free then | ||
freeModel(m) | ||
m = nil | ||
collectgarbage() | ||
end | ||
end | ||
|
||
if data.summary then | ||
|
@@ -666,6 +682,8 @@ metaTableMultipleRuns_ = { | |
-- @arg data.folderName Name or file path of the folder where the simulations output will be saved. | ||
-- Whenever the Model saves one or more files along its simulation, it is necessary to use this | ||
-- argument to guarantee that the files of each simulation will be saved in a different directory. | ||
-- @arg data.free If true, then the memory used by Model instances will be removed after their simulations. Only the observed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after each simulation. |
||
-- properties of the model will be stored within MultipleRuns, (Default is false). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
-- @arg data.hideGraphics If true (default), then sessionInfo().graphics will disable all charts and observers during models execution. | ||
-- @arg data.showProgress If true, a message is printed on screen to show the models executions progress on repeated strategy, | ||
-- (Default is false). | ||
|
@@ -677,13 +695,13 @@ metaTableMultipleRuns_ = { | |
-- @tabular strategy | ||
-- Strategy & Description & Mandatory arguments & Optional arguments \ | ||
-- "factorial" & Simulate the Model with all combinations of the argument parameters. | ||
-- & parameters, model & repetition, output, hideGraphics, quantity, folderName, showProgress, ... \ | ||
-- & parameters, model & repetition, output, hideGraphics, quantity, folderName, free, showProgress, ... \ | ||
-- "sample" & Run the model with a random combination of the possible parameters & parameters, | ||
-- repetition, model & output, folderName, hideGraphics, quantity, showProgress, ... \ | ||
-- repetition, model & output, folderName, free, hideGraphics, quantity, showProgress, ... \ | ||
-- "selected" & This should test the Model with a given set of parameters values. In this case, | ||
-- the argument parameters must be a named table, where each position is another table describing | ||
-- the parameters to be used in such simulation. & | ||
-- model, parameters & output, folderName, hideGraphics, repetition, showProgress, quantity, ... | ||
-- model, parameters & output, folderName, free, hideGraphics, repetition, showProgress, quantity, ... | ||
function MultipleRuns(data) | ||
mandatoryTableArgument(data, "model", "Model") | ||
mandatoryTableArgument(data, "parameters", "table") | ||
|
@@ -695,6 +713,7 @@ function MultipleRuns(data) | |
defaultTableValue(data, "hideGraphics", true) | ||
defaultTableValue(data, "showProgress", true) | ||
optionalTableArgument(data, "summary", "function") | ||
defaultTableValue(data, "free", false) | ||
|
||
if data.strategy == nil then | ||
local choiceStrg = false | ||
|
@@ -742,7 +761,7 @@ function MultipleRuns(data) | |
local checkingArgument = {} | ||
checkingArgument[idx] = idx | ||
verifyUnnecessaryArguments(checkingArgument, { | ||
"model", "strategy", "parameters", "repetition", "folderName", "hideGraphics", "showProgress", "repeat", "quantity", "outputVariables"}) | ||
"model", "strategy", "parameters", "repetition", "folderName", "hideGraphics", "showProgress", "repeat", "quantity", "outputVariables", "free"}) | ||
end | ||
end) | ||
|
||
|
@@ -921,6 +940,12 @@ function MultipleRuns(data) | |
|
||
table.insert(resultTable[idx2], att2) | ||
end) | ||
|
||
if data.free then | ||
freeModel(m) | ||
m = nil | ||
collectgarbage() | ||
end | ||
end | ||
|
||
if data.summary then | ||
|
@@ -1029,6 +1054,12 @@ function MultipleRuns(data) | |
|
||
table.insert(resultTable[idx2], att2) | ||
end) | ||
|
||
if data.free then | ||
freeModel(m) | ||
m = nil | ||
collectgarbage() | ||
end | ||
end | ||
|
||
if data.summary then | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This function should not be necessary.