Skip to content

Bug Fix: Check to avoid partial bookings of multiple persistent mandatory resources with alternatives#321

Open
DT-one wants to merge 1 commit intotaskjuggler:masterfrom
DT-one:master
Open

Bug Fix: Check to avoid partial bookings of multiple persistent mandatory resources with alternatives#321
DT-one wants to merge 1 commit intotaskjuggler:masterfrom
DT-one:master

Conversation

@DT-one
Copy link
Copy Markdown

@DT-one DT-one commented Apr 29, 2026

I found a bug while trying to make a schedule with a pool of material resources like rooms (resources with an efficiency = 0.0) and a pool of normal resources like teachers, which relies heavily on the constraints 'persistent' and 'mandatory'

A teacher should be scheduled to teach an entire class in a room.

I found that the section of TaskScenario that checks whether all mandatory resources are available sometimes passes when one of the current persistent resources is not available. It seems to occur when the current persitent resource is not included in the list of alternatives that is given to the mandatory check.

The result is bookResource() fails on one or more persistent mandatory resources, but books the rest of the persistent resources that are available. This can result in a teacher scheduled for a class bit with no room.

In the supplied example it can be seen that Class 3 and Class 2 are both scheduled to be conducted in room 1.
IncorrectBehaviour

After making my commit, this conflict no longer occurs
CorrectBehaviour

/* 1. Project Header: ID, Name, Version, and Timeframe */
project prj "My First Project" "1.0" 2026-03-30 - 2027-03-30 {
  timeformat "%Y-%m-%d"
  shorttimeformat "%H:%M"
  now 2026-03-30
}

/* 2. Resources: Who is doing the work? */
/* 2.1 People */
resource t1 "Teacher1"
resource t2 "Teacher2"
resource t3 "Teacher3"

macro allocate_Teacher [
  allocate t1 {alternative t2
               select minallocated
               persistent
               mandatory
               }
]

/* 2.2 Rooms */
resource r1 "Room1" { efficiency 0.0 }
resource r2 "Room2" { efficiency 0.0 }
resource r3 "Room3" { efficiency 0.0 }

/* 3. Tasks: What needs to be done? */
task c001 "Class1" { effort 4h  ${allocate_Teacher} allocate r1 { alternative r2, r3 select minallocated persistent mandatory } }
task c002 "Class2" { effort 8h  ${allocate_Teacher} allocate r1 { alternative r2, r3 select minallocated persistent mandatory } priority 600 start 2026-03-31}
task c003 "Class3" { effort 16h ${allocate_Teacher} allocate r1 { alternative r2, r3 select minallocated persistent mandatory } priority 550 }
task c004 "Class4" { effort 24h ${allocate_Teacher} allocate r1 { alternative r2, r3 select minallocated persistent mandatory } }
task c005 "Class5" { effort 26h ${allocate_Teacher} allocate r1 { alternative r2, r3 select minallocated persistent mandatory } }

/* 4. Reports: Define what you want to see */
resourcereport "ResourceGanttCorrected" {
  formats html
  headline "Resource Allocation ChartCorrected"
  loadunit hours
  columns no, name, start, end, resources, effort, duration, chart { scale hour width 1000}
  hidetask ~isleaf()
}

taskreport "PlanCorrected" {
  formats html
  headline "My Project Gantt ChartCorrected"
  loadunit hours
  # The 'chart' column generates the visual Gantt bars
  columns bsi { title 'WBS' }, name, start, end, duration, effort, resources, chart { scale hour width 1000 }
}

taskreport "GanttChartCorrected" {
  formats html
  headline "Project Gantt ChartCorrected"
  columns no, name, start, end, effort, duration, chart { scale hour width 1000 }
  timeformat "%a %Y-%m-%d"
  loadunit hours
  hideresource 0
}

@DT-one DT-one changed the title Bug Fix: Check to avoid partial and double bookings of multiple persistent mandatory resources with alternatives Bug Fix: Check to avoid partial bookings of multiple persistent mandatory resources with alternatives Apr 29, 2026
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

Successfully merging this pull request may close these issues.

1 participant