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

feat: support setting initial values for individual variables #75

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

KnorpelSenf
Copy link
Contributor

As discussed in #55 (comment) and below

src/variable.rs Outdated Show resolved Hide resolved
Previously, when building up an initial solution from the problem
variables would cause repeated reallocation. We support partial initial
solutions so we may have 0-n values in the initial solution (with n
being the number of total variables). We do not want to allocate memory
for all variables because there might be 0 initial values, and we also
do not want to do allocate 0 memory because then we have to repeatedly
reallocate memory as the initial solution grows.

These changes introduce a counter that is incrememted whenever a
variable with an initial value is added to the problem. That way, we can
allocate the perfect number of bytes upfront in all cases.
@KnorpelSenf
Copy link
Contributor Author

Please see KnorpelSenf#1 before merging

@KnorpelSenf
Copy link
Contributor Author

Do you know why the assertion fails?

ProblemVariables { variables: vec![] }
ProblemVariables {
variables: vec![],
initial_count: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this adding to the size? If yes, should we just change the test now?

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

Successfully merging this pull request may close these issues.

2 participants