Skip to content

ValueError: max() arg is an empty sequence in ExactSumConstraint.preProcess() #103

@gummiangler

Description

@gummiangler

When using ExactSumConstraint, the solver sometimes raises:
ValueError: max() iterable argument is empty
This happens inside ExactSumConstraint.preProcess() when the code calls max(domains[variable])
after domain pruning.
If all possible values for a variable are removed during the preprocessing step, the corresponding domain becomes empty, causing max() and min() to fail.

Root Cause
In preProcess():

for value in domain[:]:
    if value * multiplier + other_vars_min > exactsum:
        domain.remove(value)
    if value * multiplier + other_vars_max < exactsum:
        domain.remove(value)

# Then later:
self._var_max = { variable: max(domains[variable]) * multiplier for variable, multiplier

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions