Skip to content
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

fix #227: unpause reneging arrivals that are kicked from a queue #228

Merged
merged 2 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# simmer 4.4.1

## Minor changes and fixes

- Fix pause status of reneging arrivals that are kicked from a resource queue
(#228 addressing #227).

# simmer 4.4.0

## New features
Expand Down
8 changes: 4 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Minor release
## Patch release

Several improvements and bug fixes.
Small, but important bug fix.

Regarding the package title, Uwe asked us in a past submission to remove
"for R" because it is redundant. If it is not an issue, we would like to keep
Expand All @@ -12,8 +12,8 @@ written in Julia".

## Test environments

- Fedora 31 + GCC + clang (local), R 3.6.1
- Ubuntu 16.04 + GCC (on Travis-CI), R 3.5.3, 3.6.1, devel
- Fedora 31 + GCC + clang (local), R 3.6.3
- Ubuntu 16.04 + GCC (on Travis-CI), R 3.5.3, 3.6.3, devel
- linux-x86_64-rocker-gcc-san (on r-hub)
- ubuntu-rchk (on r-hub)
- win-builder, R devel
Expand Down
4 changes: 3 additions & 1 deletion inst/include/simmer/process/arrival_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2016 Bart Smeets and Iñaki Ucar
// Copyright (C) 2016-2019 Iñaki Ucar
// Copyright (C) 2016-2020 Iñaki Ucar
//
// This file is part of simmer.
//
Expand Down Expand Up @@ -79,6 +79,8 @@ namespace simmer {
unset_busy(sim->now());
unset_remaining();
foreach_ (ResVec::value_type& itr, resources) {
if (itr->is_waiting(this))
--paused;
if (!keep_seized || itr->is_waiting(this))
itr->remove(this);
}
Expand Down
29 changes: 28 additions & 1 deletion tests/testthat/test-trajectory-renege.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2016-2019 Iñaki Ucar
# Copyright (C) 2016-2020 Iñaki Ucar
#
# This file is part of simmer.
#
Expand Down Expand Up @@ -717,3 +717,30 @@ test_that("a reneging arrival keeps seized resources (2)", {
expect_equal(res$server, c(1, 0, 0))
expect_equal(res$queue, c(0, 1, 0))
})

test_that("a reneging arrival is able to seize a resource again", {
t <- trajectory() %>%
renege_in(
t = 5,
out = trajectory() %>%
rollback(2)) %>%
seize("resource") %>%
renege_abort() %>%
timeout(10) %>%
release("resource")

env <- simmer(verbose=TRUE) %>%
add_resource("resource") %>%
add_generator("dummy", t, at(0, 3)) %>%
run()

arr <- get_mon_arrivals(env)
res <- get_mon_resources(env)

expect_equal(arr$end_time, c(10, 20))
expect_equal(arr$activity_time, c(10, 10))
expect_true(all(arr$finished))
expect_equal(res$time, c(0, 3, 8, 8, 10, 20))
expect_equal(res$server, c(1, 1, 1, 1, 1, 0))
expect_equal(res$queue, c(0, 1, 0, 1, 0, 0))
})