# Mworks selection object not reset

**URL:** https://mworks.discourse.group/t/mworks-selection-object-not-reset/216
**Category:** Support
**Created:** [December 2, 2019, 4:57pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216 "2019-12-02T16:57:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 2, 2019, 4:57pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/1 "2019-12-02T16:57:09Z")

</div>

Hi Chris,  
Just wanted to let you know that I’ve observed that a selection variable where the autoreset field is set to YES does not automatically reset when the selections are all made. Instead it seems to sample the same last value a bunch of times (probably exactly the same as the number of entries in the selection variable) before resetting. This seems either wrong or counter-intuitive. Do you have any suggestions?  
Thanks,  
Rishi

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 2, 2019, 4:59pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/2 "2019-12-02T16:59:09Z")

</div>

Hi Rishi,

Can you send me an example experiment that demonstrates this behavior?

Thanks,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 2, 2019, 5:03pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/3 "2019-12-02T17:03:22Z")

</div>

At the moment, I am explicitly calling “reset\_selections” when I expect the  
selection variable to be expired.

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 2, 2019, 6:30pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/4 "2019-12-02T18:30:39Z")

</div>

Can you at least send me the definition of the selection variable that isn’t auto-resetting? In my tests, autoreset is working as expected, so I’m trying to understand what’s different in your experiment.

Thanks,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 2, 2019, 9:31pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/5 "2019-12-02T21:31:34Z")

</div>

Yes, it’s in the file I attached above… Pasted here as well

selection trial\_index (  
values = 0:199  
selection = random\_with\_replacement  
advance\_on\_accept = YES  
autoreset = YES  
)

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 3, 2019, 5:37pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/6 "2019-12-03T17:37:14Z")

</div>

Sorry, I didn’t get the attached file. (MWEL files seems to get caught in spam filters, probably due to the unknown extension. You can avoid this by appending `.txt` to the filename or zip-compressing the file.)

Anyway, the problem is that `advance_on_accept` and `autoreset` don’t work together. A selection variable with `advance_on_accept` set to `YES` will automatically advance only when there are unused selections remaining. If there are no selections left, then it won’t attempt to advance, and the variable will never get the chance to automatically reset itself.

Addressing this issue is [on my to-do list](https://mworks.lighthouseapp.com/projects/23610/tickets/117). In the meantime, you can work around it by omitting `advance_on_accept` and manually calling [next\_selection](https://mworks.github.io/documentation/latest/components/next_selection.html) after accepting.

Cheers,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [December 3, 2019, 5:40pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/7 "2019-12-03T17:40:42Z")

</div>

Got it – thanks, Chris!

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [July 19, 2022, 8:41pm UTC](https://mworks.discourse.group/t/mworks-selection-object-not-reset/216/8 "2022-07-19T20:41:57Z")

</div>


