-
Notifications
You must be signed in to change notification settings - Fork 35
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
get_solution mixing up two variables #244
Comments
I think that I found how to fix it. In the function extract_solution, there is patter defined as
We can force the match to be on the complete variable name and not only part of it by adding "^" at the begining of the pattern.
If it doesn't break anything else, I can make a PR with that fix. |
Oh thanks for spotting this. Or we just use exact matching instead of a regex? Otherwise I will take a look |
From grep definition, I find that about fixed = TRUE:
My understanding is that it will look for the exact string instead of a regular expression (for example, it will try to match "\[" instead of "["). "^" is the simplest way to find the exact match. "^" is the regex symbol to represent the begining of the text ("$" is the end of the text). In that case, we do not need the "$" since a variable name will always end with "]". |
I have noticed in a few cases where get_solution return strange values.
After investigating a little bit, I realised that it happens when two variables have somewhat similar names.
For example, I have found that in one model,
get_solution(solution, s[t,as])
returns the value of s but also the values of another variable named bus[c,cs].It also happened in another case with variables named "t_start" and "airport_start".
My understanding is that a regex match in get_solution is looking for "s[" and also return "bus[".
The text was updated successfully, but these errors were encountered: