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

RNDDRAW(S) - Adding a dummified performant version for advanced users #14

Open
FrederikSchaff opened this issue Oct 16, 2018 · 2 comments

Comments

@FrederikSchaff
Copy link
Collaborator

Problem description:
Currently, RNDDRAW(S) moves twice through the list of objects. Once to gather the probabilities and once more, until the position indicated by the random draw.
Sometimes one may want to define the probabilities based on a conditional dummy that takes values of 0.0 or 1.0, respectively. In other words, the random draw should be a fair draw in a subset. In this case, the conditional value might even be calculated by a function inside the object of interest. It would then be good, if there would only be a single run through all the objects.

Potential solution:
A temporary list of object pointers which holds the candidates. The set is divided in elements with weights < 1.0 and >= 1.0, the latter being part of the list. After the single run, one candidate of the subset can be returned randomly. In cpp11 std::deque would be good for holding such a list (random access, no memory reallocation).
A macro could be something like: RNDDRAW_DUMMY(LS).

@MCP1
Copy link
Collaborator

MCP1 commented Oct 16, 2018

Thanks for the suggestion!
To add this function to LSD, we would need to introduce a new category of elements to the LSD macro language, that is, pointer to functions or C++ containers. Also, it is not clear to me how useful such extension would be to a broader audience. As you know, I'm personally not very favorable to move non-essential elements to the macro language.
On the other hand, it seems to me that a personal standalone macro/function to perform such kind of job can be added to LSD without any change to the core LSD code (you could start from the code of draw_rnd member function), particularly because no modification to the internal object structure is required (so no risk of messing things).

@FrederikSchaff
Copy link
Collaborator Author

Hi,

the macro could still work the same way. I have implemented some such macros in the context of the GIS module. However, c++ structures are necessary. Let's pause this discussion, until a while after I added the GIS module as a separate branch here, as discussed with Marco.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants