의 도착 실행 오류가 없습니다.이 simmer_vignette과이 링크 advanced_simmer_usage은 "get_name, get_attribute 및 get_prioritization은 궤도 내에서 사용하기위한 것이고, 그렇지 않으면 아무런 오류도 발생하지 않습니다. 도착 실행하고 이러한 기능은 오류 " 최소한의 가능한 예를 던질 것이다 : 나는 다른 의미에서() get_attribute를 호출 할 때이 일을 해야하는로Simmer Get_attribute |
patient_traj <- trajectory(name = "patient_trajectory") %>%
set_attribute("my_key", 123) %>%
timeout(5) %>%
set_attribute("my_key", function() get_attribute(env, "my_key") + 1) %>%
timeout(5) %>%
set_attribute("dependent_key", function() ifelse(get_attribute(env, "my_key")<=123, 1, 0)) %>%
timeout(5) %>%
set_attribute("independent_key", function() runif(1))
env<- simmer() %>%
add_generator("patient", patient_traj, at(0), mon = 2)
env %>% run()
#> simmer environment: anonymous | now: 15 | next:
#> { Generator: patient | monitored: 2 | n_generated: 1 }
get_mon_attributes(env)
#> time name key value replication
#> 1 0 patient0 my_key 123.0000000 1
#> 2 5 patient0 my_key 124.0000000 1
#> 3 10 patient0 dependent_key 0.0000000 1
#> 4 15 patient0 independent_key 0.9234335 1
지금이 작동 문제가 시작됩니다. 궤적 정의의 맨 끝에 set_attribute 후이 줄을() 추가 :
log_(get_attribute(env, "independent_key"))
는 상기의 오류가 발생합니다. 실제로하고 싶은 것은 "leave"함수를 호출하여 속성으로 확률을 부여하는 것입니다. 나는 아직도 궤도에서 이것을한다.
leave(prob = get_attribute(env, "independent_key"))
말할 필요도없이
,이 또한 오류 "get_attribute_의 오류 (개인 $의 sim_obj가, 키, 전역) : 실행중인 도착 없다"던졌습니다.이 문제의 원인을 아는 사람이 있습니까? 유일한 옵션은 위의 설명입니다. "get_attribute는 궤적 안에 사용해야합니다."-하지만 나는이 일을하는 것처럼 느낍니다.
감사합니다!
맞습니다. 첫 번째 버전에서는 함수를 즉시 호출하므로 실패합니다. 대신 두 번째 버전은 시뮬레이션 중에 호출되는 익명의 함수를 정의합니다. –
@ Iñakicarcar 설명 주셔서 감사합니다. – user18093