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

[BUG] Exception when running TeacherTimetable example #74

Open
TrevorDArcyEvans opened this issue Jan 30, 2025 · 1 comment
Open

[BUG] Exception when running TeacherTimetable example #74

TrevorDArcyEvans opened this issue Jan 30, 2025 · 1 comment

Comments

@TrevorDArcyEvans
Copy link

  • Steps to reproduce

    • run TeacherTimetable example
    • get unhandled exception:
       at Decider.Csp.Integer.DomainBinaryInteger.get_InstantiatedValue() in /_/Csp/Integer/DomainBinaryInteger.cs:line 125
       at Decider.Csp.Integer.VariableInteger.get_InstantiatedValue() in /_/Csp/Integer/VariableInteger.cs:line 87
       at Decider.Csp.Integer.VariableInteger.get_Value() in /_/Csp/Integer/VariableInteger.cs:line 165
       at Decider.Example.TeacherTimetable.TeacherTimetable.Main() in /home/trevorde/dev/Decider/Examples/TeacherTimetable/TeacherTimetable.cs:line 97
    
  • Observed result

    • unhandled exception
      • DeciderException("Trying to access InstantiatedValue of an uninstantiated domain.")
    • State.Search returns StateOperationResult.Unsatisfiable
  • Expected result

    • no exceptions
    • example should be solvable
@TrevorDArcyEvans
Copy link
Author

Looks like incorrect use of Aggregate

The following changes seem to fix it:

			// No teacher teaches more than 5 hours per weekday
			foreach (var teacher in Enumerable.Range(1, numberOfTeachers))
			{
				foreach (var day in Weekdays)
				{
					constraints.Add(new ConstraintInteger(
						new ExpressionInteger(day.
						Select(x => x == teacher).
						Count()) <= 5));
				}
			}
			// No teacher teaches more than 27 hours per week
			foreach (var teacher in Enumerable.Range(1, numberOfTeachers))
			{
				constraints.Add(new ConstraintInteger(
					new ExpressionInteger(Week.
					Select(x => x == teacher).
					Count()) <= 27));
			}

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

1 participant