You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plus constraint over unbounded variables panic with message attempt to subtract with overflow #369
use std::{i32, result, vec};
use pumpkin_solver::conflict_resolvers::resolvers::ResolutionResolver;
use pumpkin_solver::core::results::{ProblemSolution, SatisfactionResult};
use pumpkin_solver::core::termination::Indefinite;
use pumpkin_solver::*;
fn main() {
let mut solver = Solver::default();
// We create 3 variables
let x = solver.new_bounded_integer(i32::MIN, i32::MAX);
let y = solver.new_bounded_integer(i32::MIN, i32::MAX);
let z = solver.new_bounded_integer(i32::MIN, i32::MAX);
let c1 = solver.new_constraint_tag();
solver.add_constraint(plus(x, y, z, c1)).post().unwrap();
let mut termination = Indefinite;
let mut resolver = ResolutionResolver::default();
let mut brancher = solver.default_brancher();
let result = solver.satisfy(&mut brancher, &mut termination, &mut resolver);
}
Thank you for reporting the issues. We discussed this internally, but I realise now that we have not replied to you.
At the core of this issue (and the others you posted) is the assumption that the variables will have relatively small domains, so overflows will not occur. This is true for (almost) all MiniZinc Challenge benchmarks. In the past, we did some experiments with other CP solvers, and we also noted that other solvers have this issue as well. Essentially, solvers hope that overflows do not occur, and if they do, that they do not affect the end result. Most silently fail, which is not great. In your case, you seem to have a specific application where having (arbitrarily?) large domains may be relevant.
We discussed handling this in Pumpkin in a principled way, but we are not sure when we would make this change, since it does require a bit of work to ensure it does not degrade performance for instances that do not need large domains. One of the main issues for us is that we do not have good use cases for such functionality. If we could get some benchmarks/instances where this is needed, that would be much appreciated!
Chiming in with a use case for a larger domain than i32; I'm using the constraint solver to minimize the number of partitioned queries in a larger overall set based on a total number of anticipated rows. The database can easily crack 2.1B rows for queries, but the number to optimize for would not surpass 1T; the constraints are to partition the queries to return chunks no more than CHUNK_LIMIT in size based on 2 dimensions (varname and datetime cutpoint). This is a case where expanding the bounds would be useful because it could handle the larger number while working on a solution, even though CHUNK_LIMIT is decidedly within-bounds (~100,000).
Obviously an open question whether you want to support the use/intent or if there's some better way to handle the problem but this would certainly make the library accommodate more flexible/general-purpose use with different domains.
Thank you both for your input! It is interesting to hear about these use cases, since we did not have such applications in mind. If you could provide some small benchmarks, we can try out the solver once we implement unbounded integers, which would be helpful. No rush from our side.
Obviously an open question whether you want to support the use/intent or if there's some better way to handle the problem but this would certainly make the library accommodate more flexible/general-purpose use with different domains.
Agreed! It seems relevant since it would make the solver more reliable, which is our prime concern. That said, I am not sure when we would do this, but it is relevant. We will think about it in the next period, but we cannot give any estimates at the moment. We would need to see how to incorporate this without slowing down the solver for cases when this is not needed.
I am interested to know which other solver have evaluate. Does Choco solver have the same ?
We tried ortools, gecode, and chuffed. We are not sure if Choco supports large integers.
Activity
EmirDe commentedon Mar 17, 2026
Thank you for reporting the issues. We discussed this internally, but I realise now that we have not replied to you.
At the core of this issue (and the others you posted) is the assumption that the variables will have relatively small domains, so overflows will not occur. This is true for (almost) all MiniZinc Challenge benchmarks. In the past, we did some experiments with other CP solvers, and we also noted that other solvers have this issue as well. Essentially, solvers hope that overflows do not occur, and if they do, that they do not affect the end result. Most silently fail, which is not great. In your case, you seem to have a specific application where having (arbitrarily?) large domains may be relevant.
We discussed handling this in Pumpkin in a principled way, but we are not sure when we would make this change, since it does require a bit of work to ensure it does not degrade performance for instances that do not need large domains. One of the main issues for us is that we do not have good use cases for such functionality. If we could get some benchmarks/instances where this is needed, that would be much appreciated!
(See for example this issue: #330)
Edit: add "when" in the first sentence of the last paragraph.
pellico commentedon Mar 17, 2026
Here my use cases:
I am interested to know which other solver have evaluate. Does Choco solver have the same ?
AndrewJBrown-MMSD commentedon Mar 17, 2026
Chiming in with a use case for a larger domain than
i32; I'm using the constraint solver to minimize the number of partitioned queries in a larger overall set based on a total number of anticipated rows. The database can easily crack 2.1B rows for queries, but the number to optimize for would not surpass 1T; the constraints are to partition the queries to return chunks no more than CHUNK_LIMIT in size based on 2 dimensions (varname and datetime cutpoint). This is a case where expanding the bounds would be useful because it could handle the larger number while working on a solution, even though CHUNK_LIMIT is decidedly within-bounds (~100,000).Obviously an open question whether you want to support the use/intent or if there's some better way to handle the problem but this would certainly make the library accommodate more flexible/general-purpose use with different domains.
EmirDe commentedon Mar 24, 2026
Thank you both for your input! It is interesting to hear about these use cases, since we did not have such applications in mind. If you could provide some small benchmarks, we can try out the solver once we implement unbounded integers, which would be helpful. No rush from our side.
Agreed! It seems relevant since it would make the solver more reliable, which is our prime concern. That said, I am not sure when we would do this, but it is relevant. We will think about it in the next period, but we cannot give any estimates at the moment. We would need to see how to incorporate this without slowing down the solver for cases when this is not needed.
We tried ortools, gecode, and chuffed. We are not sure if Choco supports large integers.