-
Notifications
You must be signed in to change notification settings - Fork 25
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
Error Weights Objective #243
Comments
During the bounds calculation in flatten_model.py, for weighted sums we have the following:
When the sum is calculated with this, it ends up being a real number instead of an int, when the weight is float. Thus, when in the next line a new intvar is created, the problem occurs due to the lower bound (and the same for upper bound) not being an integer.. This could be solved if when calculating the bounds for wsum, we take these weights into account and then convert the bounds to an int before the initialization of the new IntVar. Also, after that we should check if this creates any other problem. I can be assigned the issue and check it, in case noone else is working in the same things. Is anyone working on this? |
In that pr I make sure that bounds return ints, but there seems to be a further issue here where ortools does not like the use of floats in the objective function |
Model([test * 0.5>2]).solve() crashes with an ortools error for example |
So the bounds PR will cause the error not to be on our side, but on ortools. That is a step forward. A little bonus could be for us to catch in the ortools interface when somebody wants to post a linear expression with a float value, and print a less cryptic warning, e.g. a recommendation to scale the parameters by a large constant (ortools can handle large constants) The second nice to have could be a normalisation that rewrites 4*(expr0.5) into 2expr, e.g. that it 'mul'(const, 'mul'(const, expr)) becomes the appropriate 'mul'(newconst, expr). |
In this case the error returned is
However if I change slightly the code
The code works.
The text was updated successfully, but these errors were encountered: