r - 煨回滚功能
问题描述
我没有正确理解 simmer 中的回滚功能,根据https://r-simmer.org/reference/rollback.html,数量参数表示要回滚的活动量。但是我的代码没有做应该做的事情。这里我做了一个例子
MyEnv <- simmer("MyEnv")
Traj <- trajectory() %>%
timeout(0) %>%
log_("Registered") %>%
timeout(1) %>%
log_("Analyzed") %>%
branch (option = function() {round(ifelse(runif(1,0,100)<50,1,2))},
continue=TRUE,
trajectory() %>%
timeout(1) %>%
log_("Repair Simple") %>%
timeout(function() {round(runif(1,5,10))}) %>%
log_("Repair Tested (Simple)") %>%
branch (option = function() {round(ifelse(runif(1,0,100)<50,0,1))},
continue=TRUE,
# Restart Repair
trajectory() %>%
timeout(2) %>%
log_("Restart") %>%
rollback(amount=3)
),
trajectory() %>%
timeout(1) %>%
log_("Repair Complex")%>%
timeout(1) %>%
log_("Repair Tested (Complex)") %>%
branch (option = function() {round(ifelse(runif(1,0,100)<50,0,1))},
continue=TRUE,
trajectory() %>%
timeout(2) %>%
log_("Restart") %>%
rollback(amount=3)
)
) %>%
timeout(0) %>%
log_("User Informed") %>%
timeout(0) %>%
log_("Repair Archived")
MyEnv%>%
add_generator("Case_", Traj, distribution = function() 2) %>%
run(until=20)
当模拟进入“重新启动”活动时,它应该回滚 3 个活动并再次执行修复简单或修复复杂。但是使用提供的代码重新启动活动只是重复它自己。如果将数量参数设置为 3,这怎么可能?
这是我的模拟输出:
2: Case_0: Registered
3: Case_0: Analyzed
4: Case_0: Repair Simple
4: Case_1: Registered
5: Case_1: Analyzed
6: Case_1: Repair Simple
6: Case_2: Registered
7: Case_2: Analyzed
8: Case_2: Repair Complex
8: Case_3: Registered
9: Case_2: Repair Tested (Complex)
9: Case_3: Analyzed
9: Case_2: User Informed
9: Case_2: Repair Archived
10: Case_0: Repair Tested (Simple)
10: Case_3: Repair Simple
10: Case_4: Registered
11: Case_4: Analyzed
12: Case_1: Repair Tested (Simple)
12: Case_0: Restart
12: Case_4: Repair Complex
12: Case_5: Registered
13: Case_4: Repair Tested (Complex)
13: Case_5: Analyzed
13: Case_4: User Informed
13: Case_4: Repair Archived
14: Case_1: Restart
14: Case_0: Restart
14: Case_5: Repair Complex
14: Case_6: Registered
14: Case_0: User Informed
14: Case_0: Repair Archived
15: Case_5: Repair Tested (Complex)
15: Case_6: Analyzed
15: Case_5: User Informed
15: Case_5: Repair Archived
16: Case_1: Restart
16: Case_6: Repair Simple
16: Case_7: Registered
16: Case_1: User Informed
16: Case_1: Repair Archived
17: Case_3: Repair Tested (Simple)
17: Case_7: Analyzed
18: Case_7: Repair Simple
18: Case_8: Registered
19: Case_3: Restart
19: Case_8: Analyzed
解决方案
推荐阅读
- python - PyQt5 QDoubleValidator 不允许写点分隔符:xy
- java - 与 orika 的单对多双向关系中的 DTO 到 JPA 实体
- javascript - 如何在 if else 条件下正确使用 match()。(node.js)
- apache-kafka - kafka再平衡控制流
- javascript - 如何从画布中删除上传的图像(如果有)?
- oracle-sqldeveloper - 尝试在 sql 中更新时出现问题
- python - 如何从 tkinter Combobox 绑定函数中获取价值
- c++ - 在 C++20 中使用 `|| 初始化位域 新的 int` 构造
- python - 如何使用 IBM Speech to Text 进行扬声器分类?
- entity-framework - 如何将数据从代码插入 Db 并创建 POST 方法