Skip to content

Commit 71ec380

Browse files
authored
Update main_double-dispatch.R
1 parent 8e626c5 commit 71ec380

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

scripts/main_double-dispatch.R

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,35 +225,33 @@ map_markov_to_decision <- function(markov_result) {
225225
# define the update_model S3 functions
226226
# a kind of double dispatch approach
227227

228-
update_model <- function(model, previous) {
228+
update_model <- function(target, previous) {
229229
UseMethod("update_model")
230230
}
231231

232-
update_model.DecisionTree <- function(model, previous) {
233-
update_decisiontree(previous)
232+
update_model.DecisionTree <- function(target, previous) {
233+
UseMethod("update_model.DecisionTree", previous)
234234
}
235235

236-
update_model.MarkovModel <- function(model, previous) {
237-
update_markovmodel(previous)
236+
update_model.MarkovModel <- function(target, previous) {
237+
UseMethod("update_model.MarkovModel", previous)
238238
}
239-
240-
update_model.default <- function(model, previous) {
241-
warning("No update method for this model type; returning model unchanged.")
242-
model
239+
240+
update_model.DecisionTree.MarkovModel <- function(target, previous) {
241+
target$data <- map_decision_to_markov(target, target$mapping)
242+
target
243243
}
244244

245-
###
246-
247-
update_markovmodel <- function(model) {
248-
UseMethod("update_markovmodel")
245+
update_model.MarkovModel.DecisionTree <- function(target, previous) {
246+
target$data <- map_decision_to_markov(target, target$mapping)
247+
target
249248
}
250249

251-
update_markovmodel.DecisionTree <- function(model) {
252-
model$data <- map_decision_to_markov(model, model$mapping)
253-
model
250+
update_model.default <- function(target, previous) {
251+
warning("No update method for this model type; returning model unchanged.")
252+
target
254253
}
255254

256-
257255
###############################
258256
# Example
259257
###############################

0 commit comments

Comments
 (0)