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 add_vars #52

Open
Darksonn opened this issue Oct 27, 2021 · 2 comments
Open

Fix add_vars #52

Darksonn opened this issue Oct 27, 2021 · 2 comments

Comments

@Darksonn
Copy link
Collaborator

I got a segmentation fault when running add_vars. There's something wrong with it. It works when calling add_var in a loop.

@bazylhorsey
Copy link

bazylhorsey commented Mar 30, 2022

I actually think this is the incorrect implementation.
Here is the python implementation of add_vars:

blend = mining.addVars(years, name="Blend")

Notice how it uses the singular 'name' parameter.
In this case I do think years is indeed a list of strings;
however, the Rust function takes in a list of names: &[&str] rather than the &str of add_vars equivalent in python.

Therefore I'm drawn to conclude that the intention of add_var vs add_vars are inconsistent with the official Gurobi API.
Nevertheless I'm impressed with this library, cool stuff.

Here are the associated docs of Gurobi:
https://www.gurobi.com/documentation/9.5/refman/py_model_addvars.html
https://www.gurobi.com/documentation/9.5/refman/py_model_addvar.html

I'm pretty novice in rust, so probably won't be able to solve this :')

@Darksonn
Copy link
Collaborator Author

I don't think the difference between one vs many names is the cause of the segfault. The Python API internally converts the single name into many names by appending [0], [1] and so on to the string for each new variable, whereas this API lets you specify the name of each variable directly.

Of course, we could discuss whether you should have a single-name version of the function, which then does the same logic to generate names, but that's a separate question from this issue.

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

No branches or pull requests

2 participants