KHE diary for 2026
==================

At the end of 2025 I was working on nurse rostering.  The
current task was to design a more sophisticated time sweep
algorithm which uses optimal resource assignment using
dynamic programming to estimate the cost of assigning and
not assigning each resource on the current day.

A typical result from the end of last year (30 December 2025) was

  [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
    0.01470 0.01510 0.01535 0.01570 0.01570 0.01575 0.01590 0.01595
    0.01605 0.01615 0.01620 0.01670
  ] 0.01435 is best cost (Nurse: 4 0.01535, Nurse:Trainee: 8 0.01470)

There was a 1370 on 29 December 2025:

  [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
    0.01470 0.01480 0.01490 0.01550 0.01590 0.01595 0.01610 0.01630
    0.01635 0.01660 0.01670 0.01685
  ] 0.01370 is best cost (Nurse: 4 0.01470, Nurse:Trainee: 8 0.01480)

but that seems to have been an outlier.

31 December 2025 (copied from 2025 diary).  Did a test of
  KheMoveUnnecessaryAssignments, placing it just before each
  call on ejection chains.  I got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01470 0.01535 0.01540 0.01555 0.01570 0.01575 0.01590 0.01605
      0.01610 0.01620 0.01655 0.01670
    ] 0.01420 is best cost (Nurse: 10 0.01555, Nurse:Trainee: 8 0.01470)

  This is marginally better than the 1435 I was getting yesterday.
  But whether it is due to KheMoveUnnecessaryAssignments or just to
  the changed time weighting favouring ejection chains, or to chance,
  who knows?  Also the second best is worse.  So I'm not using it.

  Thinking about how time sweep interacts with sequence constraints.
  What we need is something that time sweep can call to ask whether
  a given resource should preferably be free or busy at the next
  time group, taking into account:

     * Existing assignments
     * Unavailable time constraints
     * Total workload constraints
     * Free day sequence constraints
     * Busy day (and time) sequence constraints
     * History
     * Complete weekends constraints
     * Max working weekends constraints

  Can we write a dynamic programming algorithm which solves for
  a single resource and decides only whether it should be free
  or busy?  Would that do what we want?  But we need to allow
  for cases where it is equally reasonable to be either.  A
  cost of being busy, and a cost of being free, would be good.
  The current dynamic solver, with a single resource, and
  keeping the existing assignments, plus one busy and one
  free on the next day, would do the trick.  Is there time?

1 January 2026.  Looked at the time sweep documentation.
  Demand sets look as though they won't need any changes,
  the problem is the edge cost which at present is just
  the solution cost; we need the option of making it
  the resource cost from dynamic, plus task costs and
  (I suppose) adjustments as usual.

  Plus we need to be able to run dynamic repeatedly on
  various single resources and different ranges.  But
  it's clear from the documentation that that can be done.
  Although it does say "Calls which assign and unassign
  resources to proper root tasks are also a problem", so
  we need to look into that.  We could build one new
  solver per day, that would get around this problem.

2 January 2026.  How to do it.  For each edge we are
  thinking of including, make the assignment and then
  call DynamicTest with just the resource in question
  and a day range starting on the day after the current
  day.  Use the cost returned by DynamicTest as the
  cost of the edge instead of the solution cost.

  In KheTimeSweepAssignResources, we can use tss->cutoff_off,
  tss->rematch_off, tss->redo_off, and tss->two_phase (and
  possibly other flags) to turn off odd things that we
  probably won't need.  Then the real new work will be done
  within KheResourceMatchingSolverSolveWithLookahead, by
  fiddling with KheEdge, where it calls KheCostWithLookahead
  (which can in effect be swapped out and replaced by Dynamic).

  Added KheDynamicResourceSolverAddFixedAssignment, so that the
  caller of Dynamic can fix an assignment before the solve starts.
  When we are implementing the new version of KheEdge we can call
  this to say which task r is to be assigned to on the first day.

3 January 2026.  Audited yesterday's changes to Dynamic, made a
  few small changes.  All good.  Documented changes to time
  sweep assignment, now I need to implement them.

  Added dynamic parameter to KheResourceMatchingSolverSolve.
  Done some boilerplace, creating and deleting a dynamic
  solver within the resource matching module.  Now I need
  to use it to calculate edge costs.

4 January 2026.  Audited yesterday's stuff.  All good,
  just KheEdgeDynamic still to do.

5 January 2026.  Implemented KheEdgeDynamic.  It needs an audit
  and test.  Also I'm not sure about some details of the costs;
  some debug output would be very helpful.  Where do I calculate
  the cost of leaving a resource r unassigned?

  Took a break and looked over my integrated hospital planning
  paper.  It's not great.  I tried to make the events more
  natural but then the number of unimplementable constraints
  blew out (see file alt_*.tex for what I did).

  What about a paper called "Two key ideas for generalizing
  timetabling models" which covers my ideas about modelling
  time and generalizing constraints?  No good, I've already
  written it and published it at the 2022 PATAT.

7 January 2026.  All right, no more procrastination.  I have to
  change khe_sr_resource_matching.c to support the dynamic flag.
  This includes calling Dynamic, but it also includes adding
  edges representing the non-assignment of resources.  Copied
  khe_sr_resource_matching.c to save_khe_sr_resource_matching.c.

  Started testing.  Dynamic is playing up, getting an inconsistent
  monitor.  Also the debug output seems to be saying that HN_0
  is not busy on 1Mon, despite fixture <HN_0, 0, 1Mon:Early.15>.
  The two bugs could possibly be the same bug.

8 January 2026.  Thinking about monitor frames.

9 January 2026.  I've now created a KHE_MONITOR_FRAME structural
  resource solver and moved all the monitor frame code from
  khe_sr_time_sweep.c to it in khe_sr_monitor_frame.c.

10 January 2026.  Thinking about mtask finders for doing what
  we need with monitors.  They certainly classify tasks by day,
  although not tasks that start on a given day (although interval
  grouping does do that), but at present they do not go on to
  classify monitors by day.  We need

  (1) Find all tasks that start on a give day;

  (2) Find all monitors that monitor those tasks.

  And it is (2) that we need to adjust.  But we already have
  sweep times for monitors, which suggests that we don't have
  to go via tasks.  If the monitor is an event resource monitor
  and its first time lies in a given day, then the monitor
  belongs to that day.

  So let's add this to monitor frames.  I've now documented
  KheMonitorFrameAssignReduce and KheMonitorFrameAssignUnReduce,
  and implemented them, and replaced the corresponding functions
  in khe_sr_dynamic_vlsn.c with calls to these ones.  And I've
  written the dynamic version of time sweep, at last:

     begin er adjust for all days
     for each day d
     {
       end er adjust for day d
       find edge costs and match day d
     }

  It needs an audit, then it will be ready to test.  I've moved
  the "end er adjust for day d" from where I had it before.

11 January 2026.  OK, I think the problem is that with the other
  kinds of fixed tasks the task is actually assigned to the
  resource it's fixed to, whereas with the new kind of fixed
  task the task is obliged to be assigned to it but not
  actually assigned to it, so when KheDrsResourceOnDayIsFixed
  returns true no actual assignment is made.  So it looks like
  KheDrsResourceOnDayIsFixed should return false but after that
  we need to reduce our search options to just the fixed one.

  KheDrsResourceOptionallyAddMTaskSoln has to be called just
  once for its drd parameter when drd is fixed.  Done and
  audited and ready to test.

12 January 2026.  Realized that KheDynamicResourceSolverAddFixedAssignment
  could add an unsatisfiable requirement, in which case the dynamic solve
  will fail to find a solution.  I've made sure that that is clear to the
  caller when KheDynamicResourceSolverTest is called, so that we don't
  install any matching edge in that case.  All done and documented.

  I've written a new "Dynamic time sweep" section which lays it all
  out very concretely, including stating that a separate implementation
  of resource matching and time sweep is used.  I need to audit this
  new doc and then get going on implementing it.  It's better this way.

13 January 2026.  There is a risk that some edge cost will be negative,
  given that we are adding asst_cost - non_asst_cost to each edge cost.
  I've documented this and a simple workaround.

  Working on khe_sr_dynamic_time_sweep.c.  Boilerplate all done.
  Currently working on KheDynamicTimeSweepSolverAssignOneDay.  It's
  all done except for the edge costs (KheDtsSolverEdge).  And only
  423 lines so far.

14 January 2026.  Working on khe_sr_dynamic_time_sweep.c.  It all
  seems to be done; 555 lines.  Audited and ready to test.  I
  started this about 7 January, although the plan changed along
  the way.

15 January 2026.  Testing khe_sr_dynamic_time_sweep.c today.  Fixed
  a few small bugs.  I'm getting the right demand and supply nodes
  now.  Next come the edges.  Restricting to must-assign tasks.
  It seems to be running more or less fast enough.


  The first few days seem to be working, after that we seem to be
  getting empty matchings, not sure why.  On 1Sat there are the
  usual demand nodes (with some omissions) and these supply nodes:

    1Sun:Early.5[Nurse]
    1Sun:Early.10[Caretaker]
    1Sun:Early.11[Caretaker]
    1Sun:Early.12[Caretaker]
    1Sun:Day.5[Nurse]
    1Sun:Day.10[Caretaker]
    1Sun:Day.11[Caretaker]
    1Sun:Day.12[Caretaker]
    1Sun:Day.13[Caretaker]
    1Sun:Late.0[HeadNurse]
    1Sun:Late.5[Nurse]
    1Sun:Late.10[Caretaker]
    1Sun:Late.11[Caretaker]
    1Sun:Late.13[Caretaker]
    -

  But there are no edges at all, not even to non-assignment.  How
  could that be?  Does it mean that dynamic resource assignment is
  failing to find any solution?  Why would that be?  Could it be
  a time limit thing?  Anyway we need one line of debug from each
  call, saying what happened.

16 January 2026.  The two undeleted arenas are each the second
  arena created by KheDynamicTimeSweepAssignResources.  Not
  the one created by the call to KheSolnArenaBegin within the
  body of KheDynamicTimeSweepAssignResources, but one created
  after that and before the first KheDtsSolverAssignOneDay.
  (There are two of them because one is created for type Nurse
  and then later another is created for type Trainee.)

  It's almost certainly the monitor frame.  Let's pass it
  an arena.  Yep, problem fixed.

  Working on all the " = false" cases.  I tried increasing the
  cost limit to KheCost(INT_MAX, INT_MAX) when there is a fixed
  assignment, and indeed it makes sense to do that; but I seem
  to have even more " = false" cases now.  Here's the first one:

    ending day 0 (1Fri), undominated 1, kept 1
    ending day 1 (1Sat), undominated 5, kept 5
    ending day 2 (1Sun), undominated 4, kept 4
    ending day 3 (2Mon), undominated 15, kept 15
    ending day 4 (2Tue), undominated 23, kept 23
    ending day 5 (2Wed), undominated 52, kept 52
    ending day 6 (2Thu), undominated 54, kept 54
    ending day 7 (2Fri), undominated 110, kept 110
    ending day 8 (2Sat), undominated 200, kept 200
    ending day 9 (2Sun), undominated 77, kept 77
    ending day 10 (3Mon), undominated 55, kept 55
    ending day 11 (3Tue), undominated 59, kept 59
    ending day 12 (3Wed), undominated 96, kept 96
    ending day 13 (3Thu), undominated 89, kept 89
    ending day 14 (3Fri), undominated 95, kept 95
    ending day 15 (3Sat), undominated 258, kept 258
    ending day 16 (3Sun), undominated 0, kept 0
    ending day 17 (4Mon), undominated 0, kept 0
    ending day 18 (4Tue), undominated 0, kept 0
    ending day 19 (4Wed), undominated 0, kept 0
    ending day 20 (4Thu), undominated 0, kept 0
    ending day 21 (4Fri), undominated 0, kept 0
    ending day 22 (4Sat), undominated 0, kept 0
    ending day 23 (4Sun), undominated 0, kept 0
    KheDynamicResourceSolverDoSolve(HN_4, 1Fri-4Sun,
      <HN_4, 4, 1Fri:Early.0>) = false

  So what happened in between 3Sat and 3Sun?  I tried removing the
  call to KheDynamicResourceSolverAddFixedAssignment and got this
  as the first fail:

    ending day 0 (1Thu), undominated 4, kept 4
    ending day 1 (1Fri), undominated 9, kept 9
    ending day 2 (1Sat), undominated 15, kept 15
    ending day 3 (1Sun), undominated 11, kept 11
    ending day 4 (2Mon), undominated 33, kept 33
    ending day 5 (2Tue), undominated 37, kept 37
    ending day 6 (2Wed), undominated 71, kept 71
    ending day 7 (2Thu), undominated 74, kept 74
    ending day 8 (2Fri), undominated 89, kept 89
    ending day 9 (2Sat), undominated 130, kept 130
    ending day 10 (2Sun), undominated 52, kept 52
    ending day 11 (3Mon), undominated 115, kept 115
    ending day 12 (3Tue), undominated 123, kept 123
    ending day 13 (3Wed), undominated 145, kept 145
    ending day 14 (3Thu), undominated 7, kept 7
    ending day 15 (3Fri), undominated 0, kept 0
    ending day 16 (3Sat), undominated 0, kept 0
    ending day 17 (3Sun), undominated 0, kept 0
    ending day 18 (4Mon), undominated 0, kept 0
    ending day 19 (4Tue), undominated 0, kept 0
    ending day 20 (4Wed), undominated 0, kept 0
    ending day 21 (4Thu), undominated 0, kept 0
    ending day 22 (4Fri), undominated 0, kept 0
    ending day 23 (4Sat), undominated 0, kept 0
    ending day 24 (4Sun), undominated 0, kept 0
    KheDynamicResourceSolverDoSolve(CT_66, 1Thu-4Sun, ) = false

  So KheDynamicResourceSolverAddFixedAssignment does not seem
  to be the problem.  And there seem to be plenty of supply
  nodes (33 including non-assignment).

  Without KheDynamicResourceSolverAddFixedAssignment we are
  making the same call over and over again, and at first it
  succeeds but subsequently it fails.  So there is something
  going wrong with the carryover from one solve to the next.
  And it remains wrong when we move from one resource to the
  next.  Perhaps there are no tasks available to assign?
  Could they be being assigned by the solution but then
  not freed?  What about a check that the number of open
  tasks (or assigned tasks, etc.) is the same at the end
  as at the start?

17 January 2026.  Continuing to work on yesterday's problem.  I
  tried creating a new solver for every call.  That fixed some
  of the problems but not all of them (it makes HN_2 work but
  HN_6 is failing even on 1Mon, for no apparent reason).  Could
  tasks be remaining assigned, so that after a few goes there
  are no tasks to assign?  Need a print of open tasks on the
  first day.

  OK, the problem is "= false no_soln (time limit reached)".
  So we need to work out which time limits are in force and
  get rid of them.  It may be the 0.5 seconds per day - no,
  that's for interval grouping.  For now I've just got rid
  of the overall time limit, and that seems to have fixed
  the problem.  I'm now doing a run with no time limit
  but not rebuilding the solver.  It seems to be working.
  At any rate I've got all the way through to the end of
  KheDynamicTimeSweepAssignResources:

    KheDynamicTimeSweepAssignResources returning true (0.02710 < 162.22980)

  This is after the Trainee solve.  Not a great result for
  such a long time spent.

  There are also calls made by the VLSN solver, almost all
  of which return with no soln; but a few do find things.

  And here is proof that we ran right through:

    [ "INRC2-4-100-0-1108", 1 solution, in 40.8 mins: cost 0.01635 ]
      0.01635 is best cost (diversifier 0)

  All the calls made from dynamic time sweep returned true.
  The solution is nothing to write home about however.

  When solving for a single resource, we only need to open tasks
  whose domain contains that resource.  In general, we only need
  to open tasks which are assignable by at least one resource.
  Could save a lot of time.  But we're already doing that.  I
  have however changed the code so that the number of tasks
  opened in each mtask is at most the number of resources.

  Doing some timings to see how fast KheDynamicTimeSweepAssignResources
  is.  I'me getting results like this for each day:

    KheDtsSolverAssignOneDay returning (6.5 secs)
    KheDtsSolverAssignOneDay returning (4.8 secs)
    KheDtsSolverAssignOneDay returning (4.4 secs)
    KheDtsSolverAssignOneDay returning (3.9 secs)
    ...
    KheDtsSolverAssignOneDay returning (1.1 secs)

  So it's not hopelessly slow.  Can it be sped up at all?  Do we
  need the absolute optimal assignment here?

18 January 2026.  Did a run that just did the dynamic time sweep (for
  both resource types) and then stopped:

    [ "INRC2-4-100-0-1108", 1 solution, in 115.8 secs: cost 0.04060 ]

  The plan now is to work out in detail why the result is so bad.

    Summary 						Inf. 	Obj.
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	   	         180
    Avoid Unavailable Times Constraint (9 points) 	   	  90
    Cluster Busy Times Constraint (45 points) 	        	1330
    Limit Active Intervals Constraint (75 points) 	   	2460
    ----------------------------------------------------------------
      Grand total (135 points) 	   				4060

  Who would have thought it:  the costs for all but limit active
  intervals monitors are actually not bad, but limit active intervals
  monitors are a complete disaster - why?

  Perhaps it's time to admit that dynamic time sweep is a dog.
  I've been working on it since 1 January, and now I think it's
  time to stop flogging a dead horse.  The aim was always to get
  a better initial solution, and that has certainly not happened.
  Here is the regular time sweep's initial solution:

    [ "INRC2-4-100-0-1108", 1 solution, in 15.9 secs: cost 0.03285 ]

    Summary 						Inf. 	Obj.
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	   	         120
    Avoid Unavailable Times Constraint (9 points) 	   	 130
    Cluster Busy Times Constraint (45 points) 	        	1700
    Limit Active Intervals Constraint (75 points) 	   	1335
    ----------------------------------------------------------------
      Grand total (135 points) 	   				3285

  So although this is not wonderful either, it is better, and it is a
  lot faster (most of the 16 secs goes on interval grouping).  It's
  testament to the old truth that quick construction followed by
  repair is better than elaborate construction without repair.
  How often have we learned that lesson?

  Had a look at how ordinary time sweep progresses.  It seems that all
  its bits (solve, after-solve, and rematch on each day, and redo of
  each day at the end) are finding worthwhile improvements quickly.
  There does not seem to be any obvious way to do better.  It runs
  very quickly so dropping some parts of it would not do much.

  Documented pgroups in interval grouping.  We're sticking with them.

  Removed all trace of dynamic from the regular time sweep.  Back
  to the usual kind of solve, got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01480 0.01520 0.01560 0.01565 0.01600 0.01630 0.01640 0.01655
      0.01665 0.01715 0.01720 0.01835
    ] 0.01470 is best cost (Nurse: 8 0.01480, Nurse:Trainee: 0 0.01520)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 180
    Avoid Unavailable Times Constraint (6 points)      70   	  80
    Cluster Busy Times Constraint (32 points) 	      950	1030
    Limit Active Intervals Constraint (7 points)       75   	 180
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1470

    Nurse                            LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     20       22
    O  Available times (negative)     36       39
    Y  Unnecessary assignments         1        3
    X  Unassigned tasks                5        6
    ---------------------------------------------
    U - O + Y - X                    -20      -20

    Nurse:Trainee                    LOR      KHE
    ---------------------------------------------
    U  Available times (positive)      4        7
    O  Available times (negative)      7       11
    Y  Unnecessary assignments        18       19
    X  Unassigned tasks                0        0
    ---------------------------------------------
    U - O + Y - X                     15       15

  Here 1470 is rel = 1.18.  Have things decayed, then?  A bit, perhaps.
  I was getting 1435 at the end of last year, as documented above.
  There was even a 1370 at one point.  But these were outliers.
  If we can get the 180 for limit active intervals monitors down
  to the LOR value, 75, that would save 105 points and lead to cost
  1365 which is rel = 1.09.  So it's not impossible to get there.

  The limit active intervals defects are (* means also in LOR):

    Constraint Id / Point   Calculation 			Inf.   Obj.
    ----------------------------------------------------------------------
      Constraint:15/CT_66   15 * Linear(2 - 4Fri2) 	   	        15
    * Constraint:17/HN_8    15 * Linear(4 - History 1 - 1Mon4 - 1Tue4)  15
      Constraint:17/TR_84   15 * Linear(4 - 1Sat4 - 1Sun4 - 2Mon4)      15
    * Constraint:17/TR_88   15 * Linear(4 - History 1 - 1Mon4) 	        30
      Constraint:17/TR_92   15 * Linear(4 - History 2 - 1Mon4) 	        15
    * Constraint:17/TR_98   15 * Linear(4 - History 2) 	   	        30
      Constraint:20/CT_43   30 * Linear(*2Sat + *2Sun + ... *3Wed - 4)  30
      Constraint:23/HN_14   30 * Linear(3 - 3Thu - 3Fri) 	        30
    ----------------------------------------------------------------------
	Total (8 points) 	   	   	   		       180

  Here is a 10 minute run:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 9.1 mins:
      0.01465 0.01520 0.01555 0.01560 0.01560 0.01600 0.01630 0.01645
      0.01665 0.01685 0.01720 0.01805
    ] 0.01465 is best cost (diversifier 8)

  Not much better.

19 January 2026.  Grinding down INRC2-4-100-0-1108.  Back to the
  5-minute run.  Let's have a closer look at the limit active
  intervals defects above, especially for Constraint:17.

  Constraint:17/TR_84.  The problem here seems to be TR_88 with
  history 2: interval grouping added 3 night shifts, but the final
  KHE and LOR solutions added none, probably because TR_88 has a
  total workload limit of only 6.  This left a sequence of 7 night
  shifts which can only be broken 3-4 or 4-3, leaving a group of 3
  which TR_84 got lumbered with.  Not much I can do here.

  Constraint:17/TR_92.  There is a shortage of Night shifts to
  fill this spot.  LOR handles it by assigning two optional
  shifts, which is expensive in another way.

  Constraint:15/CT_66.  A lone Day shift.  There is a following
  sequence of two Day shifts that it could be tacked onto, but
  it's hard to see what to then do with the sequence of 3.  A
  possible repair sequence is to combine the CT_66 1Fri Day with
  the CT_74 1Sat-1Sun Day to form a sequence of 3 Day shifts,
  and then add that to CT_63 and move its nearby sequence of
  3 Late shifts to CT_74, clobbering one optional Day shift
  as we go.

  More generally, for isolated shifts we could identify a
  suitable sequence, then we could unassign it and group
  it, then we could try repairs that assign it.  A whynot
  of those repairs would be worth a look.

  But the current best 5 minute solution does not contain
  that defect.  It is

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01480 0.01520 0.01550 0.01555 0.01560 0.01630 0.01640 0.01655
      0.01665 0.01670 0.01720 0.01835
    ] 0.01455 is best cost (Nurse: 9 0.01550, Nurse:Trainee: 0 0.01520)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 150
    Avoid Unavailable Times Constraint (6 points)      70   	  70
    Cluster Busy Times Constraint (32 points) 	      950	1040
    Limit Active Intervals Constraint (7 points)       75   	 195
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1455

  which is rel = 1.16.

    Constraint Id / Point 	Calculation 	Inf. 	             Obj.
    ---------------------------------------------------------------------
    * Constraint:17/HN_8  15 * Linear(4 - History 1 - 1Mon4)           30
      Constraint:17/NU_33 15 * Linear(3Wed4 + 3Thu4 + ... + 4Mon4 - 5) 15
      Constraint:17/TR_84 15 * Linear(4 - 1Sat4 - 1Sun4 - 2Mon4)       15
    * Constraint:17/TR_88 15 * Linear(4 - History 1 - 1Mon4)           30
      Constraint:17/TR_92 15 * Linear(4 - History 2 - 1Mon4) 	       15
    * Constraint:17/TR_98 15 * Linear(4 - History 2) 	   	       30
      Constraint:18/HN_14 30 * Linear(2 - *3Tue) 	   	       30
      Constraint:18/NU_31 30 * Linear(2 - *3Tue) 	   	       30
    ---------------------------------------------------------------------
	Total (8 points) 	   	   	   		      195

  This is quite poor.  It would be good to find something special to
  target the last two defects, which are undersized sequences of free
  days.  Reducing by 60 points would give 1395, which is rel = 1.12.
  LOR has no problems at this point.

20 January 2026.  In the current solution, we could get rid of an
  optional task by swapping HN_15 <--> HN_10 on 3Mon-3Wed and then
  dropping the optional task.  This would increase HN_15's available
  workload from 2 to 3, but not save any cost.  What happened to that
  redundancy thing?  Added rrd to the diy solver and got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01525 0.01525 0.01565 0.01595 0.01605 0.01620 0.01680 0.01700
      0.01745 0.01755 0.01775 0.01795
    ] 0.01495 is best cost (Nurse: 3 0.01525, Nurse:Trainee: 0 0.01565)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 180
    Avoid Unavailable Times Constraint (6 points)      70   	  60
    Cluster Busy Times Constraint (32 points) 	      950	1090
    Limit Active Intervals Constraint (7 points)       75   	 165
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1495

  So the result is inferior, but what about unnecessary assignments?
  There were 3 + 19 previously, now there are 0 + 19.  So that should
  be a positive, but it doesn't seem to be.

  I also tried moving rrd so that it applies to just the first rec,
  nothing else.  Got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01500 0.01520 0.01555 0.01560 0.01565 0.01640 0.01660 0.01665
      0.01665 0.01670 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 9 0.01565, Nurse:Trainee: 0 0.01520)

  with 2 + 19 italic entries.A  Now back to the first rrd, the one
  that applies to the entire first phase, but with a 10-minute run:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 8.8 mins:
      0.01525 0.01525 0.01565 0.01575 0.01600 0.01650 0.01680 0.01695
      0.01720 0.01725 0.01765 0.01775
    ] 0.01495 is best cost (Nurse: 3 0.01525, Nurse:Trainee: 0 0.01565)

  It's no better.  So I'm going back to solving without rrd:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01500 0.01520 0.01555 0.01560 0.01565 0.01630 0.01640 0.01655
      0.01665 0.01670 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 9 0.01565, Nurse:Trainee: 0 0.01520)

    Constraint Id / Point    Calculation         Inf.              Obj.
    ------------------------------------------------------------------
      Constraint:16/CT_72    15 * Linear(2 - 1Mon3)                 15
    * Constraint:17/HN_8     15 * Linear(4 - History 1 - 1Mon4)     30
      Constraint:17/NU_33    15 * Linear(3Wed4 + ... + 4Mon4 - 5)   15
      Constraint:17/TR_84    15 * Linear(4 - 1Sat4 - 1Sun4 - 2Mon4) 15
    * Constraint:17/TR_88    15 * Linear(4 - History 1 - 1Mon4)     30
      Constraint:17/TR_92    15 * Linear(4 - History 2 - 1Mon4)     15
    * Constraint:17/TR_98    15 * Linear(4 - History 2)             30
      Constraint:18/HN_14    30 * Linear(2 - *3Tue)                 30
      Constraint:18/NU_21    30 * Linear(2 - *3Tue)                 30
    ------------------------------------------------------------------
          Total (9 points)                                         210

  I've decided that rrd is a reasonable idea but one whose results do
  not justify its inclusion.

  The current best solution still has the two isolated free day defects
  on 3Tue, but the resources now are HN_14 and NU_21.

  I thought of getting rid of isolated free day defects by trying to
  swap all the way to the end, but that is already being done.  What
  about swapping all the way to the beginning?

  Constraint:16/CT_72 is an interesting one.  CT_72 starts off with
  an isolated Late.  There are no 1Mon isolated Late shifts in LOR
  except NU_34, which KHE also has.  The problem with KHE is that
  CT_72 has an isolated Late, and then NU_26 has a Late sequence
  starting on 1Tue, whereas LOR has no Late sequences at all starting
  on 1Tue.  So why not move the CT_48 1Tue:Late to CT_72?  CT_72 has
  2 free days of history, if we move it that will make 4 free days
  at the start, but that is allowed.  So we need a whynot here.

  The whynot is that CT_48 has max workload 15 and those resources
  have min consecutive days = 4.  The move was tried but there was
  a cost of 30 because CT_48's first sequence dropped from 4 to 3.

  Back to the regular 5-minute solve, which is producing this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01500 0.01520 0.01560 0.01565 0.01600 0.01625 0.01630 0.01640
      0.01665 0.01715 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 9 0.01565, Nurse:Trainee: 0 0.01520)

  I need to grind it down.

  CT_72 has history 5 in the constraint that requires between 4 and 7
  busy days.  So it can work one or two consecutive days at the start
  of the cycle.  It also has history 5 in consecutive Night shifts,
  so it can't work any more of those.  So its options at the start
  of the cycle are to be free for 3-4 days, or to work exactly 2
  Early, Day, or Late shifts (less would violate min consecutive
  same shifts rules, more would violate max consecutive busy days).
  LOR gives CT_72 4 consecutive free days at the start.

  Altogether, the way CT_72 is being handled is quite poor, because
  there is a gap of 4 free days after that first Late.  So there is
  very little hope of getting rid of that defect, as things stand.
  How did it come about in the first place?  Did time sweep put it
  there?

23 January 2026.  I've been pondering where to go from here but not
  actually doing very much.

  What about cutting down the time devoted to solvers other than rec?
  I've tried giving rec 3 times its current allocation.  For the usual
  5-minute run I got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01480 0.01520 0.01555 0.01560 0.01565 0.01630 0.01640 0.01645
      0.01665 0.01670 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 8 0.01480, Nurse:Trainee: 0 0.01520)

  No better in the end.  So I tried giving 3 times to rec and rrm,
  which amounts to demoting rdv.  Got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01480 0.01520 0.01555 0.01560 0.01565 0.01630 0.01630 0.01660
      0.01665 0.01670 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 8 0.01480, Nurse:Trainee: 0 0.01520)

  So then, just to be fair, I tried tripling the time allocated to rdv:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01500 0.01560 0.01575 0.01575 0.01600 0.01620 0.01630 0.01630
      0.01665 0.01715 0.01735 0.01835
    ] 0.01490 is best cost (Nurse: 9 0.01575, Nurse:Trainee: 8 0.01500)

  A bit worse, quite reasonably.  So go back to even time for all.
  What about best of 6 rather than best of 12?

    [ "INRC2-4-100-0-1108", 6 threads, 6 solves, 5.0 mins:
      0.01520 0.01560 0.01630 0.01630 0.01665 0.01670
    ] 0.01510 is best cost (Nurse: 4 0.01665, Nurse:Trainee: 0 0.01520)

  So it seems out old basic is the best option:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01480 0.01525 0.01560 0.01565 0.01600 0.01630 0.01640 0.01655
      0.01665 0.01715 0.01720 0.01835
    ] 0.01470 is best cost (Nurse: 8 0.01480, Nurse:Trainee: 0 0.01525)

  There are no cheap ways to get below this, it seems.

  In this current best solution, why not swap 1Wed-1Fri CT_67 <--> CT_70
  and drop the italic 1Wed day shift?  Because that would give CT_67 8
  consecutive free days spanning the start of the cycle, that's why.

  Tried adding rrd back in, because of the 3 italic entries in the
  KHE Nurse timetable.  One at least of those looks redundant.  Got

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01525 0.01545 0.01575 0.01580 0.01605 0.01630 0.01680 0.01715
      0.01725 0.01745 0.01765 0.01775
    ] 0.01505 is best cost (Nurse: 7 0.01575, Nurse:Trainee: 8 0.01525)

  Surprisingly poor.

24 January 2026.  Analysing the singleton free day for HN_14, ending
  a sequence on 3Mon is bad news for a resource (like HN_14) which is
  already busy on two weekends.  Because then the next free sequence
  must be 3Tue-3Wed, leaving no room for a sequence of length 3 or
  more before the next weekend, so that there must be at least 6
  consecutive free days:  3Tue, 3Wed, 3Thu, 3Fri, 3Sat, 3Sun.  But
  HN_14 is full-time so it can have at most 3 consecutive free days.
  The same analysis applies to NU_21.

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01500 0.01520 0.01560 0.01565 0.01600 0.01630 0.01640 0.01655
      0.01665 0.01670 0.01720 0.01805
    ] 0.01470 is best cost (Nurse: 9 0.01565, Nurse:Trainee: 0 0.01520)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 150
    Avoid Unavailable Times Constraint (6 points)      70   	  70
    Cluster Busy Times Constraint (32 points) 	      950	1040
    Limit Active Intervals Constraint (7 points)       75   	 210
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1470

    Nurse                            LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     20       21
    O  Available times (negative)     36       38
    Y  Unnecessary assignments         1        2
    X  Unassigned tasks                5        5
    ---------------------------------------------
    U - O + Y - X                    -20      -20

    Nurse:Trainee                    LOR      KHE
    ---------------------------------------------
    U  Available times (positive)      4        7
    O  Available times (negative)      7       11
    Y  Unnecessary assignments        18       19
    X  Unassigned tasks                0        0
    ---------------------------------------------
    U - O + Y - X                     15       15

  So KHE is worse here by (21+2 - 20+1) + (7+19 - 4+18) = 2 + 4 = 6,
  which translates to cost about 6 * 20 = 120, which is exactly where
  we are (LOR is 30 points worse on max weekends).

  The biggest problem here is that KHE is 3 worse on available times
  (positive) for trainees.  We could save 60 points if we could use
  those 3 times.

  TR_83 is a big part of the problem.  Why didn't it get a full load?
  Discovered that the run above was using rts, not rds.  Switching
  back to rds, we now get (over two attempts)

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01520 0.01575 0.01580 0.01580 0.01585 0.01595 0.01610 0.01625
      0.01635 0.01655 0.01655 0.01725
    ] 0.01490 is best cost (Nurse: 6 0.01580, Nurse:Trainee: 8 0.01580)

  Amazing, it's worse than ordinary time sweep.  What has gone wrong?
  Here is a second run, just to check:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01520 0.01575 0.01580 0.01590 0.01595 0.01610 0.01625 0.01630
      0.01635 0.01655 0.01655 0.01725
    ] 0.01510 is best cost (Nurse: 7 0.01520, Nurse:Trainee: 8 0.01580)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 180
    Avoid Unavailable Times Constraint (6 points)      70   	  70
    Cluster Busy Times Constraint (32 points) 	      950	1140
    Limit Active Intervals Constraint (7 points)       75   	 120
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1510

    Nurse                            LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     20       21
    O  Available times (negative)     36       40
    Y  Unnecessary assignments         1        5
    X  Unassigned tasks                5        6
    ---------------------------------------------
    U - O + Y - X                    -20      -20

    Nurse:Trainee                    LOR      KHE
    ---------------------------------------------
    U  Available times (positive)      4        7
    O  Available times (negative)      7       14
    Y  Unnecessary assignments        18       22
    X  Unassigned tasks                0        0
    ---------------------------------------------
    U - O + Y - X                     15       15

  So KHE is worse here by (21+5 - 20+1) + (7+22 - 4+18) = 5 + 7 = 12,
  which translates to cost 12 * 20 = 240, which is pretty much where
  we are (LOR is 30 points worse on max weekends).

  Decided to try frac=0.3 in Sequential, because the debug output
  looked like too many resources were being solved optimally to
  begin with.  Got this:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01570 0.01580 0.01585 0.01595 0.01595 0.01605 0.01655 0.01655
      0.01670 0.01675 0.01690 0.01715
    ] 0.01445 is best cost (Nurse: 5 0.01585, Nurse:Trainee: 0 0.01570)

    Summary 	                                      LOR	 KHE
    ----------------------------------------------------------------
    Assign Resource Constraint (6 points) 	      150	 120
    Avoid Unavailable Times Constraint (6 points)      70   	  60
    Cluster Busy Times Constraint (32 points) 	      950	1070
    Limit Active Intervals Constraint (7 points)       75   	 195
    ----------------------------------------------------------------
      Grand total (51 points) 	   		     1245	1445

    Nurse                            LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     20       23
    O  Available times (negative)     36       42
    Y  Unnecessary assignments         1        3
    X  Unassigned tasks                5        4
    ---------------------------------------------
    U - O + Y - X                    -20      -20

    Nurse:Trainee                    LOR      KHE
    ---------------------------------------------
    U  Available times (positive)      4        6
    O  Available times (negative)      7       10
    Y  Unnecessary assignments        18       19
    X  Unassigned tasks                0        0
    ---------------------------------------------
    U - O + Y - X                     15       15

  So KHE is worse here by (23+3 - 20+1) + (6+19 - 4+18) = 5 + 3 = 8,
  which translates to cost 8 * 20 = 160, which is pretty much where
  we are (LOR is 60 points worse on max weekends).

  OK, we'd better stick with this!  This is rel = 1.16.

  I've just completed a long run, and saved it as res_2026_01_24.xml.
  Here are the results:

    Instances (20) 	  LOR17 	KHE24x12-RPS 	KHE24x12
			  Cost 	Rel. 	Cost 	Rel. 	Cost 	Rel.
    --------------------------------------------------------------------
    INRC2-4-030-1-6291 	0.01695 1.00 	0.01925 1.14 	0.01850 1.09
    INRC2-4-030-1-6753 	0.01890 1.00 	0.02000 1.06 	0.02045 1.08
    INRC2-4-035-0-1718 	0.01425 1.00 	0.01625 1.14 	0.01650 1.16
    INRC2-4-035-2-8875 	0.01155 1.00 	0.01315 1.14 	0.01340 1.16
    INRC2-4-040-0-2061 	0.01685 1.00 	0.01965 1.17 	0.01940 1.15
    INRC2-4-040-2-6106 	0.01890 1.00 	0.02040 1.08 	0.02150 1.14
    INRC2-4-050-0-0487 	0.01505 1.00 	0.01650 1.10 	0.01625 1.08
    INRC2-4-050-0-7272 	0.01500 1.00 	0.01750 1.17 	0.01580 1.05
    INRC2-4-060-1-6115 	0.02505 1.00 	0.02820 1.13 	0.02810 1.12
    INRC2-4-060-1-9638 	0.02750 1.00 	0.03235 1.18 	0.03130 1.14
    INRC2-4-070-0-3651 	0.02435 1.00 	0.02700 1.11 	0.02795 1.15
    INRC2-4-070-0-4967 	0.02175 1.00 	0.02465 1.13 	0.02460 1.13
    INRC2-4-080-2-4333 	0.03340 1.00 	0.03800 1.14 	0.03660 1.10
    INRC2-4-080-2-6048 	0.03260 1.00 	0.03620 1.11 	0.03730 1.14
    INRC2-4-100-0-1108 	0.01245 1.00 	0.01660 1.33 	0.01445 1.16
    INRC2-4-100-2-0646 	0.01950 1.00 	0.02190 1.12 	0.02375 1.22
    INRC2-4-110-0-1428 	0.02440 1.00 	0.02660 1.09 	0.02545 1.04
    INRC2-4-110-0-1935 	0.02560 1.00 	0.02835 1.11 	0.02755 1.08
    INRC2-4-120-1-4626 	0.02170 1.00 	0.02485 1.15 	0.02575 1.19
    INRC2-4-120-1-5698 	0.02220 1.00 	0.02445 1.10 	0.02530 1.14
    --------------------------------------------------------------------
       Average 		0.02089 1.00 	0.02359 1.13 	0.02349 1.13

  This is very similar to the results I was getting on 3 December 2025
  and 10 December 2025, which give rel = 1.12 but have the same average
  cost (2349), presumably owing to slightly different roundoff errors.

  Making "yourself" exit early if soln cost equals zero.

25 January 2026.  From what I can see, the Azaiez bug is that the
  dynamic solver is building a solution in which Nurse12 is unchanged,
  and measuring its cost accordingly, but then when it rebuilds the
  KHE solution it fails to make one of the assignments, to 1Mon:1.
  Here are the unassignments:

    [ KheDrsTaskUnAssign(1Mon:1.3, Nurse3, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.1, Nurse4, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.4, Nurse7, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.6, Nurse12, true)
    ] KheDrsTaskUnAssign returning

  And here are the assignments:

    [ KheDrsTaskAssign(1Mon:1.3 (1 days), Nurse3, true)
    ] KheDrsTaskAssign returning true
    [ KheDrsTaskAssign(1Mon:1.1 (1 days), Nurse4, true)
    ] KheDrsTaskAssign returning true
    [ KheDrsTaskAssign(1Mon:1.4 (1 days), Nurse7, true)
    ] KheDrsTaskAssign returning true

  So the assignment of 1Mon:1.6 to Nurse12 is missing.  Of course,
  this could be a different solution which deliberately omits this
  assignment, but the open and search cost suggests otherwise.  But
  1Mon:1.6 has no constraints, so it cost 0 whether it is assigned
  or not.

  The failed call on KheDrsSolveClose comes from KheDoSolve (1),
  the case we take when the search fails to find a new best.  So
  is there something wrong with init_soln?  It needs looking into.

  Actually init_soln is fine, but this call:

    KheDrsSolveClose calling KheDrsTaskClose(1Mon:1.6, Nurse12)

  is *not* followed by KheDrsTaskAssign, as it is in all the
  other cases.  I think this proves that dt is not open.  Why not?

  Look at this:

    [ KheDrsTaskUnAssign(1Mon:1.3, Nurse3, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.1, Nurse4, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.4, Nurse7, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskUnAssign(1Mon:1.6, Nurse12, true)
    ] KheDrsTaskUnAssign returning
    [ KheDrsTaskOpen(1Mon:1.1, drs)
    ] KheDrsTaskOpen
    [ KheDrsTaskOpen(1Mon:1.3, drs)
    ] KheDrsTaskOpen
    [ KheDrsTaskOpen(1Mon:1.4, drs)
    ] KheDrsTaskOpen
    [ KheDrsTaskOpen(1Mon:1.5, drs)
    ] KheDrsTaskOpen

  Not sure why opening is divorced from unassigning, but it is,
  and then at the end we open 1Mon:1.5 when surely we should have
  opened 1Mon:1.6.  What is going on?  Is it something to do with
  those tasks being equivalent (they are)?

26 January 2026.  Fixed the bug.  It was what I thought it was,
  confusion over equivalent tasks.  Carrying on through COI,
  finding and fixing odd bugs as I go.

  Current bug: KheVLSNLimitBusyTimesMonitorNextNHood thinks it
  is getting a limit busy times monitor, but it isn't.  It seems
  to be a rubbish value, there are no limit busy times monitors
  in the list of defective monitors.  This is in COI-WHPP.

27 January 2026.  Fixed the COI-WHPP bug.  Just a stupid cut and
  paste error.  But results are not great (best is 1003).  Back to
  a long run now.

  Current bug is in COI-Ikegami-2.1:

    KheMTaskFinderMTasksInTimeGroup: tg is empty

  It's caused by this in COI-Ikegami-2.1 Constraint:24:

    <TimeGroups>
      <TimeGroup Reference="1Fri1"/>
      <TimeGroup Reference="TG:Empty" Polarity="negative"/>
      <TimeGroup Reference="1Sun1-2"/>
    </TimeGroups

  What does this mean?  I went back to the original file but
  it was not very illuminating.  It seems to be something
  that would always be true.  Just take it as that and keep
  moving.

  Fixed all the bugs and got a complete run of COI.  But the
  costs are not great, and MER produced no solutions at all,
  because all threads ran out of memory.  So work to do there.

28 January 2026.  Looking over yesterday's complete run of COI.
  Of the 27 instances in COI, 19 have different solution costs,
  with KHE26 always worse:

    Instance       KHE24            KHE26
    ------------------------------------------------------------
    Azaiez	       0                1
    GPost              8               12
    GPost-B            5               10
    QMC-1             16               22
    WHPP            2001             1003
    BCV-3.46.2	     894              895
    SINTEF             0                1
    ORTEC01          295              315
    ORTEC02          295              300
    ERMGH            882             2359
    CHILD            261             3987
    ERRVH           2219             9003
    Valouxis         100              160
    Ikegami-2.1        0               50
    Ikegami-3.1        9              283
    Ikegami-3.1.1     15              283
    Ikegami-3.1.2     10              292
    BCDT-Sep         210              280
    MER            13840            -- out of memory --
    ------------------------------------------------------------

  We need to grind these down.  I'll work through the table,
  starting with Azaiez.  Tried es_swap_widening_max=28 (the
  default is 16) and got 

    [ "COI-Azaiez", 12 threads, 12 solves, 141.3 secs:
      0.00003 0.00003 0.00003 0.00003 0.00005 0.00005 0.00006 0.00006
      0.00007 0.00007 0.00009 0.00013
    ] 0.00003 is best cost (diversifier 11)

  which is worse!

  It's interesting that the one defect is a single free day (when
  free days are supposed to come in groups of at least 2).  This
  same defect is a problem in INRC2-4-100-0-1108.  OK, it's time
  for a whynot on this defect.

  The whynot shows that ejection chains are completely ineffective
  at repairing this defect.  For example, if you move the task
  following the free day to another resource, you immediately
  get three defects:

    [ MTaskSwapRepair+(Nurse8, {0-0: 2Thu:2.1}, Nurse12 {0--1: })
      new defect 0.00000 -> 0.00005: [ A1 01432 Constraint:6/Nurse8 ]
      new defect 0.00000 -> 0.00020: [ A1 00344 Constraint:8/Nurse12 ]
      new defect 0.00000 -> 0.00005: [ A1 01436 Constraint:6/Nurse12  ]
      total_gap (0.00020) <= min_gap (0.00029)
    [ Beam (1 elements)
      targ 0.00000, gap 0.00020:
      [ A1 00344 Constraint:8/Nurse12  0.00020 CBTM max 15, active_count 16 ]
    ]
    ]

  and there is no recursion.  To get anywhere here we really need a
  double swap that preserves total workload.  What happened to that?
  There is a KheDoubleSwapRepair function that looks to be pretty
  much what we want (currently it is only invoked once, from function
  KheIncreaseLoadDoubleSwapMultiRepair), so we should be able to get
  something going.

  Tried with es_max_beam=3, got this:

    [ "COI-Azaiez", 12 threads, 12 solves, 159.5 secs:
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00002 0.00002 0.00002
      0.00003 0.00004 0.00005 0.00005
    ] 0.00001 is best cost (diversifier 1)

  And here is a go with es_max_beam=5:

    [ "COI-Azaiez", 12 threads, 12 solves, 179.2 secs:
      0.00001 0.00002 0.00002 0.00002 0.00003 0.00003 0.00003 0.00004
      0.00005 0.00006 0.00006 0.00007
    ] 0.00001 is best cost (diversifier 8)

  It doesn't seem to help very much.  Double swaps then.

29 January 2026.  Revising the ejection chain documentation and
  reorganizing the code, trying to bring the two closer together.
  The aim is to complete the documentation, including descriptions
  of the repairs that I am actually currently using, as a basis for
  carrying on.

30 January 2026.  Revising the ejection chain documentation.  I've
  audited the chapter from the start down to where I'm up to now.
  I've finished iterators and I've finished task repairs.  Task
  multi-repairs are next.

31 January 2026.  Revising the ejection chain documentation.
  I've basically done everything I want to do this time around,
  and audited it as well.  It's in good shape.

  Added mtask set slices.  All implemented, documented, and used
  in khe_se_solvers.c, and the changes there all documented.

  Documented the demand monitor augment function.

  I've compared the descriptions of the augment functions with
  what is actually in the code.  It's all good; there are one
  or two places where the description is a slight simplification,
  but I'm fine with that.

  Random offsets in iterators should access the number of
  augments made so far.  Already done.

  Sorted out the rationale for widening limit active intervals
  repairs in only one direction, and given that rationale in
  the documentation.

1 February 2026.  Reviewing what I did yesterday, and sketching
  out a description of workload-balanced repairs.  It seems
  close to being ready to design code and implement.

  I've added an in parameter to the three intervals, so that
  I know which interval of days the current iteration covers.

2 February 2026.  Implemented KheMTaskBalancedSwapRepair,
  KheMTaskBalancedAssignRepair, and KheBalancedMTaskUnassignRepair.
  They are pretty much just clones of the unbalanced versions.

  I looked into the two Boolean parameters of KheMTaskSetMoveResource
  and KheMTaskSetSliceMoveResource, with a view to getting rid of
  them; but I could see no way to do it.

  Written KheForEachBalancedSwap and used it in KheDoDecreaseLoad
  (so far) with clean compile.  But KheBalancedSwapIteratorStart
  and KheBalancedSwapIteratorNext is still to do.  I've made a start.

3 February 2026.  Working on KheForEachBalancedSwap.  All done with
  a clean compile, but there are still a few issues to resolve.

  Have to set *mts1 and *mts2 differently, depending on which
  way around the resources go.  Done, needs an audit.

  The end of an interval may not have the exact duration
  required, if there are multi-day tasks.  I need to get
  the tasks and then check that the duration is still
  what I want.  Done.

4 February 2026.  I've done a careful audit of the documentation of
  the resource assign, resource unassign, and resource swap iterators,
  and made sure that the documentation of each is consistent with
  the documentation of the others.  I still have to make sure
  that it is consistent with the implementation.

  Change EXTEND to WIDEN, make it WIDEN_LEFT, WIDEN_RIGHT,
  WIDEN_BOTH.  Done in doc, not implementation yet.

5 February 2026.  I've now altered all the names in the iterators
  in khe_se_solvers.c to agree with the documentation, and also
  adjusted the of their parameters.

  I've checked that resource assign iterators behave as the
  documentation says they do.  It's a complicated check, the
  connection between the code and the rules is not obvious.
  I found a sort of bug, the code was checking that r was
  assignable to mt, but not checking that r was not already
  assigned to mt.  But is that guaranteed in some other way?

6 February 2026.  I've now checked all four of the revised
  iterators (resource assign, resource unassign, resource swap,
  and balanced resource swap).  They all seem good.

  Audited the relevant ejection chain options.  Did some
  revising and implemented what I wrote.  All done.

  Written KheResourceSwapMultiRepair, KheResourceAssignMultiRepair,
  and KheResourceUnassignMultiRepair, somewhat unexpectedly, which
  have turned out really well.

7 February 2026.  Added KHE_BALANCED_RESOURCE_ASSIGN_ITERATOR.
  Have clean compile and I've audited it as well, so all seems
  good and ready to test.  Also brought the documentation of
  resource multi-repairs up to date.

8 February 2026.  Wrote new KheFindAssignableMTasksInInterval.
  It's audited and ready to test.

9 February 2026.  Did an audit of the resource assign iterator,
  including KheFindAssignableMTasksInInterval.  It's ready to test.
  Found one stupid but, in MTaskSetSliceDuration, which was
  spoiling balanced swaps.  After fixing that:

    [ "COI-Azaiez", 12 threads, 12 solves, 138.6 secs:
      0.00001 0.00002 0.00003 0.00003 0.00003 0.00004 0.00004 0.00004
      0.00004 0.00005 0.00005 0.00005
    ] 0.00001 is best cost (diversifier 4)

  The one defect looks easy to fix, so let's try a whynot.  It
  may be that we need a balanced unassignment in order to fix
  it.  All we have right now are balanced assignments and
  balanced swaps.

  Here we seem to be assigning Nurse8 on a day when it is
  already busy:

    KheResourceAssignRepair+(Nurse8, 2Mon, {4-4: 2Mon:1.1})

  Could there be some kind of out by one error here?

  The mtasks in the assign iterator have to run at times
  when r is free.  No-one seems to be checking for that.
  It's not enough to say that r is not assigned to mt.
  or assignable to it.  It needs to be free.  I've
  documented this and implemented the update.

10 February 2026.  Decided to park Azaiez.  It's one defect
  seems to be quite intractable.  Here is GPost:

    [ "COI-GPost", 12 threads, 12 solves, 34.2 secs:
      0.00008 0.00012 0.00012 0.00013 0.00013 0.00013 0.00014 0.00014
      0.00014 0.01010 0.01012 0.01013
    ] 0.00008 is best cost (diversifier 11)

  This is what I was getting before, so that's OK.  GPost-B:

    [ "COI-GPost-B", 12 threads, 12 solves, 13.3 secs:
      0.00006 0.00006 0.00007 0.00009 0.00010 0.00011 0.00012 0.01004
      0.01005 0.01006 0.01007 0.01010
    ] 0.00006 is best cost (diversifier 7)

  I was getting 5 before, in 145 seconds.  Much faster now.
  Tried 24 threads, still getting cost 6.  Now for 1108:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01510 0.01520 0.01530 0.01530 0.01550 0.01560 0.01560 0.01565
      0.01565 0.01570 0.01590 0.01630
    ] 0.01435 is best cost (Nurse: 8 0.01560, Nurse:Trainee: 4 0.01520)

  This is not bad, rel = 1.15.  It's at the low end of what I
  have been getting since the start of 2026, inferior to the
  remarkable 1370 outlier but not to much else.

  Altogether these results are quite good, good enough to
  publish I would say.  Do some more grinding down and then
  do the show runs.  Today is 10 Feb, there are 7 weeks to
  the PATAT deadline, minus the bushwalk.

  Removed KheSwapRepair, but unfortunately there is still
  a double swap repair (KheDoubleSwapRepair, called by
  KheIncreaseLoadDoubleSwapMultiRepair), so I did not
  save much code.  I need to look into what these double
  swap functions are doing, and see if I can bring them
  back into the fold.

  Tried 1108 without KheIncreaseLoadDoubleSwapMultiRepair:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01505 0.01520 0.01530 0.01535 0.01540 0.01550 0.01560 0.01580
      0.01585 0.01590 0.01625 0.01640
    ] 0.01435 is best cost (Nurse: 8 0.01560, Nurse:Trainee: 4 0.01520)

  The rationale is that balanced swaps might be doing something
  just as good.  Results are much the same.  On Azaiez and GPost:

    [ "COI-Azaiez", 12 threads, 12 solves, 137.8 secs:
      0.00001 0.00002 0.00002 0.00002 0.00003 0.00003 0.00003 0.00004
      0.00004 0.00005 0.00005 0.00006
    ] 0.00001 is best cost (diversifier 10)

    [ "COI-GPost", 12 threads, 12 solves, 30.2 secs:
      0.00008 0.00012 0.00012 0.00013 0.00013 0.00013 0.00014 0.00014
      0.00014 0.01010 0.01012 0.01013
    ] 0.00008 is best cost (diversifier 11)

  These are the same as before.

  So I've decided to comment out double swaps.  If I need them
  I can bring them back later.  Done it and got rid of a huge
  amount of code.  Also moved iterators to between repairs and
  multi-repairs, to agree with their placement in the doc.

  Decided to do some work on GPost.  A key constraint is
  Constraint:22, which requires all sequences of busy days
  to have length at least 4 (full-time nurses only, i.e.
  nurses A, B, C, and D).  In the KHE solution, 6 of the
  8 points come from violations of this constraint.

11 February 2026.  Grinding down COI and INRC2.  Looking just
  now at GPost.

  The two night shifts on 1Mon must be followed by two free
  days.  This means that they form a sequence of length 2,
  which in turn means that they can only be assigned to
  resources which accept sequences of that length.  All
  very true, but the best known solution (cost 5) assigns
  them to resource D and pays cost 4 for doing that.  In
  fact all solutions do it, because constraint TimeOn-D-s1000
  requires it.  So those four points are unavoidable and we
  need to look elsewhere for savings.  (We can't extend to
  a longer initial sequence of night shifts, because comb
  grouping has correctly found that the next two, 1Wed2 and
  1Thu2, must be grouped, and that would be a sequence of
  4 consecutive night shifts, when the max is 3 (cost 1000).

  Tried a seriously long run, hoping to randomize around the
  problem:

    [ "COI-GPost", 12 threads, 48 solves, 48.9 secs:
      0.00008 0.00008 0.00008 0.00010 0.00011 0.00011 0.00011 0.00012
      0.00012 0.00012 0.00012 0.00012 0.00012 0.00013 0.00013 0.00013
      0.00013 0.00013 0.00013 0.00013 0.00014 0.00014 0.00014 0.00014
      0.00014 0.00014 0.00015 0.00015 0.00016 0.00017 0.00024 0.00034
      0.00212 0.01008 0.01008 0.01009 0.01009 0.01009 0.01010 0.01010
      0.01010 0.01011 0.01012 0.01012 0.01012 0.01013 0.01013 0.02012
    ] 0.00008 is best cost (diversifier 47)

  No luck there, nor in another run of 96 solves.  Looking at the
  defect list, I've reached basically the same solution as before.
  I could have a variable value of ps_make, depending on time
  consumed, but on the evidence here there is no point in it.
  I also tried this for Azaiez;

    [ "COI-Azaiez", 12 threads, 48 solves (40 completed), 279.2 secs:
      0.00000 0.00001 0.00001 0.00001 0.00001 0.00001 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00003 0.00003 0.00003
      0.00003 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003
      0.00003 0.00003 0.00004 0.00004 0.00004 0.00004 0.00004 0.00004
      0.00005 0.00005 0.00005 0.00005 0.00006 0.00006 0.00007 0.00009
    ] 0.00000 is best cost (diversifier 36)

  It got down to zero, which is good, but only one out of 48 solves
  did that, and it was number 36.  Not great.  The running time is
  just short of 300 seconds.  Also not great.  Back to GPost, tried
  rts instead of rds, result was worse (best cost 10).  Tried
  rs_drs_seq_frac="0.5", result was worse (best cost 11).  Tried
  rs_drs_seq_frac="0.8", result was 9.  Altogether I seem to be
  lucky to be getting the 8 that I am getting.

  I've decided that it's time for some wider runs.  Here is COI:

    Instance       KHE24            KHE26 (26 Jan)   KHE26 (11 Feb)
    ---------------------------------------------------------------
    Azaiez	       0                1                1
    GPost              8               12                8
    GPost-B            5               10                6
    QMC-1             16               22               21
    WHPP            2001             1003                5
    BCV-3.46.2	     894              895              895
    SINTEF             0                1                1
    ORTEC01          295              315              305
    ORTEC02          295              300              295
    ERMGH            882             2359             2028
    CHILD            261             3987             1346
    ERRVH           2219             9003             4519
    HED01            136             oops              136
    Valouxis         100              160              100
    Ikegami-2.1        0               50                3
    Ikegami-3.1        9              283               58
    Ikegami-3.1.1     15              283              162
    Ikegami-3.1.2     10              292               67
    BCDT-Sep         210              280              280
    MER            13840            -- out of mem --     ?
    ---------------------------------------------------------------

  These results are better than what I was getting on 26 Jan, but
  still inferior to KHE24.  And something is wrong with the MER
  solve, it is running seriously overtime.  I had to terminate it.

  Decided to add balanced unassignments.  I've done the boilerplate,
  I just have to add the detailed semantic stuff now.  

13 February 2026.  Working on balanced unassignments.  I'm now
  finding the next free interval and its adjacent tasks.  I've
  also modified KheFindAssignableMTasksInInterval so that the
  "kernel mtask" can be outside the interval, making this
  function usable for finding mtasks for balanced unassignments.
  Using KheFindAssignableMTasksInInterval to do this is next.

14 February 2026.  Working on balanced unassignments.  Finished
  KheBRUINext, which finishes balanced unassignments.  It's
  audited and tested.  Here is GPost:

    [ "COI-GPost", 12 threads, 12 solves, 9.9 secs:
      0.00011 0.00011 0.00011 0.00011 0.00012 0.00013 0.00014 0.00014
      0.00015 0.00018 0.01012 0.01017
    ] 0.00011 is best cost (diversifier 11)

  which is worse than before.  And here is Azaiez:

    [ "COI-Azaiez", 12 threads, 12 solves, 40.4 secs:
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00002 0.00003 0.00003
      0.00004 0.00005 0.00005 0.00005
    ] 0.00001 is best cost (diversifier 1)

  which is the same as before.  The defect is Constraint:9/Nurse1.

  To help with Azaiez, could we deduce that the min and max limits
  for Day and Night shifts imply the limits for total busy days
  and total days off, then detach those so that there would be
  fewer defects along each chain?  Worth a try?

15 February 2026.  When repairing Azaiez Constraint:9/Nurse1, this
  is the last repair which tries to swap Nurse1 with Nurse5:

    KheResourceSwapRepair+(Nurse1, Nurse5, 3Tue-4Sat

  What happened to a full-width swap?  It was turned off, that's what.
  Turning it on got us to cost 0 for Azaiez:

    [ "COI-Azaiez", 12 threads, 12 solves, 27.2 secs:
      0.00000 0.00001 0.00001 0.00001 0.00001 0.00001 0.00002 0.00003
      0.00004 0.00004 0.00004 0.00005
    ] 0.00000 is best cost (diversifier 9)

  but we are still behind with GPost:

    [ "COI-GPost", 12 threads, 12 solves, 14.1 secs:
      0.00011 0.00011 0.00011 0.00012 0.00012 0.00013 0.00014 0.00015
      0.00015 0.00017 0.01014 0.01017
    ] 0.00011 is best cost (diversifier 11)

  By detault I now turn full-width on for smaller instances, and
  leave it off for larger ones.  All documented and implemented.

  Looking at resource rematching.  It seems to be trying only
  quite small intervals.  What about all intervals?  Tried
  all intervals and it does seem to have helped:

    [ "COI-GPost", 12 threads, 12 solves, 20.7 secs:
      0.00009 0.00010 0.00012 0.00012 0.00012 0.00014 0.00016 0.01006
      0.01010 0.01012 0.01013 0.01013
    ] 0.00009 is best cost (diversifier 5)

  The KHE24 result was 8, so just one point behind.  And Azaiez
  is still good, although much slower:

    [ "COI-Azaiez", 12 threads, 12 solves, 111.5 secs:
      0.00000 0.00001 0.00001 0.00002 0.00002 0.00002 0.00002 0.00003
      0.00003 0.00004 0.00005 0.00006
    ] 0.00000 is best cost (diversifier 0)

  I need to impose some time limit on rematching.  No I don't,
  it's already there.  These solves are both much faster than
  KHE24 was getting, so arguably we've achieved all we need to
  achieve here.  Time for another long run:

    Instance       Best   KHE24     26 Jan     11 Feb    15 Feb
    -----------------------------------------------------------
    Ozkarahan         0       0                               0
    Musa            175     175                             175
    Millar-2.1        0       0                               0
    Millar-2.1.1      0       0                               0
    LLR             301     301                             301
    Azaiez	      0       0          1          1         0
    GPost             5       8         12          8         9
    GPost-B           3       5         10          6         6
    QMC-1            13      16         22         21        21
    QMC-2            29      30                              30
    WHPP              5    2001       1003          5         5
    BCV-3.46.2	    894     894        895        895       895
    BCV-4.13.1       10      10                              10
    SINTEF            0       0          1          1         1
    ORTEC01         270     295        315        305       295
    ORTEC02         270     295        300        295       305
    ERMGH           779     882       2359       2028      1407
    CHILD           149     261       3987       1346      1233
    ERRVH          2001    2219       9003       4519      3406
    HED01           136     136       oops        136       136
    Valouxis-1       20     100        160        100       100
    Ikegami-2.1       0       0         50          3         2
    Ikegami-3.1       2       9        283         58       155
    Ikegami-3.1.1     3      15        283        162        71
    Ikegami-3.1.2     3      10        292         67        89
    BCDT-Sep        100     210        280        280       270
    MER            7081   13840        mem          ?         ?
    -----------------------------------------------------------

  I tried pumping up dynamic vlsn; I increased the limits to a
  point where one of the individual solves took 60.9 seconds:

    [ KheDynamicResourceSolverDoSolve(drs, priqueue false, extra_selection true,
      expand_by_shifts true, shift_pairs false, correlated_exprs false,
      daily_expand_limit 10000, daily_prune_trigger 0,
      resource_expand_limit 0, dom_approx 0,
      main_dom_kind IndexedTabulated, cache false) cost 0.00009
      resources:  A, B, E, F, G, H
      day ranges: 0-13 (1Mon{1Mon1..1Mon2} - 2Sun{2Sun1..2Sun2})
    ] KheDynamicResourceSolverDoSolve returning false, 60.9 secs

  Still it found no improvement.  This was targeted at defect
  Constraint:22/A, which is indeed at the start of the cycle,
  and which should be fixable.

  Best of 48:

    [ "COI-GPost", 12 threads, 48 solves, 42.2 secs:
      0.00008 0.00009 0.00009 0.00010 0.00010 0.00011 0.00012 0.00012
      0.00012 0.00012 0.00012 0.00012 0.00012 0.00012 0.00012 0.00013
      0.00013 0.00013 0.00013 0.00013 0.00014 0.00014 0.00014 0.00015
      0.00015 0.00015 0.00015 0.00016 0.00016 0.00017 0.00017 0.00019
      0.00019 0.00020 0.00021 0.00217 0.01006 0.01007 0.01008 0.01008
      0.01009 0.01009 0.01010 0.01010 0.01010 0.01012 0.01013 0.01013
    ] 0.00008 is best cost (diversifier 14)

  Slight improvement here.  Best of 98 was also 0.00008.  This is
  also what KHE24 got.  It more or less proves that the current
  code is capable of getting what KHE24 got, and it is only bad
  luck that it missed it.  That is, unless several inidividual KHE24
  solves were getting it before.

  Time for another instance.  Looks like QMC-1 is next:

    [ "COI-QMC-1", 12 threads, 12 solves, 18.3 secs:
      0.00021 0.00023 0.00023 0.00024 0.00025 0.00025 0.00025 0.00025
      0.00025 0.00026 0.00027 0.00028
    ] 0.00021 is best cost (diversifier 6)

  Best is 13, KHE24 is 16.  It's fairly weird, all the defects are
  for Time On constraints, that is, they are violations of lower
  limits of limit busy times constraints.  Could be some fruitful
  whynots here.

  One example of a TimeOn violation which KHE26 has but the
  best solution doesn't is TimeOn-B-s1/B (at 4Sun1).

16 February 2026.  Grinding down QMC-1.  These are KHE26's defects (cost 21):

    -------------------------------------------------------------------------
  * TimeOn-A-s1/A  1 * Linear(1 - 0 2Thu2-4)                                1
    TimeOn-B-s1/B  1 * Linear(1 - 0 4Sun1)                                  1
  * TimeOn-C-s1/C  1 * Linear(1 - 0 3Fri5-7)                                1
    TimeOn-F-s1/F  1 * Linear(1 - 0 3Fri1; 1 - 0 3Sat1)                     2
  * TimeOn-H-s1/H  1 * Linear(1 - 0 1Wed2-4; 1 - 0 1Sun2-4; 1 - 0 4Sun2-4)  3
  * TimeOn-L-s1/L  1 * Linear(1 - 0 2Sat1; 1 - 0 3Tue1)                     2
  * TimeOn-N-s1/N  1 * Linear(1 - 0 3Fri1; 1 - 0 1Wed5-7; 1 - 0 2Tue5-7)    3
  * TimeOn-O-s1/O  1 * Linear(1 - 0 2Sat1; 1 - 0 3Fri1)                     2
  * TimeOn-P-s1/P  1 * Linear(1 - 0 4Sat1; 1 - 0 1Tue2-4)                   2
    TimeOn-Q-s1/Q  1 * Linear(1 - 0 1Mon8-9; 1 - 0 3Mon5-7)                 2
  * TimeOn-S-s1/S  1 * Linear(1 - 0 2Sat1; 1 - 0 3Mon5-7)                   2
    -------------------------------------------------------------------------

  The ones marked * are also in the best (cost 13) solution, at least
  partly.  Many of these defects are smaller in the best soln, e.g.
  O, P, Q, and S have cost 1 in the best soln, as opposed to 2 here.
  All defects involving a first time of the day (4Sun1, 3Fri1 etc.)
  are in fact unavailable times defects, although they are notated
  here otherwise.

  The O shifts should not be a problem.  We just swap them rather
  than unassign them.  Here is part of the whynot for TimeOn-B-s1/B:

    [ KheResourceSwapRepair+(B, J, 4Fri-4Sun,
	{14-16: 4Fri:N.0, 4Sat:N.0, 4Sun:N.0},
	{14-16: 4Fri:O.0, 4Sat:O.0, 4Sun:O.0})
      new defect 0.00001 -> 0.00003:
	[ A1 03400 TimeOn-B-s1/B                 0.00003
	LBTM (min 1, max 1000, allow_zero false, dev 3)
	4Sun1 (busy 0, open 0) 4Fri8-9 (busy 0, open 0) 4Sat8-9 (busy 0,open 0)]
      new defect 0.00000 -> 0.00003:
	[ A1 03412 TimeOn-J-s1/J                 0.00003
	LBTM (min 1, max 1000, allow_zero false, dev 3)
	4Fri1 (busy 0, open 0) 4Sat1 (busy 0, open 0) 4Sun1 (busy 0, open 0) ]
      total_gap (0.00003) <= min_gap (0.00005)
    ]

  What this is saying is that B wants to be busy on Friday and
  Saturday night, and J wants to be free on Friday, Saturday,
  and Sunday, so this repair is not working out.  A similar
  repair on 4Sat-4Sun has the same problem.

  Implemented ejecting task moves.  KheResourceEjectingMoveRepair
  and KheResourceEjectingMoveMultiRepair are written, and I'm
  calling KheResourceEjectingMoveMultiRepair now.  Still needs
  to be tested and documented.

17 February 2026.  Ejecting task set moves all done and being used,
  including documentation and auditing but not yet testing.  I have
  to adjust condition (9) of the iterator when ejecting moves are
  being tried, so instead of KheResourceSwapIteratorForEach I have
  KheResourceSwapIteratorForEachEjectingMove.

18 February 2026.  Testing ejecting task set moves.  First results:

    [ "COI-QMC-1", 1 solution, in 17.4 secs: cost 0.00023 ]

    [ "COI-QMC-1", 12 threads, 12 solves, 22.7 secs:
      0.00021 0.00021 0.00022 0.00023 0.00023 0.00023 0.00025 0.00025
      0.00025 0.00025 0.00028 0.00035
    ] 0.00021 is best cost (diversifier 3)

  as compared with the best soln's 13 and KHE24's 16.  This cost 21
  is the same as I was getting before.

  Tried a whynot of TimeOn-R-s1/R (time is 1Sat1).

19 February 2026.  Wrote and documented KheResourceEjectingAssignRepair.
  Now I need to find a way to use it; it may require a separate iterator.

20 February 2026.  I've been thinking about a generic iterator that
  combines the assign, unassign, and swap iterators.  I've written
  interfaces for functions KheGenericIteratorMake,
  KheGenericIteratorEntryBeginAssigned,
  KheGenericIteratorEntryBeginAssignable, and
  KheGenericInteratorEntryEnd.  The next step is to define the
  KHE_GENERIC_ITERATOR type and fill in its fields.

21 February 2026.  Implementing KHE_GENERIC_ITERATOR.  I've done
  most of it.  Now called KHE_WIDENING_ITERATOR.

22 February 2026.  Implementing KHE_WIDENING_ITERATOR.  All written,
  needs an audit, then we need to use it in other code and get rid
  of the other iterators.

23 February 2026.  Working on widening iterator documentation.
  All done, basically.

24 February 2026.  Working on widening iterator.  Sorted out
  the two ways around for ejecting moves, all documented and
  implemented.  Have clean compile after the other iterators
  removed.  It's ready for an audit and test.

25 February 2026.  Audited the widening iterator documentation
  and implementation.  It seems to be ready to test.  But first
  I have to audit each spot where it is used.  I've done
  KheResourceEjectingMoveBMultiRepair, I now need to look at
  KheDoDecreaseLoad and what follows it.

  I started work on the widening iterator on 20 February.  Not
  a bad week's work.

  Deleted most of the "Structure of resource repairs" section.

26 February 2026.  Finished auditing the code.  There are two
  unused functions, KheResourceEjectingMoveBMultiRepair and
  KheResourceEjectingAssignRepair, but I'll keep them since
  they complete the repertoire and may be needed later.

  Altered the three balanced iterators to return NULL when
  balancing_max == 0.  All documented and implemented.

  Removed the documentation for the iterators replaced by
  the widening iterator.

  Testing COI.  Azaiez still has cost 1.

    Instance       Best   KHE24     26 Jan     11 Feb    15 Feb    26 Feb
    ---------------------------------------------------------------------
    Ozkarahan         0       0                               0         0
    Musa            175     175                             175       175
    Millar-2.1        0       0                               0         0
    Millar-2.1.1      0       0                               0         0
    LLR             301     301                             301       301
    Azaiez	      0       0          1          1         0         1
    GPost             5       8         12          8         9         9
    GPost-B           3       5         10          6         6         6
    QMC-1            13      16         22         21        21        24
    QMC-2            29      30                              30        30
    WHPP              5    2001       1003          5         5         5
    BCV-3.46.2	    894     894        895        895       895       895
    BCV-4.13.1       10      10                              10        10
    SINTEF            0       0          1          1         1         1
    ORTEC01         270     295        315        305       295       290
    ORTEC02         270     295        300        295       305       300
    ERMGH           779     882       2359       2028      1407      1713
    CHILD           149     261       3987       1346      1233      1221
    ERRVH          2001    2219       9003       4519      3406      4967
    HED01           136     136       oops        136       136       136
    Valouxis-1       20     100        160        100       100       120
    Ikegami-2.1       0       0         50          3         2         4
    Ikegami-3.1       2       9        283         58       155        48
    Ikegami-3.1.1     3      15        283        162        71       150
    Ikegami-3.1.2     3      10        292         67        89       149
    BCDT-Sep        100     210        280        280       270       300
    MER            7081   13840        mem          ?         ?         ?
    ---------------------------------------------------------------------

  And here is the good news:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01445 0.01500 0.01505 0.01510 0.01510 0.01510 0.01525 0.01530
      0.01565 0.01565 0.01605 0.01620
    ] 0.01400 is best cost (Nurse: 3 0.01445, Nurse:Trainee: 8 0.01510)

  This is rel = 1.12, close to the best I ever did, which was 1370
  (rel = 1.10).  And here is a full INRC2-4 run (5 minutes per instance):

    Instances (20) 	  LOR17 	   KHE26x12
                          Cost     Rel.    Cost     Rel.
    ----------------------------------------------------
    INRC2-4-030-1-6291    0.01695  1.00    0.01780  1.05
    INRC2-4-030-1-6753    0.01890  1.00    0.01960  1.04
    INRC2-4-035-0-1718    0.01425  1.00    0.01525  1.07
    INRC2-4-035-2-8875    0.01155  1.00    0.01270  1.10
    INRC2-4-040-0-2061    0.01685  1.00    0.01845  1.09
    INRC2-4-040-2-6106    0.01890  1.00    0.02030  1.07
    INRC2-4-050-0-0487    0.01505  1.00    0.01615  1.07
    INRC2-4-050-0-7272    0.01500  1.00    0.01520  1.01
    INRC2-4-060-1-6115    0.02505  1.00    0.02830  1.13 *
    INRC2-4-060-1-9638    0.02750  1.00    0.03105  1.13 *
    INRC2-4-070-0-3651    0.02435  1.00    0.02700  1.11 *
    INRC2-4-070-0-4967    0.02175  1.00    0.02475  1.14 *
    INRC2-4-080-2-4333    0.03340  1.00    0.03665  1.10
    INRC2-4-080-2-6048    0.03260  1.00    0.03660  1.12 *
    INRC2-4-100-0-1108    0.01245  1.00    0.01410  1.13 *
    INRC2-4-100-2-0646    0.01950  1.00    0.02230  1.14 *
    INRC2-4-110-0-1428    0.02440  1.00    0.02640  1.08
    INRC2-4-110-0-1935    0.02560  1.00    0.02820  1.10
    INRC2-4-120-1-4626    0.02170  1.00    0.02525  1.16 *
    INRC2-4-120-1-5698    0.02220  1.00    0.02575  1.16 *
    ----------------------------------------------------
     Average              0.02089  1.00    0.02309  1.10

  So we have got it down to 10% worse on average, with 9 of
  the 20 instances over the 10% mark.  This is very close,
  and much better than the 13% worse that I was getting on
  24 January 2026 as well as earlier.  I've saved this in
  file res_2026_02_26.xml; it could be the basis of my
  PATAT paper if I can't improve it before the deadline.

  Did some thinking about unifying balanced repair iterators.
  It would probably be doable but it's messy and I'm not in a
  hurry to do it.

  Having another look at Azaiez.  The sole defect is too few
  consective busy days for Nurse 2 on 2Wed.  Unassigning Nurse2's
  2Thu task is the only way, apparently, to start a chain, and
  assigning that task to Nurse11 is the best bet:

    [ KheResourceAssignRepair+(Nurse11, 2Thu, {4-4: 2Thu:2.1})
      defect 0.00000 -> 0.00020: [ A1 00343 Constraint:8/Nurse11 0.00020 CBTM]
      defect 0.00000 -> 0.00005: [ A1 01435 Constraint:6/Nurse11 0.00005 LBTM]
      at length limit 2
    ]

  Constraint:8 is max 15 busy days, Constraint:6 is max 7 night
  shifts.  So actually a balanced assign might work better.  But
  there is only one balanced repair tried:

    KheBalancedResourceAssignRepair(Nurse11, {4-4: 2Thu:2.1}, {[1Mon] 1Mon:2.0})

  Line 5788 of the whynot (op2, edited).  Why stop so soon?

27 February 2026.  I checked, and balancing_max has default value 12.
  It doesn't find any other places to balance because there are none.
  Actually there are some:  4Mon and 4Thu.  Found the bug, it was
  horrible:  KheMTaskFinderAddResourceMTasksInInterval was not
  clearing the mtask it was given to begin with.  I seem to have
  thought that that would be a good idea but it provieed to be
  horribly error-prone.  And Hurrah!  Azaiex now has cost 0.

  So now I am doing a fresh COI run:

    Instance       Best   KHE24     26 Jan     11 Feb    15 Feb    27 Feb
    ---------------------------------------------------------------------
    Ozkarahan         0       0                               0         0
    Musa            175     175                             175       175
    Millar-2.1        0       0                               0         0
    Millar-2.1.1      0       0                               0         0
    LLR             301     301                             301       301
    Azaiez	      0       0          1          1         0         0
    GPost             5       8         12          8         9         8
    GPost-B           3       5         10          6         6         5
    QMC-1            13      16         22         21        21        20
    QMC-2            29      30                              30        30
    WHPP              5    2001       1003          5         5         5
    BCV-3.46.2	    894     894        895        895       895       894
    BCV-4.13.1       10      10                              10        10
    SINTEF            0       0          1          1         1         0
    ORTEC01         270     295        315        305       295       290
    ORTEC02         270     295        300        295       305       310
    ERMGH           779     882       2359       2028      1407      1689
    CHILD           149     261       3987       1346      1233       590
    ERRVH          2001    2219       9003       4519      3406      5244
    HED01           136     136       oops        136       136       136
    Valouxis-1       20     100        160        100       100       140
    Ikegami-2.1       0       0         50          3         2         3
    Ikegami-3.1       2       9        283         58       155       276
    Ikegami-3.1.1     3      15        283        162        71       185
    Ikegami-3.1.2     3      10        292         67        89      lost
    BCDT-Sep        100     210        280        280       270       260
    MER            7081   13840        mem          ?         ?         ?
    ---------------------------------------------------------------------

  Plenty of grinding down to do here.  And here is a full INRC2-4 run
  (5 minutes per instance):

  Instances (20) 	LOR17 		KHE26x12
   	                Cost 	Rel. 	Cost 	Rel.
  --------------------------------------------------
  INRC2-4-030-1-6291 	0.01695 1.00 	0.01800 1.06
  INRC2-4-030-1-6753 	0.01890 1.00 	0.01995 1.06
  INRC2-4-035-0-1718 	0.01425 1.00 	0.01560 1.09
  INRC2-4-035-2-8875 	0.01155 1.00 	0.01270 1.10
  INRC2-4-040-0-2061 	0.01685 1.00 	0.01825 1.08
  INRC2-4-040-2-6106 	0.01890 1.00 	0.02060 1.09
  INRC2-4-050-0-0487 	0.01505 1.00 	0.01625 1.08
  INRC2-4-050-0-7272 	0.01500 1.00 	0.01555 1.04
  INRC2-4-060-1-6115 	0.02505 1.00 	0.02745 1.10
  INRC2-4-060-1-9638 	0.02750 1.00 	0.03065 1.11 *
  INRC2-4-070-0-3651 	0.02435 1.00 	0.02770 1.14 *
  INRC2-4-070-0-4967 	0.02175 1.00 	0.02415 1.11 *
  INRC2-4-080-2-4333 	0.03340 1.00 	0.03665 1.10
  INRC2-4-080-2-6048 	0.03260 1.00 	0.03645 1.12 *
  INRC2-4-100-0-1108 	0.01245 1.00 	0.01410 1.13 *
  INRC2-4-100-2-0646 	0.01950 1.00 	0.02205 1.13 *
  INRC2-4-110-0-1428 	0.02440 1.00 	0.02595 1.06
  INRC2-4-110-0-1935 	0.02560 1.00 	0.02825 1.10
  INRC2-4-120-1-4626 	0.02170 1.00 	0.02575 1.19 *
  INRC2-4-120-1-5698 	0.02220 1.00 	0.02665 1.20 *
  --------------------------------------------------
     Average 		0.02089 1.00 	0.02313 1.10

  That's great, we have different costs but the average relative
  cost is still 1.10.

28 February 2026.  Grinding down.  Constraint TimeOn-J-s1 is
  requesting an assignment at time 2Sat1, i.e. a free time then.
  What this needs is an ejecting move (assignment?) of an O to
  that slot, which we don't seem to have yet.  Added ejecting
  assignments, but no improvement:

    [ "COI-QMC-1", 12 threads, 12 solves, 36.9 secs:
      0.00020 0.00023 0.00023 0.00023 0.00023 0.00024 0.00025 0.00025
      0.00025 0.00025 0.00028 0.00031
    ] 0.00020 is best cost (diversifier 11)

  Tried replacing assignments by ejecting assignments:

    [ "COI-QMC-1", 12 threads, 12 solves, 12.6 secs:
      0.00020 0.00021 0.00022 0.00023 0.00023 0.00024 0.00024 0.00025
      0.00025 0.00025 0.00026 0.00027
    ] 0.00020 is best cost (diversifier 1)
  
  Some solutions are better but the best is no better.  Looking
  at the whynot for TimeOn-R-s1/R now.  Got this:

    [ KheResourceAssignMultiRepair(ej, ao, R, 4Sun:O.0, WidenBoth)
    ] KheResourceAssignMultiRepair ret. false

  We seem to be trying no repairs at all.  Here's the iterator at
  the start of the loop:

    [ KheWideningIterator()
      assignable R: {[4Wed-4Sun] 4Wed:O.0, 4Thu:O.0, 4Fri:O.0, 4Sat:O.0, 4Sun:O.0}
      assigned R: {[4Wed-4Sun] 4Wed:N.0, 4Fri:N2.0, 4Sat:O.0, 4Sun:N2.0}
      [ start_cuts: 
      ]
      [ stop_cuts: 
      ]
    ]

  The entries seem fine (4Sun is the last day); why are there no cuts?
  Because of "KheWideningIteratorStart returning (kernel)" - the kernel
  did not work, why not?  Because IntervalWorks had the two operations
  the wrong way around.  And now we have

    [ "COI-QMC-1", 12 threads, 12 solves, 27.5 secs:
      0.00018 0.00018 0.00020 0.00020 0.00020 0.00021 0.00022 0.00023
      0.00024 0.00024 0.00024 0.00027
    ] 0.00018 is best cost (diversifier 11)

  Now 18 is an improvement over 20, but still inferior to the
  16 that KHE24 was getting, and to the 13 of the best soln.
  So more grinding down is needed.  And here is GPost:

    [ "COI-GPost", 12 threads, 12 solves, 15.8 secs:
      0.00010 0.00011 0.00011 0.00011 0.00012 0.00012 0.00013 0.00013
      0.00014 0.01006 0.01009 0.01011
    ] 0.00010 is best cost (diversifier 9)

  This has deteriorated, let's bring back the full asst code:

    [ "COI-GPost", 12 threads, 12 solves, 12.4 secs:
      0.00008 0.00009 0.00009 0.00010 0.00011 0.00011 0.00014 0.00022
      0.01006 0.01011 0.01011 0.01012
    ] 0.00008 is best cost (diversifier 9)

    [ "COI-QMC-1", 12 threads, 12 solves, 81.6 secs:
      0.00017 0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00022 0.00022 0.00023
    ] 0.00017 is best cost (diversifier 11)

  It's quite a lot slower (82 secs vs 28 secs), but the result is
  one better.  What about 1108?

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01450 0.01510 0.01510 0.01515 0.01530 0.01535 0.01540 0.01545
      0.01545 0.01555 0.01560 0.01640
    ] 0.01440 is best cost (Nurse: 8 0.01450, Nurse:Trainee: 9 0.01510)

  Now 1440 is rel = 1.15.  It's just a bit worse than the 1410 I
  got during the last big run.  Better use of running time might
  be the answer here.  Here's a 10-minute run:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 10.0 mins:
      0.01410 0.01420 0.01440 0.01460 0.01470 0.01480 0.01495 0.01495
      0.01495 0.01510 0.01520 0.01525
    ] 0.01385 is best cost (Nurse: 7 0.01410, Nurse:Trainee: 9 0.01460)

  So this is what this code could do, given enough time.  Here
  1385 is rel = 1.11.  It's not far off the 1370 that was the
  best we ever did.  Here's a 20-minute run:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 19.5 mins:
      0.01390 0.01410 0.01440 0.01450 0.01465 0.01475 0.01480 0.01485
      0.01485 0.01485 0.01505 0.01510
    ] 0.01370 is best cost (Nurse: 8 0.01390, Nurse:Trainee: 2 0.01505)

  And there it is, for only the second time: 1370 (rel = 1.10).

  But now let's return to QMC-1:

    [ "COI-QMC-1", 12 threads, 12 solves, 74.4 secs:
      0.00017 0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00022 0.00022 0.00023
    ] 0.00017 is best cost (diversifier 11)

  The best known soln has cost 13, and KHE24 was getting 16.  So it
  would be worth more grinding down here.  A 10-minute run produced
  the same result, not surprising since the running time is 76 secs.
  So instead, let's try best of 48:

    [ "COI-QMC-1", 12 threads, 48 solves, 268.2 secs:
      0.00017 0.00017 0.00017 0.00018 0.00018 0.00018 0.00018 0.00018
      0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00020 0.00020
      0.00020 0.00020 0.00020 0.00020 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00021 0.00021 0.00021 0.00021 0.00021 0.00022 0.00022
      0.00022 0.00022 0.00022 0.00022 0.00022 0.00022 0.00022 0.00022
      0.00023 0.00023 0.00023 0.00024 0.00024 0.00025 0.00026 0.00027
    ] 0.00017 is best cost (diversifier 11)

  This consumed almost the whole 5 minutes, but still we are stuck
  on 17.  

1 March 2026.  Here are the defects from the best QMC-1 solution:

    Id / Point      Calculation                                  Inf.    Obj.
    -------------------------------------------------------------------------
    TimeOn-A-s1/A   1 * Linear(1 - 0 2Thu2-4)                               1
    TimeOn-C-s1/C   1 * Linear(1 - 0 3Fri5-7)                               1
    TimeOn-H-s1/H   1 * Linear(1 - 0 1Sat8-9; 1 - 0 1Sun2-4)                2
    TimeOn-J-s1/J   1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-L-s1/L   1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-N-s1/N   1 * Linear(1 - 0 1Wed5-7; 1 - 0 2Tue5-7; 1 - 0 3Mon5-7) 3
    TimeOn-O-s1/O   1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-P-s1/P   1 * Linear(1 - 0 1Sat1)                                 1
    TimeOn-Q-s1/Q   1 * Linear(1 - 0 1Tue8-9)                               1
    TimeOn-S-s1/S   1 * Linear(1 - 0 3Mon5-7)                               1
    -------------------------------------------------------------------------
      Total (10 points)                                                    13 

  And here are the defects from the current KHE solution:

    Id / Point      Calculation                                  Inf.    Obj.
    -------------------------------------------------------------------------
    TimeOn-A-s1/A     1 * Linear(1 - 0 2Thu2-4; 1 - 0 3Tue2-4)              2
    TimeOn-B-s1/B     1 * Linear(1 - 0 1Thu1)                               1
    TimeOn-C-s1/C     1 * Linear(1 - 0 3Fri5-7)                             1
    TimeOn-F-s1/F     1 * Linear(1 - 0 1Wed5-7; 1 - 0 2Sat5-7)              2
    TimeOn-H-s1/H     1 * Linear(1 - 0 1Sat8-9; 1 - 0 1Sun2-4)              2
    TimeOn-J-s1/J     1 * Linear(1 - 0 3Sat1)                               1
    TimeOn-L-s1/L     1 * Linear(1 - 0 2Sat1)                               1
    TimeOn-N-s1/N     1 * Linear(1 - 0 1Sat1; 1 - 0 3Fri1; 1 - 0 2Tue5-7)   3
    TimeOn-Q-s1/Q     1 * Linear(1 - 0 1Sat5-7; 1 - 0 3Mon5-7)              2
    TimeOn-S-s1/S     1 * Linear(1 - 0 2Sat1; 1 - 0 3Mon5-7)                2
    -------------------------------------------------------------------------
      Total (10 points)                                                    17

  TimeOn-B-s1/B is a free day request that is honoured in the best soln
  but not in the KHE solution.  So that would be a good one to work on.

  Just ejecting from 1Thu does not work because it leaves a sequence
  of busy days of length 1 at 1Wed.  So what about ejecting both of
  them?  The problem then is that we get two assign resource defects,
  one for each of the ejected tasks.  Could we group those defects?
  Could we group the two shifts and group the defects?  That would
  be something quite new, but interesting.  We would have to ungroup
  on a successful repair.

  Perhaps we could pass a "group new defects" parameter to repair end.
  In any case we would want to do it for unassignments only, and only
  the assign resource defects, and only if that allowed a chain to
  continue.  Perhaps do it at the start of the repair operation,
  after the mtask set slice is returned but before the repair
  operation is called.  We could undo it after the repair operation,
  whether it succeeds or not.  Yes, that seems like the best way.

2 March 2026.  From tomorrow, I'm taking a week off to go
  bushwalking.

20 March 2026.  It's been a busy time, with bushwalking at first
  and Mum dying afterwards.  However I have made a start on my
  PATAT paper today:  just an abstract reporting my recent good
  results with KHE26 on the INRC2-4 instances, and promising
  more detail at the conference.  It's all done, basically;
  I need to let it lie for a few days, then submit it.

21 March 2026.  The PATAT paper is done, and I've even put the
  XESTT file from which Table 1 is derived on my web site and
  referenced it.  I've submitted the paper, and added it to my
  web site.

22 March 2026.  Grinding down QMC-1.  I'm currently getting

    [ "COI-QMC-1", 12 threads, 12 solves, 80.8 secs:
      0.00017 0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00022 0.00022 0.00023
    ] 0.00017 is best cost (diversifier 11)

  whereas the best known solution has cost 13 (see 1 March 2026).

  Thinking about grouping the tasks that get unassigned.  They
  come from an mtask slice, so we need

     bool KheMTaskSliceGroupTasks(KHE_MTASK_SET_SLICE mtss,
       KHE_RESOURCE r, KHE_TASK_GROUPER tg, KHE_MTASK_FINDER mtf,
       KHE_TASK *task, KHE_SOLN_ADJUSTER sa)

  which does the grouping and returns the grouped task in *task,
  if it can.  This will call KheMTaskFinderTaskGrouperMakeGroup.
  Then we need to group the assign resource monitors of *task
  and its descendants.  Everything goes into sa so that it can
  be undone.  But we need to undo in mtf as well, which this
  plan doesn't yet allow for.

23 March 2026.  OK, here's the plan.  It would arguably be best
  to take KHE_MTASK into the platform so that mtasks can be
  kept up to date automatically as tasks are assigned.  But
  that would be a huge change, and I'm not ready for it now.

  So instead we divide operations on tasks into two kinds
  and treat them differently:

  * Platform operations - these have no knowledge of mtasks,
    so we need to make solver versions of them as we are doing
    now, passing their usual parameters plus mtf.  We have this
    now for KheMTaskFinderTaskMove, KheMTaskFinderTaskAssign,
    KheMTaskFinderTaskUnAssign, KheMTaskFinderTaskSwap,
    KheMTaskFinderTaskAssignFix, and KheMTaskFinderTaskAssignUnFix.

  * Solver operations - leave these where they are but add
    an mtf parameter at the end of each one.  If mtf != NULL,
    these operations update mtf as required.  This involves
    making KheMTaskFinderAddTask and KheMTaskFinderDeleteTask
    public and calling them as required, when mtf != NULL.
    We have this now for KheMTaskFinderTaskGrouperMakeGroup,
    but the plan is to remove that function and add an mtf
    parameter to KheTaskGrouperMakeGroup.  We need to be
    able to undo this call, for use in sa.

  Changed all occurrences of UnAssign to Unassign, in the
  platform code, the solver code, and the documentation.

  Changed the task and meet fix and unfix functions to
  the more usual Check and Do forms, with bool results.
  This is for uniformity.  I've checked that all uses
  of these functions are still using them correctly,
  and I've updated the documentation.

27 March 2026.  The last few days have gone on a CT scan,
  Mum's funeral, and related things.  Back at work today.

28 March 2026.  Designed, documented, and implemented
  KheSolnAdjusterMonitorGroupBegin, KheSolnAdjusterMonitorGroupAdd,
  and KheSolnAdjusterDoMonitorGroupEnd.  It's not everything,
  but it will make the monitor grouping part of the unassigned
  task grouping problem easy.  In khe_se_solvers.c, I've also
  written KheTaskGroupAssignResourceMonitors to actually do
  this grouping.

29 March 2026.  Audited yesterday's work, it's all good.  So
  at least I can group the monitors now.  Then I went on and
  did something that produced a clean compile and might even
  be correct.  But it needs a careful audit.  Especially the
  undoing and its mtask aspect.

30 March 2026.  Today I need to audit yesterday's work, and
  then go on to implement the undoing part of it.

  Verified that mtask grouping only groups unassigned tasks.
  The documentation already said so, but I made it clearer.

  Redo it, this time allowing for grouping tasks assigned
  a given resource r.  Will be simpler in the end.  No,
  because you can't be sure that the mtask invariant will
  hold if you do this.

  Added an sa parameter to KheMTaskFinderAddTask and
  KheMTaskFinderDeleteTask, and that seems to have finished
  the job.  It all needs an audit, but it's looking good.

31 March 2026.  Sorted out the solution adjuster interface,
  implementation, and documentation.  It's all good now.
  I've also done this for the "forbidden" operations of
  the mtask finder, although somewhat less convincingly.
  Still, I have a clean compile and things are reasonable.

1 April 2026.  Audited khe_sm_soln_adjuster.c; I found quite
  a lot of small points.  Audited KheResourceUnassignRepair;
  Started testing; I currently have a bug undoing grouping.
  Someone is assigning 1Fri:O.4 to /B/ at a time when it
  is supposed to be grouped under 1Sun:E2.0.  It probably
  means that the mtasks are not working properly, but I
  am not sure about it yet.

2 April 2026.  It looks like the bad move comes from the
  recursive call on the ejector:

    [ KheResourceUnassignRepair calling RepairEnd(true)
      [ KheTaskDoMove("1Fri:O.4", "-")
	KheTaskDoUnassign(task "1Fri:O.4")
	KheTaskDoMove("1Fri:O.4", "-") (b)
	KheTaskDoMove("1Fri:O.4", "-") (c)
      ] KheTaskDoMove
      [ KheTaskDoMove("1Fri:O.4", "/B/")
	KheTaskDoMove("1Fri:O.4", "/B/") (b)
	KheTaskDoMove("1Fri:O.4", "/B/") (c)
      [ KheTaskDoAssign(task 1Fri:O.4, target_task /B/), 0 monitors
      ] KheTaskDoAssign
      ] KheTaskDoMove
    ] KheResourceUnassignRepair end RepairEnd

  It should not be touching 1Fri:O.4 at this point, because
  it is grouped.  Or if it is touching it, it should just be
  on its way to the root task.

    [ KheResourceUnassignRepair calling RepairEnd(true)
      [ KheEjectorRepairEnd(ej, 11, true)
	KheEjectorRepairEnd calling KheMarkUndo
	[ KheTaskDoMove("1Fri:O.4", "-")
	  KheTaskDoUnassign(task "1Fri:O.4")
	  KheTaskDoMove("1Fri:O.4", "-") (b)
	  KheTaskDoMove("1Fri:O.4", "-") (c)
	] KheTaskDoMove
	[ KheTaskDoMove("1Fri:O.4", "/B/")
	  KheTaskDoMove("1Fri:O.4", "/B/") (b)
	  KheTaskDoMove("1Fri:O.4", "/B/") (c)
	[ KheTaskDoAssign(task 1Fri:O.4, target_task /B/), 0 monitors
	] KheTaskDoAssign
	] KheTaskDoMove
      ] KheEjectorRepairEnd returning false (d)
    ] KheResourceUnassignRepair RepairEnd returned false

  Everything we've done has gone into the path, even the
  things from before KheEjectorRepairBegin; because that
  does not reset the path, nor can it do so.

3 April 2026.  I've implemented KheSolnHideMainPathBegin and
  KheSolnHideMainPathEnd.  That seems to have got me past the
  double undo problem documented above, but now I have this:

    KheGroupMonitorAddChildMonitor: operation would cause a monitor cycle

  The code seems OK, I need some debug output.

4 April 2026.  Fixed yesterday's bug.  Today's bug is in the dynamic
  resource solver, of all places:

    KheDrsSolveClose internal error:
      KHE soln cost 0.00020 != packed soln cost -0.00980

  It seems that some cost 1000 monitor is having its cost added in
  once and subtracted away twice.  But why?  I've verfied that
  this only happens when the new repair is included, so it must
  be leaving the solution in a defective state, somehow.  Look
  at this; it must be wrong:

    KheDrsPackedSolnMake(-0.00980, drs)

  I've tracked it down to

    KheDrsExprCounterChildHasOpened: solve_start_cost +=
      (0.00000 - 0.01000) = -0.00980 from ARC:NA=s1000:2/1Thu:E/NA=s1000:2
    old_dev = 1 = KheDrsExprCounterDev(ec[1, 2147483647], 0 + 0, 0 + 0)
    new_dev = 0 = KheDrsExprCounterDev(ec[1, 2147483647], 0 + 0, 1 + 0)

  I need to delve into what the various components are saying.  Wait:
  the monitor is showing A0, meaning attached to the soln but not
  a descendant of the solution group monitor:

    [ A0 00483 ARC:NA=s1000:2/1Thu:E/NA=s1000:2
	0.01000 Nurse:1Thu:E:NA=s1000:2 asst (-) ]

  Why not?

5 April 2026.  Hurrah, fixed the bug.  I was getting my group
  monitors confused when building the unassign group monitor.
  But now I have another bug, which I have refined into

    KheMTaskCheckAssignments failing (not unassigned at position 0)

  KheResourceSwapRepair seems to be the problem.  The initial
  call on KheMTaskFinderCheckAssignments passes, but the final
  call does not.  It may have to do with paths not undoing mtask
  operations, although I thought that was OK because the paths
  just returned us to where we were before.  But that may not
  be good enough when mtasks are changing.  Needs thinking about.
  It seems that asst_count is *allowed* to be out of date; see
  the comment on function KheMTaskBringAsstCountUpToDate.  Here
  is the true invariant:

    Even when mt->asst_count is out of date, we still assume
    that all the assigned tasks are at the front.

  So when we add a task, it is a mistake to assume that asst_count
  is up to date.

  OK, the real problem is that KheMTaskTidyAssignments is called
  only by KheMTaskAddTask and assumes that KheMTaskAddTask is
  called only when making the mtask finder.  But KheMTaskAddTask
  is now being called from other places, and in particular its
  asst_count field can be out of date, whereas KheMTaskTidyAssignments
  assumes that it isn't.

6 April 2026. Sorting out the mtask assignment count problem today.
  Rewrote KheMTaskTidyAssignments, it looks good.  First results:

    [ "COI-QMC-1", 1 solution, in 36.5 secs: cost 0.00019 ]

    [ "COI-QMC-1", 12 threads, 12 solves, 75.6 secs:
      0.00017 0.00018 0.00019 0.00019 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00022 0.00022 0.00023
    ] 0.00017 is best cost (diversifier 11)

  Sadly, this is no better than I was getting before.  The best
  known solution has cost 13, KHE24 was getting cost 16.  It took
  me since 22 March, which was when I got this identical result.
  Two weeks for no discernible progress.

  Here is the defect table for the best known solution:

    Constraint Id / Point         Calculation                 Inf.       Obj.
    ------------------------------------------------------------------------
    TimeOn-A-s1/A  1 * Linear(1 - 0 2Thu2-4)                               1
    TimeOn-C-s1/C  1 * Linear(1 - 0 3Fri5-7)                               1
    TimeOn-H-s1/H  1 * Linear(1 - 0 1Sat8-9; 1 - 0 1Sun2-4)                2
    TimeOn-J-s1/J  1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-L-s1/L  1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-N-s1/N  1 * Linear(1 - 0 1Wed5-7; 1 - 0 2Tue5-7; 1 - 0 3Mon5-7) 3
    TimeOn-O-s1/O  1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-P-s1/P  1 * Linear(1 - 0 1Sat1)                                 1
    TimeOn-Q-s1/Q  1 * Linear(1 - 0 1Tue8-9)                               1
    TimeOn-S-s1/S  1 * Linear(1 - 0 3Mon5-7)                               1
    ------------------------------------------------------------------------
      Total (10 points)                                                   13

  And here is the table for the KHE26x12 solution:

    Constraint Id / Point         Calculation                 Inf.       Obj.
    ------------------------------------------------------------------------
    TimeOn-A-s1/A  1 * Linear(1 - 0 2Thu2-4; 1 - 0 3Tue2-4)                2
    TimeOn-B-s1/B  1 * Linear(1 - 0 1Thu1)                                 1
    TimeOn-C-s1/C  1 * Linear(1 - 0 3Fri5-7)                               1
    TimeOn-F-s1/F  1 * Linear(1 - 0 1Wed5-7; 1 - 0 2Sat5-7)                2
    TimeOn-H-s1/H  1 * Linear(1 - 0 1Sat8-9; 1 - 0 1Sun2-4)                2
    TimeOn-J-s1/J  1 * Linear(1 - 0 3Sat1)                                 1
    TimeOn-L-s1/L  1 * Linear(1 - 0 2Sat1)                                 1
    TimeOn-N-s1/N  1 * Linear(1 - 0 1Sat1; 1 - 0 3Fri1; 1 - 0 2Tue5-7)     3
    TimeOn-Q-s1/Q  1 * Linear(1 - 0 1Sat5-7; 1 - 0 3Mon5-7)                2
    TimeOn-S-s1/S  1 * Linear(1 - 0 2Sat1; 1 - 0 3Mon5-7)                  2
    ------------------------------------------------------------------------
      Total (10 points)                                                   17

  So we need whynots for the defects in the KHE26x12 solution that are
  not in the best known solution.

  TimeOn-B-s1/B is asking for the O shift on 1Thu (i.e. day off), but
  in fact B has the E (Early) shift on that day.  There is in fact
  a sequence of two E shifts in the KHE26 solution, on 1Wed and 1Thu.
  So a grouped unassigned would be just the ticket.

  Actually an ejecting assign would be better, and in fact I'm
  doing that now:

    KheResourceEjectingAssignRepair+(B, 1Wed-1Thu,
      {2-3: 1Wed:O.0, 1Thu:O.0}, {0-1: 1Wed:E.0, 1Thu:E.0})
      new defect 0.00000 -> 0.01000: [ A1 00482 ARC:NA=s1000:2/1Wed:E/NA=s1000:2
        0.01000 Nurse:1Wed:E:NA=s1000:2 asst (-) ]
      new defect 0.00000 -> 0.01000: [ A1 00483 ARC:NA=s1000:2/1Thu:E/NA=s1000:2
        0.01000 Nurse:1Thu:E:NA=s1000:2 asst (-) ]

  But to make this effective I need to group together the two monitors
  of the tasks that get unassigned.

  I've made separate functions for grouping for unassignment, and
  I'm now using them for grouped ejecting assignments.  First test:

    [ "COI-QMC-1", 1 solution, in 45.1 secs: cost 0.00017 ]

    [ "COI-QMC-1", 12 threads, 12 solves, 76.1 secs:
      0.00017 0.00018 0.00018 0.00018 0.00019 0.00019 0.00019 0.00020
      0.00020 0.00021 0.00021 0.00021
    ] 0.00017 is best cost (diversifier 0)

  The best is no better, but some solutions are better, including
  the worst solution (was 23, now 21), so I'm counting that as a
  success of sorts.  Tried a 10-minute run, nothing new there.
  Tried best of 48:

    [ "COI-QMC-1", 12 threads, 48 solves, 264.6 secs:
      0.00015 0.00015 0.00017 0.00017 0.00018 0.00018 0.00018 0.00018
      0.00018 0.00018 0.00018 0.00018 0.00019 0.00019 0.00019 0.00019
      0.00019 0.00020 0.00020 0.00020 0.00020 0.00020 0.00020 0.00020
      0.00021 0.00021 0.00021 0.00021 0.00021 0.00021 0.00021 0.00021
      0.00021 0.00021 0.00021 0.00021 0.00022 0.00022 0.00022 0.00022
      0.00022 0.00022 0.00022 0.00022 0.00022 0.00023 0.00023 0.00024
    ] 0.00015 is best cost (diversifier 33)

  I could do this within 5 minutes if the parallel solver was
  willing to keep starting solves while time is available.

  I've documented and implemented some changes to the ps_make,
  ps_time_limit, and gs_time_limit options which allow the solver
  to keep starting solves until time runs out.  It all seems
  to be working, and it's giving this for COI-QMC-1:

    [ "COI-QMC-1", 12 threads, 54 solves, 297.0 secs:
      0.00015 0.00015 0.00017 0.00017 0.00018 0.00018 0.00018 0.00018
      0.00018 0.00018 0.00018 0.00018 0.00018 0.00019 0.00019 0.00019
      0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00020 0.00020
      0.00020 0.00020 0.00020 0.00020 0.00021 0.00021 0.00021 0.00021
      0.00021 0.00021 0.00021 0.00021 0.00021 0.00021 0.00021 0.00021
      0.00021 0.00022 0.00022 0.00022 0.00022 0.00022 0.00022 0.00022
      0.00022 0.00022 0.00022 0.00023 0.00023 0.00024
    ] 0.00015 is best cost (diversifier 33)

  I've also tried adding ps_make=24, and I got this:

    [ "COI-QMC-1", 12 threads, 24 solves, 139.4 secs:
      0.00017 0.00018 0.00018 0.00018 0.00018 0.00018 0.00019 0.00019
      0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00020 0.00021
      0.00021 0.00021 0.00021 0.00021 0.00021 0.00022 0.00023 0.00024
    ] 0.00017 is best cost (diversifier 0)

  which is correct but not as good a result as I got before.  So it
  looks like the best thing to do is to use up the five minutes on
  every instance.

  Tried a run of all of COI.xml.  But hit a snag:  the call to
  KheSolnAdjusterUndo in case KHE_SOLVER_RCG of yourself
  (combinatorial grouping) failed (line 1502), because it
  could not undo a call to KheMTaskFinderAddTask.  Need to
  look into the combinatorial grouper to see how it is using
  sa and mtf, it may be deleting it too soon.

7 April 2026.  Yesterday's problem seems to be that the mtask
  finder is made within the combinatorial grouper module, and
  then becomes out of date when KheSolnArenaEnd is called at
  the end of KheCombinatorialGrouping.  I guess I have to treat
  it like tgdf, and keep it around for the duration.  But it's
  slow, so I'll have to think carefully about when it is present
  and when it isn't.  Files that call KheMTaskFinderMake but
  not in a way that interacts with KHE_SOLN_ADJUSTER:

    khe_se_solvers.c
    khe_sr_dynamic_resource.c
    khe_sr_dynamic_time_sweep.c
    khe_sr_first_resource.c
    khe_sr_pack_resource.c

  Files that call KheMTaskFinderMake and do interact with it:

    khe_sr_comb_grouping.c	(current problem)
    khe_sr_interval_grouping.c	(similar problem to comb grouping)

  So there are two cases of the current problem.  Basically the
  mtask finder needs to last for as long as the solution adjuster;
  or if it doesn't, then it needs to be deleted from the solution
  adjuster.  Could we have a single mtask finder for all of
  resource assignment?  The problematic operations are

    KheSolnAdjusterMTaskFinderAddTask (calls KheMTaskFinderAddTask)
    KheSolnAdjusterMTaskFinderDeleteTask (calls KheMTaskFinderDeleteTask)

  Both are called only from function KheMTaskFinderTaskGrouperMakeGroup
  in khe_sr_mtask_finder.c.  It in turn is called only by

    khe_sr_interval_grouping.c (KheIgTaskGroupTaskGrouperBuildGroup)
    khe_sr_mtask_grouper.c (KheMTaskGrouperMakeOneGroup)

  The question is, when we come to undo, are we undoing the mtasks
  as well as the tasks?  At present, the undo thinks we are.

    void KheSolnAdjusterMTaskFinderBegin(KHE_SOLN_ADJUSTER sa,
      KHE_MTASK_FINDER mtf);
    void KheSolnAdjusterMTaskFinderEnd(KHE_SOLN_ADJUSTER sa,
      KHE_MTASK_FINDER mtf);

  and the second function turns all the mtf operations into no-ops.
  If mtf is made first, it will be deleted last and there is no
  need for these functions.

  Trying a full run of COI now.  NB we're using ordinary time
  sweep, that is rts, for the initial assignment.

  Have this remarkble bug in KheSolnAdjusterUndo:

    KheSolnAdjusterUndo cost 0.27179 before op 23
    [ undoing DeleteTask, initial cost 0.27179
    ] undoing DeleteTask, final cost 0.27177

  In between these two prints there is nothing except a single
  call to KheMTaskFinderAddTask.  But I suppose it could rearrange
  the assignments a bit and cause the cost to change that way.
  Yes, that is what happened.

8 April 2026.  Looking at yesterday's bug.  It seems we are coming
  back from ejection chains (or somewhere) with clashes, two Late
  shifts for the same resource, or two Early.  The clashes are
  introduced by a call to KheMarkEnd, as some debug output shows.

  I can't work it out exactly but it is not surprising that an
  undo should do something that does not gel with sa.  I need
  a rethink about how sa interacts with marks and paths.  It
  should not be doing stuff that interacts at all, I deem.

  Back to the drawing board.  OK, here is a plan.  Do no task
  grouping at all.  Instead, just group monitors.  When repairing a
  grouped assign resource monitor, try only repairs that assign all
  of its tasks.  I've verified that sub-tag KHE_SUBTAG_ASSIGN_RESOURCE
  does not occur in any .c file, that is, it is currently unused.
  So we can assume that any grouped assign resource monitor is
  grouped for this reason.

  Currently we are using KheEventResourceMultiRepair to repair
  assign resource defects.  We are going to have to generalize
  it.  The key code for assign resource defects is

    KheForEachNonNullResource(to_ri, other_r)
    if( KheResourceAssignMultiRepair(ej, ao, other_r,from_mt,widen_type) )
    {
      return true;
    }

  we are going to have to replace this with an mtask set.  But
  that is quite doable, surely, based on the tasks monitored
  by the individual monitors.  We might not bother with widening,
  but we can still do ejecting assignments.

9 April 2026.  Implementing the 8 April plan.  At the repair, all
  is done including KheMTaskSetSliceGroupAssignResourceMonitors,
  which is audited and ready to test.  At the assign resource
  augment function, nothing is done yet except a debug print.
  Still I did this 5-minute run, just to see what happens:

    [ "COI-QMC-1", 12 threads, 52 solves, 5.8 mins:
      0.00016 0.00016 0.00016 0.00017 0.00017 0.00018 0.00018 0.00018
      0.00018 0.00019 0.00019 0.00019 0.00019 0.00019 0.00019 0.00019
      0.00020 0.00020 0.00020 0.00020 0.00020 0.00020 0.00020 0.00020
      0.00020 0.00020 0.00020 0.00020 0.00020 0.00021 0.00021 0.00021
      0.00021 0.00021 0.00021 0.00021 0.00021 0.00022 0.00022 0.00022
      0.00022 0.00023 0.00023 0.00023 0.00023 0.00023 0.00023 0.00024
      0.00024 0.00024 0.00026 0.00030
    ] 0.00016 is best cost (diversifier 3)

  Here 16 is what KHE24 was getting before; 13 is best known.

  KheAssignResourceGroupAugment, KheResourceAssignMultiRepair,
  KheWideningIteratorExtraBeginAssignable, and
  KheFindAssignableMTasksInInterval all updated now to handle
  grouped assign resource monitors.  All audited and ready to test.

10 April 2026.  Carried out another audit of the new code.  All good.
  Testing, go this from a 5-minute run:

    [ "COI-QMC-1", 12 threads, 51 solves, 5.1 mins:
      0.00016 0.00016 0.00017 0.00017 0.00018 0.00018 0.00018 0.00018
      0.00018 0.00018 0.00019 0.00019 0.00019 0.00019 0.00019 0.00019
      0.00019 0.00019 0.00019 0.00019 0.00020 0.00020 0.00020 0.00020
      0.00020 0.00020 0.00020 0.00020 0.00021 0.00021 0.00021 0.00021
      0.00021 0.00021 0.00021 0.00022 0.00022 0.00022 0.00022 0.00023
      0.00023 0.00023 0.00023 0.00023 0.00023 0.00023 0.00023 0.00024
      0.00024 0.00024 0.00030
    ] 0.00016 is best cost (diversifier 28)

  This is probably good enough to go on with.

  Doing a full COI run now, limiting the number of solves to 48.
  Got a new best for COI-QMC-2:  cost 29, which is optimal.  So
  far all my solutions are at least as good as KHE24 (a few are
  better, e.g. ORTEC01), except that SINTEF has cost 1 whereas
  KHE24 has cost 0, ORTEC02 has cost 305 where KHE24 has cost
  295.  Also the Ikegami instances generally are returning
  relatively poor results.  Need to look into SINTEF and see
  if anything can be done.  On the larger instances (e.g COI-ERMGH
  and COI-CHILD), KHE26 is doing quite a lot better than KHE24,
  which is encouraging.

  Fixed the timing problem that was causing COI-ORTEC01 to run
  for 7.3 minutes.  All documented and tested.  COI-ORTEC01 now
  runs for 5.0 minutes.

  SINTEF is fine now:

    [ "COI-SINTEF", 12 threads, 126 solves, 30.5 secs:
      0.00000 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
      0.00002 0.00002 0.00002 0.00002 0.00003 0.00003 0.00003 0.00003
      0.00003 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003
      0.00004 0.00004 0.00004 0.00004 0.00004 0.00004
    ] 0.00000 is best cost (first diversifier 117)

  Here is COI-Ikegami-2.1:

    [ "COI-Ikegami-2.1", 12 threads, 27 solves, 5.0 mins:
      0.00003 0.00004 0.00004 0.00005 0.00006 0.00007 0.00007 0.00008
      0.00009 0.00010 0.00011 0.00012 0.00020 0.00021 0.00024 0.00024
      0.00025 0.00026 0.00027 0.00034 0.00042 0.00043 0.00052 0.00057
      0.00263 0.00559 0.04086
    ] 0.00003 is best cost (first diversifier 2)

  OK, the best known solution has cost 0, and KHE24 was also getting
  cost 0.  So I need to grind down this cost 3.  Interestingly, all
  three defects are limit resources defects:

    Constraint Id / Point           Calculation       Inf.       Obj.
    -----------------------------------------------------------------
    DemandConstraint:2A/1Sat:N      1 * Linear(1)                 1
    DemandConstraint:21A/2Tue:D     1 * Linear(3 - 2 2Tue:D)      1
    DemandConstraint:2A/3Sun:N      1 * Linear(1)                 1
    -----------------------------------------------------------------
      Total (3 points)                                            3

  I've assembled some fun facts about COI-Ikegami-2.1 (see below).
  Looks like time for some whynot runs.  Assigning A02 (which is
  what LOR has here) gives this:

    [ KheResourceAssignRepair+(A02, 1Sat, {1-1: 1Sat:N.0})
      new defect 0.00000 -> 0.00100: [ A1 00267 Constraint:21/A02/3
	0.00100 CBTM max 4, active_count 5 ]
      new defect 0.00000 -> 0.00001: [ A1 05689 DemandConstraint:24A/1Sat:N
	0.00001 LRM (min 4, max 4, curr 5) ]
    ]

  Constraint:21 is an unwanted pattern, 1Fri:N, free, free, free, 1Tue:N.
  DemandConstraint:24A is a minimum and maximum limit pof 4 on the number
  of night shifts.  These are indeed problems with assigning A02.
  Assigning A03 gives even more problems:

    [ KheResourceAssignRepair+(A03, 1Sat, {1-1: 1Sat:N.0})
      new defect 0.00000 -> 1.00000: [ A1 04353 Constraint:27/A03/3
	1.00000 LBTM (min 0, max 1, allow_zero false, dev 1)
	1Sat (busy 2, open 0) ]
      new defect 0.00000 -> 0.00100: [ A1 01751 Constraint:23/A03/3
	0.00100 CBTM max 3, active_count 4 ]
      new defect 0.00000 -> 0.00100: [ A1 05135 Constraint:35/A03
	0.00100 LBTM (min 4, max 5, allow_zero false, dev 1)
	1-4Fri-Thu1:5Fri-Sat1 (busy 6, open 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05689 DemandConstraint:24A/1Sat:N
	0.00001 LRM (min 4, max 4, curr 5) ]
    ]

  Constraint:27 is single assignment per day.  Not sure what the problem
  is there.  Constraint:23 is unwanted pattern 1Fri:N, free, free, 1Mon:N
  which does not look right either.  Need to run again, I think.

11 April 2026.  Grinding down COI-Ikegami-2.1.  Tried best over 5 mins
  as yesterday, got the same result (cost 3), with the same defects:

    Constraint Id / Point           Calculation       Inf.       Obj.
    -----------------------------------------------------------------
    DemandConstraint:2A/1Sat:N      1 * Linear(1)                 1
    DemandConstraint:21A/2Tue:D     1 * Linear(3 - 2 2Tue:D)      1
    DemandConstraint:2A/3Sun:N      1 * Linear(1)                 1
    -----------------------------------------------------------------
      Total (3 points)                                            3

  The queer thing is that when I rerun with a single thread and a
  whynot (or indeed without a whynot), I get a solution of cost 6.
  However the rerun includes a defect at DemandConstraint:2A/1Sat:N,
  so I guess that's near enough.

  I've looked at the six resources with skill "Skill-Skilled" (A01,
  A02, A03, B11, B12, C20, and C21) and verified that resource assign
  repairs are being tried using all of them, and that there are good
  reasons why they all fail.  All the same, I need to think now about
  how these defects could be repaired.  The whynot is for

    [ A1 05308 DemandConstraint:2A/1Sat:N
	0.00001 LRM (min 1, max 2, curr 0) ]

  which requests 1 or 2 Skill-Skilled resources on 1Sat:N.
  Here is the A02 whynot:

    KheResourceAssignRepair+(A02, 1Sat, {1-1: 1Sat:N.0})
      new defect 0.00000 -> 0.00100: [ A1 00267 Constraint:21/A02/3 
        0.00100 CBTM max 4, active_count 5 ]
      new defect 0.00000 -> 0.00001: [ A1 05689 DemandConstraint:24A/1Sat:N
        0.00001 LRM (min 4, max 4, curr 5) ]

  where Constraint:21 is unwanted pattern 1Fri1, *, *, *, 1Tue1, and
  DemandConstraint:24A requests exactly 4 nurses for the night shift.
  So when we add a skilled nurse, we are always going to spring this
  limit.  Do we need some analysis of these limit resources constraints,
  to understand what they are really asking for?  Perhaps we can do
  some fancy domain setting to, in effect, make them independent.

    [ KheBalancedResourceAssignRepair+(A02, {1-1: 1Sat:N.0}, {[1Wed] 1Wed:N.0})
      new defect 0.00000 -> 0.00001: [ A1 05689 DemandConstraint:24A/1Sat:N
        0.00001 LRM (min 4, max 4, curr 5) ]
      new defect 0.00000 -> 0.00001: [ A1 05282 DemandConstraint:1A/1Wed:N
        0.00001 LRM (min 1, max 2, curr 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05312 DemandConstraint:2A/1Wed:N
        0.00001 LRM (min 1, max 2, curr 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05462 DemandConstraint:7A/1Wed:N
        0.00001 LRM (min 1, max 2, curr 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05693 DemandConstraint:24A/1Wed:N
        0.00001 LRM (min 4, max 4, curr 3) ]
    ]

  So let's look at what constraints apply to 1Sat:N:

    <Event Id="1Sat:N">
      <Name>1Sat:N</Name>
      <Duration>1</Duration>
      <Time Reference="1Sat1"/>
      <Resources>
	<R>X:1</R>
	<R>X:2</R>
	<R>X:3</R>
	<R>X:4</R>
	<R>X:5</R>
      </Resources>
      <EventGroups>
	<EventGroup Reference="EG:All"/>
	<EventGroup Reference="EG:X"/>
      </EventGroups>
    </Event>

  There are no asssign resource or prefer resources constraints, so
  all cover constraints are limit resources constraints.  Here are
  all constraints that apply to 1Sat:N.  They apply to all other
  Night events as well, but those are separate points of application
  so we have deleted those.  They also apply to all five roles of
  1Sat:N, but again we've deleted those:

    <LimitResourcesConstraint Id="DemandConstraint:1A">
      <Name>N:SkillGroup-A_SS, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="SkillGroup-A_SS"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:2A">
      <Name>N:Skill-Skilled, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="Skill-Skilled"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:3A">
      <Name>N:SkillGroup-B_SS, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="SkillGroup-B_SS"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:4A">
      <Name>N:SkillGroup-C_SS, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="SkillGroup-C_SS"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:5A">
      <Name>N:Skill-GroupB, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="Skill-GroupB"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:6A">
      <Name>N:Skill-GroupC, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="Skill-GroupC"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:7A">
      <Name>N:Skill-GroupA, min 1, max 2</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="Skill-GroupA"/>
      </ResourceGroups>
      <Minimum>1</Minimum>
      <Maximum>2</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:24A">
      <Name>N:all, min 4, max 4</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="RG:All"/>
      </ResourceGroups>
      <Minimum>4</Minimum>
      <Maximum>4</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

    <LimitResourcesConstraint Id="DemandConstraint:36A">
      <Name>N:Skill-RecentlyQualified, max 1</Name>
      <Required>false</Required>
      <Weight>1</Weight>
      <CostFunction>Linear</CostFunction>
      <AppliesTo>
	<Events>
	  <Event Reference="1Sat:N"/>
	</Events>
      </AppliesTo>
      <ResourceGroups>
	<ResourceGroup Reference="Skill-RecentlyQualified"/>
      </ResourceGroups>
      <Maximum>1</Maximum>
      <Roles> (all)
    </LimitResourcesConstraint>

  To summarize, with the order rearranged:

     Weight	Resources			Min	Max
     ------------------------------------------------------------
     Soft 1	Skill-GroupA			1	2
     Soft 1	SkillGroup-A_SS			1	2
     Soft 1	Skill-GroupB			1	2
     Soft 1	SkillGroup-B_SS			1	2
     Soft 1	Skill-GroupC			1	2
     Soft 1	SkillGroup-C_SS			1	2

     Soft 1	Skill-Skilled			1	2
     Soft 1	RG:All				4	4
     Soft 1	Skill-RecentlyQualified		0	1
     ------------------------------------------------------------

  Here are how the resources line up with the resource groups:

    	A	B	C	A_SS	B_SS	C_SS	Skilled	RQ
    --------------------------------------------------------------
    A01	*			*			*
    A02	*			*			*
    A03	*			*			*
    A04	*			*
    A05	*			*
    A06	*			*
    A07	*			*
    A08	*							*
    A09	*							*
    A10	*							*
    B11		*			*		*
    B12		*			*		*
    B13		*			*
    B14		*			*
    B15		*			*
    B16		*			*
    B17		*			*
    B18		*						*
    B19		*						*
    C20			*			*	*
    C21			*			*	*
    C22			*			*
    C23			*			*
    C24			*			*
    C25			*			*
    C26			*			*
    C27			*					*
    C28			*					*
    --------------------------------------------------------------

   What this amounts to is this.  The resources are partitioned into
   types A, B, and C, which have complementary skills.  Within each
   type, the nurses have three skill levels:  RQ (the lowest), SS
   (the middle), and SS + Skilled (the highest).  The constraints say:

     (1) Exactly four nurses altogether;
     (2) Either 1 or 2 A nurses, including at least one A_SS nurse;
     (3) Either 1 or 2 B nurses, including at least one B_SS nurse;
     (4) Either 1 or 2 C nurses, including at least one C_SS nurse;
     (5) Either 1 or 2 Skilled nurses;
     (6) At most one recently qualified nurse.

  You could express this by adding domains to tasks, requiring one
  A_SS nurse, one B_SS nurse, one C_SS nurse, and one arbitrary
  nurse.  The X:5 slot you could prohibit altogether.  This
  would cover constraints (1), (2), (3), (4), and (6), leaving
  only (5) as a true limit resources constraint.  Given the way
  that the Skilled group cuts across the three types, this seems
  to be the best possible arrangement.

  The two Night defects in the cost 3 solution are for constraint
  DemandConstraint:2A, which asks for 1 to 2 Skilled nurses.  This
  constraint is the only one that cannot be expressed by adding
  domains to tasks, as we've just seen, suggesting that adding
  domains to tasks might not solve our problems.

12 April 2026.  Continuing yesterday's analysis, there is no Skilled
  nurse supply shortage.  In the KHE solution, the 7 Skilled nurses
  have 3 + 4 + 3 + 3 + 3 + 2 + 2 = 20 available times.  In the
  optimal solution the number is 3 + 2 + 1 + 3 + 2 + 2 + 3 = 16.

  To satisfy exactly four nurses for the night shift, don't we need
  to just move one Night task from one nurse to another?  Are we
  doing that?  What kind of repair is that?  At present (see
  KheEventResourceMultiRepair, line 7244 and following), we
  are trying only swaps, which is fine when the Skilled resource
  is free.  Here's what should be a successful example:

    [ KheResourceSwapRepair+(A05, A03, 1Sat, {1-1: 1Sat:N.0}, {1-0: })
      new defect 0.00000 -> 0.00001: [ A1 05278 DemandConstraint:1A/1Sat:N
        0.00001 LRM (min 1, max 2, curr 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05458 DemandConstraint:7A/1Sat:N
        0.00001 LRM (min 1, max 2, curr 0) ]
      new defect 0.00000 -> 0.00001: [ A1 05689 DemandConstraint:24A/1Sat:N
        0.00001 LRM (min 4, max 4, curr 3) ]
    ]

  It should be fine, but it seems to wreck the demand constraints, why?
  It seems as though the swap is actually just an unassign.  How can
  that be?  It's probably because the limit resources constraints make
  all the tasks seem to have needless assignments.  And indeed when we
  turn off the unassign_extreme_unneeded flag we get this:

    [ "COI-Ikegami-2.1", 12 threads, 14 solves, 237.4 secs:
      0.00000 0.00000 0.00001 0.00001 0.00001 0.00001 0.00001 0.00002
      0.00002 0.00002 0.00004 0.00004 0.00004 0.00008
    ] 0.00000 is best cost (first diversifier 1)

  So this is the solution, but we need to analyse what to do about
  the unassign_extreme_unneeded flag, because we added it in for a
  good reason once before.  I've looked into this and written
  subsection "Needing and not needing assignment" of the mtasks
  section and implemented and audited everything.  Testing now:

    [ "COI-Ikegami-2.1", 12 threads, 12 solves, 166.1 secs:
      0.00000 0.00000 0.00001 0.00001 0.00001 0.00001 0.00002 0.00002
      0.00003 0.00003 0.00004 0.00006
    ] 0.00000 is best cost (first diversifier 1)

  And this is with the unassign_extreme_unneeded turned back on.
  The point is that we now have a better definition of what an
  unneeded assignment is, so it's working more precisely.  Time
  for a long test.  The results are generally as good as KHE24
  or better, although the Ikegamis and Sep are worse.  It would
  be good to look more closely at those.  MER still not terminating.

  Starting to look closely at COI-Ikegami-3.1.2 (best known soln
  has cost 3, KHE is getting 18).  As for COI-Ikegami-2.1, all
  defects are limit resources defects.  Here is the KHE solution:

    Constraint Id / Point        RG      Calculation         Inf.   Obj.
    -------------------------------------------------------------------
    DemandConstraint:2A/2Sat:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Wed:N   A_SS    1 * Linear(2 2Wed:N - 1)    1
    DemandConstraint:2A/3Fri:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/3Sat:N   B_SS    1 * Linear(1)               1
    DemandConstraint:3A/3Sun:N   B_SS    1 * Linear(1)               1
    DemandConstraint:2A/4Thu:N   A_SS    1 * Linear(2 4Thu:N - 1)    1
    DemandConstraint:16A/4Fri:D  B_SS_s  1 * Linear(2 - 1 4Fri:D)    1
    DemandConstraint:2A/4Sat:N   A_SS    1 * Linear(1)               1
    DemandConstraint:1A/4Mon:E   B_SS    1 * Linear(1)               1
    DemandConstraint:4A/4Mon:E   B_rq_s  1 * Linear(2 4Mon:E - 1)    1
    DemandConstraint:6A/4Mon:E   B_SS    1 * Linear(1)               1
    DemandConstraint:2A/4Tue:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/4Tue:N   B_SS    1 * Linear(1)               1
    DemandConstraint:22A/4Tue:N  all     1 * Linear(3 - 2 4Tue:N)    1
    DemandConstraint:16A/4Wed:D  B_SS_s  1 * Linear(2 - 1 4Wed:D)    1
    DemandConstraint:3A/5Fri:N   B_SS    1 * Linear(1)               1
    DemandConstraint:22A/5Fri:N  all     1 * Linear(3 - 2 5Fri:N)    1
    DemandConstraint:17A/5Sun:D  B_rq_s  1 * Linear(2 - 1 5Sun:D)    1
    -------------------------------------------------------------------
      Total (18 points)                                             18

  These are spread between A_SS (6), B_SS and B_SS_s (8), B_rq_s (2),
  and all (2).  The all defects require exactly 3 Night shifts.  And
  here is the best Misc solution:

    Constraint Id / Point        RG     Calculation         Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:22A/2Fri:N  all     1 * Linear(3 - 2 2Fri:N)    1
    DemandConstraint:6A/3Mon:D   B_SS    1 * Linear(1)               1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    -------------------------------------------------------------------
      Total (3 points)                                               3

  These look like the KHE defects, except that there are very few of them.

14 April 2026.  If I add a non-assignment cost derived from limit resources
  constraints, will that throw solvers such as the dynamic programming
  solver out of balance?  Not in khe_sr_dynamic_resource.c, because
  the non_asst_cost value is used only for forward checking, it does
  not get added to the solution cost.  And the other two uses for it,
  khe_sr_interval_grouping.c and khe_sr_dynamic_time_sweep.c, seem to
  be OK too.

  I've done the adjustment to non-assignment cost and audited it.
  It's ready to test.  The interval grouping timetable looks great,
  a whole whack of duration 2 groups.  Here are the first results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 238.3 secs: cost 0.00116 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 5.0 mins:
      0.00014 0.00015 0.00016 0.00016 0.00018 0.00020 0.00021 0.00021
      0.00023 0.00023 0.00032 0.00033 0.00041 0.00044 0.00044 0.00048
      0.00116 0.00118 0.00157 0.00267 0.00277 0.00614 0.00793 0.01787
    ] 0.00014 is best cost (first diversifier 1)

  Best of 1 is quite poor (there is one violation of a cost 100 limit
  active intervals constraint Constraint:28), but best of 12 is an
  improvement on what I had before: 14 instead of 18, and sure enough
  there are no violations of DemandConstraint:22A.  But this is still
  a long way behing the best known cost of 3.  Needs looking into

  "There is a final wrinkle..."  Starting with these words, I've
  added a few paragraphs to the mtask doc.  I've audited these
  paragraphs and implemented them.  It says that the extra
  non-assignment costs are not maintained when individual tasks
  enter and leave an mtask.

  Deleted the ps_no_diversify option.  Use gs_diversifier instead.

15 April 2026.  Wrote and tested KheIgSolverGetLimits.  All good.
  Still getting these results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 237.8 secs: cost 0.00116 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 5.0 mins:
      0.00014 0.00015 0.00016 0.00017 0.00018 0.00020 0.00021 0.00021
      0.00023 0.00023 0.00038 0.00040 0.00048 0.00048 0.00049 0.00057
      0.00116 0.00118 0.00131 0.00194 0.00375 0.00670 0.00793 0.02137
    ] 0.00014 is best cost (first diversifier 1)

  Here are the 3 defects from the best known solution again:

    Constraint Id / Point        RG     Calculation         Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:22A/2Fri:N  all     1 * Linear(3 - 2 2Fri:N)    1
    DemandConstraint:6A/3Mon:D   B_SS    1 * Linear(1)               1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    -------------------------------------------------------------------
      Total (3 points)                                               3

  Here are the 14 KHE defects:

    Constraint Id / Point        RG     Calculation         Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:3A/1Wed:N   B_SS    1 * Linear(1)               1
    DemandConstraint:22A/1Wed:N  all     1 * Linear(3 - 2 1Wed:N)    1
    DemandConstraint:2A/2Thu:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Mon:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/2Wed:N   B_SS    1 * Linear(1)               1
    DemandConstraint:22A/2Wed:N  all     1 * Linear(3 - 2 2Wed:N)    1
    DemandConstraint:12A/3Sun:D  B_SS_s  1 * Linear(2 - 1 3Sun:D)    1
    DemandConstraint:3A/3Mon:N   B_ss    1 * Linear(1)               1
    DemandConstraint:3A/3Tue:N   B_ss    1 * Linear(1)               1
    DemandConstraint:2A/4Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    DemandConstraint:32A/5Thu:D  all     1 * Linear(13 - 12 5Thu:D)  1
    DemandConstraint:2A/5Fri:N   A_SS    1 * Linear(1)               1
    -------------------------------------------------------------------
      Total (14 points)                                             14

  Of the 14 KHE defects, 11 are N and 3 are D; 5 are A and 6 are B.
  Running a single solve perversely gave cost 16 instead of 14, but
  anyway most of the defects are the same.

  Defects DemandConstraint:22A/1Wed:N and DemandConstraint:22A/2Wed:N
  were supposed to be eliminated by interval grouping, and indeed
  looking at the debug output from interval grouping they were
  eliminated.  Why they have crept back in again is a mystery,
  but it is clear that the grouping has been wrecked in the week
  between 1Wed:N and 2Wed:N.

  Let's take a close look at DemandConstraint:3A/3Mon:N.  It's typical
  of the defects here.  Its domain is B_SS, which contains resources
  B14, B15, B16, B17, and B18.  So of the 3 night shifts on 3Mon,
  exactly one must be filled by one of these five nurses.  It's
  noticeable that they are very busy nurses:  summed over all five,
  there is only one shift available, for A14.  Now B14 is unavailable
  that day, and B16 and B17 are preassigned to O shifts, so only B15
  and B18 are available.  This swap seems promising:

    B18 <--> B22 [3Mon, 3Tue, 3Wed, 4Thu]

  So it's time for a whynot.

16 April 2026.  Thinking about adding domain reduction to express
  limit resources constraints.  I could add it to task trees, but
  I've noticed that by default task trees do not install domains
  for soft prefer resources monitors.  I'm going to have to reverse
  that default, but the doc says that there are cases where this
  is harmful.  Of course, using the wisdom of the serpent, we
  are concerned here with limit resources constraints, not prefer
  resources constraints.

  KheTaskTreeMake has a soln_adjuster parameter, but at the
  place where it is called, the sa argument is NULL.  I
  guess its stuff is removed by WidenDomains, or whatever
  it's called.  So let's make a separate solver for this job.
  I've started documenting it, as a new subsection of the
  task trees section.

17 April 2026.  Working on task domain reduction using limit
  resources monitors.  I've documented it, as a new subsection
  of the task trees section.  Now I need to implement it.  I've
  set up a new solver source file (khe_sr_reduce_domains.c) and
  defined the main function (KheReduceTaskDomains), and I've
  implemented quite a lot of stuff and also called it from
  yourself and getting some good debug output.  Just
  KheReduceDomainsSolverSolve to do now.

18 April 2026.  Revised yesterday's code to ignore pointless
  monitors, which turned out to be surprisingly messy.  And
  finished off the implementation.  First results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 225.4 secs: cost 0.00120 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 5.0 mins:
      0.00017 0.00020 0.00021 0.00021 0.00021 0.00022 0.00023 0.00024
      0.00025 0.00025 0.00025 0.00026 0.00027 0.00027 0.00027 0.00032
      0.00034 0.00045 0.00058 0.00121 0.00122 0.00126 0.00136 0.00240
    ] 0.00017 is best cost (first diversifier 11)

  This is worse than the previous results:

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 5.0 mins:
      0.00014 0.00015 0.00016 0.00017 0.00018 0.00020 0.00021 0.00023
      0.00023 0.00027 0.00029 0.00044 0.00045 0.00050 0.00050 0.00055
      0.00116 0.00120 0.00141 0.00375 0.00495 0.00614 0.00892 0.00984
    ] 0.00014 is best cost (first diversifier 1)

  Let's try it for COI-Ikegami-2.1.  Without domain reduction:

    [ "COI-Ikegami-2.1", 12 threads, 17 solves, 230.3 secs:
      0.00000 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00002
      0.00002 0.00002 0.00003 0.00003 0.00003 0.00003 0.00003 0.00004
      0.00004
    ] 0.00000 is best cost (first diversifier 1)

  With domain reduction:

    [ "COI-Ikegami-2.1", 12 threads, 12 solves, 147.5 secs:
      0.00000 0.00000 0.00001 0.00001 0.00001 0.00001 0.00002 0.00002
      0.00003 0.00003 0.00005 0.00006
    ] 0.00000 is best cost (first diversifier 1)

  So domain reduction got there a lot faster.  But I'll carry on
  without it for the time being.

19 April 2026.  Took the day off to review PATAT papers.

20 April 2026.  Looking into the relatively high cost of the KHE
  solutions to COI-Ikegami-3.1.2.  Here are KHE's solutions:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 259.8 secs:
      0.00014 0.00015 0.00016 0.00017 0.00018 0.00020 0.00020 0.00021
      0.00021 0.00023 0.00116 0.00118
    ] 0.00014 is best cost (first diversifier 1)

  Here are the 3 defects from the best known solution again:

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:22A/2Fri:N  all     1 * Linear(3 - 2 2Fri:N)    1
    DemandConstraint:6A/3Mon:D   B_SS    1 * Linear(1)               1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    -------------------------------------------------------------------
      Total (3 points)                                               3

  Here are the 14 defects from KHE's best solution (diversifier 1):

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:3A/1Wed:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:22A/1Wed:N  all     1 * Linear(3 - 2 1Wed:N)    1
    DemandConstraint:2A/2Thu:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Mon:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/2Wed:N   B_SS    1 * Linear(1)               1
    DemandConstraint:22A/2Wed:N  all     1 * Linear(3 - 2 2Wed:N)    1
    DemandConstraint:12A/3Sun:D  B_SS_s  1 * Linear(2 - 1 3Sun:D)    1
  * DemandConstraint:3A/3Mon:N   B_ss    1 * Linear(1)               1
    DemandConstraint:3A/3Tue:N   B_ss    1 * Linear(1)               1
    DemandConstraint:2A/4Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    DemandConstraint:32A/5Thu:D  all     1 * Linear(13 - 12 5Thu:D)  1
    DemandConstraint:2A/5Fri:N   A_SS    1 * Linear(1)               1
    -------------------------------------------------------------------
      Total (14 points)                                             14

  These are the defects I'm getting today; they are also the defects I was
  getting before.

  Doing a whynot run of DemandConstraint:3A/3Mon:N.  Annoyingly, the
  whynot run gives a solution with cost 16, but luckilyu it still has
  DemandConstraint:3A/3Mon:N as a defect.  It's a limit resources
  monitor for event 3Mon:N, and its set of preferred resources has
  just 5 resources: B14, B15, B16, B17, B18.  One of those, B14,
  has a day off on 3Mon, and two more, B16 and B17, are preassigned
  to O tasks on 3Mon, so in effect the available resources are just
  B15 and B18.  Stlll, the best Misc solution manages to avoid this
  defect, by assigning B18 to 3Mon:N.  On the other hand it has an
  adjacent defect on 3Mon:D, so perhaps one or the other is unavoidable.

  What about a whynot run for DemandConstraint:3A/1Wed:N?  It's at
  the start of the cycle, it's not in the best Misc solution, and
  that solution has no nearby defects.  Domain is B_SS_s, that is,
  B14, B15, B16, B17, B18, and B25, but minus B18 because it has
  a day off request then.  The others look pretty good though.

  Having a look at what interval grouping is doing around there.
  There is one group of 2 ending on 1Wed:N and preassigned A02,
  which both KHE and Misc have, and two groups starting on
  1Wed, but curiously the KHE solution seems to have dumped
  one of these groups, at least, it's there in the interval
  grouping but not there in the final solution.

  Removed the final ejection chain call from KheGeneralSolve2026.
  If people want something like that, they can add it to the
  do-it-yourself solver.  Incredibly, there are now no assignments
  at all except a few preassignments.  What is going on?

21 April 2026.  Looking into time sweep and resource matching.  The
  doc says that KheTaskNonAsstAndAsstCost is used to decide whether
  to include a task or not.  This will be a problem when there are
  no assign resources monitors.  So we see what's happening now:  we
  need to use KheMTaskTaskPlus instead of KheTaskNonAsstAndAsstCost.

  I've altered resource matching to get its tasks from an mtask finder
  and use KheMTaskTaskPlus rather than KheTaskNonAsstAndAsstCost to
  find each task's non-assignment cost.  Time sweep seems to be back
  in business on COI-Ikegami-3.1.2.  First results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 257.0 secs: cost 0.00025 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 272.0 secs:
      0.00012 0.00013 0.00016 0.00019 0.00020 0.00021 0.00021 0.00024
      0.00025 0.00026 0.00029 0.00119
    ] 0.00012 is best cost (first diversifier 8)

  I was getting 14 before, so there is some improvement.  Back to the
  regular grinding down, I guess.

  Here is the defect list for KHE's cost 12 solution:

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:22A/3Sat:N  all     1 * Linear(4 3Sat:N - 3)    1
    DemandConstraint:2A/3Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:1A/3Sun:E   B_SS    1 * Linear(1)               1
    DemandConstraint:4A/3Sun:E   B_rq_s  1 * Linear(2 3Sun:E - 1)    1
    DemandConstraint:12A/3Sun:D  B_SS_s  1 * Linear(2 - 1 3Sun:D)    1
    DemandConstraint:6A/3Mon:D   B_SS_s  1 * Linear(1)               1
    DemandConstraint:22A/4Fri:N  all     1 * Linear(3 - 2 4Fri:N)    1
    DemandConstraint:2A/4Tue:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/4Tue:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:22A/4Tue:N  all     1 * Linear(3 - 2 4Tue:N)    1
    DemandConstraint:3A/4Wed:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/5Mon:N   B_SS_s  1 * Linear(1)               1
    -------------------------------------------------------------------
      Total (12 points)                                             12


  There are three broken N groupings, so I guess the next step is to
  look into what broke them.  What happens if we fix them?  Can we?

  I've run with the grouping in place and nothing else, got cost 15
  included three isolated "all" defects (22A).  How is that possible?
  I'll try running without each element and see what that gives.

  I think it might be the ungrouped tasks that are being assigned.

22 April 2026.  It's a story of two types of constraints.  One is the
  one driving the grouping:  a limit active intervals constraint which
  identifies a set of times, typically Night times.  The other type is
  the cover constraints for the events running at those times.  When
  we group, we want only the grouped tasks to be available for
  assignment.  So any tungrouped tasks running at the times in
  question need to be cut off from assignment, for example by
  fixing their non-assignments.  When their cover constraints
  are assign resource constraints, there is really no reason
  to assign these other tasks.  But when limit resources
  constraints are there, there is.

  Now fixing unused tasks, and most of the unassigned tasks are
  indeed coming in pairs.  But there is one triple:  2Wed, 3Thu,
  and 3Fri.  However, let's press on and see what a full solve
  gives us

    [ "COI-Ikegami-3.1.2", 1 solution, in 52.7 secs: cost 0.00062 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 274.8 secs:
      0.00015 0.00015 0.00016 0.00017 0.00017 0.00017 0.00019 0.00020
      0.00022 0.00023 0.00023 0.00023
    ] 0.00015 is best cost (first diversifier 2)

  This is not a bad result, and there are none of the defects that
  I have been trying to get rid of:

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:3A/1Wed:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/2Thu:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:27A/3Thu:D  GroupA  1 * Linear(4 - 3 3Thu:D)    1
    DemandConstraint:3A/3Sat:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:2A/3Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/3Sun:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:1A/3Sun:E   B_SS    1 * Linear(1)               1
    DemandConstraint:4A/3Sun:E   B_rq_s  1 * Linear(2 3Sun:E - 1)    1
    DemandConstraint:6A/3Mon:D   B_SS_s  1 * Linear(1)               1
    DemandConstraint:2A/4Sun:E   A_SS    1 * Linear(1)               1
    DemandConstraint:1A/4Mon:E   B_SS    1 * Linear(1)               1
    DemandConstraint:4A/4Mon:E   B_rq_s  1 * Linear(2 4Mon:E - 1)    1
    DemandConstraint:33A/4Tue:N  1_9     1 * Linear(2 4Tue:N - 1)    1
    DemandConstraint:16A/4Tue:D  B_ss_s  1 * Linear(2 - 1 4Tue:D)    1
    DemandConstraint:2A/5Sat:E   A_SS    1 * Linear(1)               1
    -------------------------------------------------------------------
      Total (15 points)                                             15

  I tried a 10 minute run, it ran for 8.3 minutes but no better.  Then
  I tried 24 solves at 5 minutes each, and got this:

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 9.3 mins:
      0.00013 0.00015 0.00015 0.00016 0.00017 0.00018 0.00018 0.00018
      0.00018 0.00019 0.00019 0.00019 0.00019 0.00019 0.00020 0.00021
      0.00021 0.00021 0.00022 0.00023 0.00023 0.00023 0.00025 0.00026
    ] 0.00013 is best cost (first diversifier 21)

  and again there were no 22A defects.  Back to a five-minute run,
  14 defects.  DemandConstraint:3A/2Thu:N looks like a good one
  to try.

23 April 2026.  Documented the fixing of admissible tasks which are
  not included.

28 April 2026.  I've been away for a few days.  Starting work again
  today.  Here is the standard best of 12 run:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 274.9 secs:
      0.00014 0.00015 0.00019 0.00019 0.00019 0.00020 0.00021 0.00022
      0.00022 0.00023 0.00024 0.00027
    ] 0.00014 is best cost (first diversifier 2)

  I was getting 15 before, but it's all the same really:

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:2A/2Sat:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/2Sun:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/3Thu:E   A_SS    1 * Linear(2 3Thu:E - 1)    1
    DemandConstraint:6A/3Fri:D   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/3Sat:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:1A/3Sat:E   B_SS    1 * Linear(1)               1
    DemandConstraint:4A/3Sat:E   B_rq_s  1 * Linear(2 3Sat:E - 1)    1
    DemandConstraint:6A/3Sat:D   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/3Sun:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:2A/4Sat:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/4Sun:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/4Mon:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:2A/4Tue:N   A_SS    1 * Linear(1)               1
    DemandConstraint:2A/5Fri:E   A_SS    1 * Linear(1)               1
    -------------------------------------------------------------------
      Total (15 points)                                             15

  Added rtr and best of 12 then had cost 18.  But the grouping seems
  to have gone wrong.  Needs looking into.

29 April 2026.  Working on yesterday's problem.  It seems that the
  missing tasks are not rated as needing assignment.  For example:

    KheIgSolverAddAdmissiblePrimaryMTasks considering:
    [ MTask 2Sun SkillGroup-B_SS_s asst_count 0
      n0.00000 a0.00000 nfalse 2Sun:N.1
    ]

  This task is not considered to need assignment, despite the
  domain reduction showing that only this task can satisfy the
  demand for SkillGroup-B_SS_s.

  Trying grouping first, and only then reducing domains:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 241.0 secs:
      0.00016 0.00016 0.00016 0.00016 0.00016 0.00017 0.00018 0.00018
      0.00019 0.00021 0.00024 0.00128
    ] 0.00016 is best cost (first diversifier 3)

  But now I think of it, the overlapping nature of the groups
  probably prevents domain reduction for night shifts.  Yes;
  I've just checked, and there is no domain reduction for
  Night shifts when it runs after grouping.  For the record,
  here is what we are getting with no domain reduction:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 279.7 secs:
      0.00017 0.00017 0.00018 0.00018 0.00019 0.00020 0.00020 0.00022
      0.00022 0.00023 0.00024 0.00024
    ] 0.00017 is best cost (first diversifier 8)

  That's strange, I was getting 12 before (21 April).  What are we
  aiming for here?

  * Interval grouping uses mtask non-assignment and assignment costs
    to decide whether to include a task or not.  (But we could switch
    that to assignment_not_needed == false.)  This includes the extra
    cost from limit resources monitors.

  * Other code uses restricted domains to run faster.

  What is wrong with running rtr after rig?  Once again it might
  spoil the choice of tasks during rts.  But also it does not
  work very effectively after rig.  The grouping puts it off.
  
  Can we include varying domains in an mtask?  Everything else
  as before, but allow varying domains?  Assign a resource to
  the first task that accepts it?  We lose the symmetry.

  Can we somehow preserve the non-assignment cost?  A more
  sophisticated calculation of the wrinkle?  Group together
  mtasks that would be one mtask except for the domains, and
  then if a monitor monitors only the tasks of the group,
  can we do something?  We need a priority system, assigning
  the smaller domain mtasks before the larger domain mtasks.

  I've read through the resource matching documentation.  It
  did not shed a lot of light.  But I'm beginning to think that
  I need a larger, more comprehensive theory of task equivalence
  than mtasks currently supply.  This would encompass the
  "preferences" used in the implementation of resource
  matching, and the way that mtasks get split up into
  varying domains during task domain reduction.

30 April 2026.  Today's job is to get a grip on the relationship
  between mtasks, task domain reduction caused by limit resources
  monitors, and interval grouping.

  Without task domain reduction, the tasks of one event are
  syummetrical and all go into the same mtask, which means
  that the first few can have their non-assignment costs
  increased.  After task domain reduction, the tasks of one
  event are not symmetrical, they go into different mtasks,
  and there is nothing to say which mtask (in effect, which
  domain) has priority, so no tasks can have their non-assignment
  costs increased.

  Limit resources monitors for 2Wed:N:

    Id			      Min     Max	RG
    -------------------------------------------------------------
    DemandConstraint:2A		1	1	SkillGroup-A_SS
    DemandConstraint:3A		1	1	SkillGroup-B_SS_s
    DemandConstraint:7A		1	2	Skill-GroupB
    DemandConstraint:8A		1	2	Skill-GroupA
    DemandConstraint:22A	3	3	RG:All
    DemandConstraint:33A	0	1	SkillGroup-1_9
    DemandConstraint:34A	0	1	SkillGroup-B_SS
    DemandConstraint:36A	0	2	SkillGroup-B_rq_s
    -------------------------------------------------------------

	GroupA	A_SS	GroupB	B_SS	B_SS_s	B_rq_s	1_9
    ---------------------------------------------------------
    A01	*	*					*
    A02	*	*
    A03	*	*
    A04	*	*
    A05	*	*
    A06	*	*
    A07	*
    A08	*
    A09	*						*
    A10	*
    A11	*
    A12	*
    A13	*
    B14			*	*	*
    B15			*	*	*
    B16			*	*	*
    B17			*	*	*
    B18			*	*	*
    B19			*			*
    B20			*			*
    B21			*			*
    B22			*			*
    B23			*			*
    B24			*			*
    B25			*		*	*
    ---------------------------------------------------------
        13     6       12      5        6       7       2

  There is quite a lot to sort through here.  For one thing,
  we have focussed on min limits, but the max limits also
  constrain domains, for example a max limit of 2 implies that
  there is one task that should *not* be assigned a resource
  from the given resource group.

  Sort the constraints so that the largest resource groups come first:

    Id			      Min     Max	RG
    -------------------------------------------------------------
    DemandConstraint:22A	3	3	RG:All
    DemandConstraint:8A		1	2	Skill-GroupA
    DemandConstraint:7A		1	2	Skill-GroupB
    DemandConstraint:2A		1	1	SkillGroup-A_SS
    DemandConstraint:36A	0	2	SkillGroup-B_rq_s
    DemandConstraint:3A		1	1	SkillGroup-B_SS_s
    DemandConstraint:34A	0	1	SkillGroup-B_SS
    DemandConstraint:33A	0	1	SkillGroup-1_9
    -------------------------------------------------------------

  After the first constraint we have exactly 3 tasks:

    Task1	RG:All
    Task2	RG:All
    Task3	RG:All

  Now we process minimum limits.  After DemandConstraint:8A we
  have one Skill-GroupA task:

    Task1	RG:All ^ Skill-GroupA
    Task2	RG:All
    Task3	RG:All

  After DemandConstraint:7A we have one Skill-GroupB task:

    Task1	RG:All ^ Skill-GroupA
    Task2	RG:All ^ Skill-GroupB
    Task3	RG:All

  After DemandConstraint:2A we have one SkillGroup-A_SS task,
  This overtakes the Skill-GroupA task, so:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB
    Task3	RG:All

  After DemandConstraint:3A we have one SkillGroup-B_SS_s task.
  This overtakes the Skill-GroupB task, so:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB ^ SkillGroup-B_SS_s
    Task3	RG:All

  The other constraints have 0 min limit, which changes nothing.
  Now for maximum limits.  After DemandConstraint:8A we need
  at least one non-Skill-GroupA task, which we already have.
  After DemandConstraint:7A we need at least one non-Skill-GroupB
  task, which we already have.  After DemandConstraint:2A we need
  at least two non-SkillGroup-A_SS tasks.  We can't do this
  to Task1, because that would give it an empty domain.  We
  already have it for Task2, leaving us one task short.  So:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB ^ SkillGroup-B_SS_s
    Task3	RG:All ^ not SkillGroup-A_SS

  DemandConstraint:36A requires at least one non-SkillGroup-B_rq_s
  task, which we already have (Task1).  DemandConstraint:3A requires
  at least two non-SkillGroup-B_SS_s task.  Task1 is already this,
  and Task2 can't be this (it would have an empty domain).  So:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB ^ SkillGroup-B_SS_s
    Task3	RG:All ^ not SkillGroup-A_SS ^ not SkillGroup-B_SS_s

  DemandConstraint:34A requires two non-SkillGroup-B_SS tasks.
  Task1 is one, Task2 can't be the second, so Task3 it is:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB ^ SkillGroup-B_SS_s
    Task3	RG:All ^ not SkillGroup-A_SS ^ not SkillGroup-B_SS_s
                  ^ not SkillGroup-B_SS

  Finally, DemandConstraint:33A requires two non-SkillGroup-1_9
  tasks.  Task2 is one of these, but we can't really choose
  between Task1 and Task3 for the other, although Task3 looks
  marginally better:

    Task1	RG:All ^ Skill-GroupA ^ SkillGroup-A_SS
    Task2	RG:All ^ Skill-GroupB ^ SkillGroup-B_SS_s
    Task3	RG:All ^ not SkillGroup-A_SS ^ not SkillGroup-B_SS_s
                  ^ not SkillGroup-B_SS ^ not SkillGroup-1_9

  since only one resource (A09) is newly ruled out by this.  We
  can simplify this result to

    Task1	SkillGroup-A_SS
    Task2	SkillGroup-B_SS_s
    Task3	not SkillGroup-A_SS ^ not SkillGroup-B_SS_s
                  ^ not SkillGroup-1_9

  What we have now is doing the right thing for Task1 and Task2,
  but leaving Task3 untouched.  We can live with that, or we could
  press on and make it happen.  The advantage of pressing on is
  that it could be used to prove that Task1 and Task2 must
  be assigned, because they are the only tasks with the
  domains required by their monitors.

1 May 2026.  Do the full task domain thing.  Then when looking
  for extra non-assignment costs when building mtasks, find
  each monitor of the tasks, find which tasks in other mtasks
  have domains which allow them to be assigned suitable resources,
  and subtract the total duration of those other tasks from the min
  limit.  If there is anything left over, add extra non-assignment
  costs to the tasks of this mtask.

  I gave some thought to folding KHE_TASK_GROUP_DOMAIN_FINDER, or something
  very like it, into the platform.  This way, this code from khe_task.c:

    static KHE_RESOURCE_GROUP KheTaskDomainWhenTaskBoundAdded(KHE_TASK task,
      KHE_TASK_BOUND tb)
    {
      ...
      KheSolnResourceGroupBegin(task->soln, KheTaskResourceType(task));
      KheSolnResourceGroupUnion(task->soln, task->domain);
      KheSolnResourceGroupIntersect(task->soln, KheTaskBoundResourceGroup(tb));
      res = KheSolnResourceGroupEnd(task->soln);
    }

  can be replaced by something more efficient.  Although there is
  another option, which is to make this code itself more efficient
  by adapting the caching idea from KHE_TASK_GROUP_DOMAIN_FINDER.
  We could store the KHE_TASK_GROUP_DOMAIN object beside the domain,
  and replace the code above by

    task->tg_domain = KheTGDomainIntersect(task->tg_domain,
      KheTaskBoundResourceGroup(tb));
    res = KheTGDomainResourceGroup(task->tg_domain);

  However this seems like a lot of work for not much gain.  After all,
  KheSolnResourceGroupBegin etc. have some opimizations now.

2 May 2026.  Working on a revised task domain reduction algorithm which
  is unashamedly heuristic but capable of reaching the endpoint of the
  2 April example.  I've completed the documentation for it, in the
  section at the end of task trees, and advertised it as being what
  function KheReduceTaskDomains implements.  I've audited this
  documentation but not implemented it yet.

3 May 2026.  Implementing the revised task domain reduction algorithm.
  Spent the whole day on a major rewrite of the documentation.  It
  has been audited; it's ready to implement.

4 May 2026.  Implementing the revised task domain reduction algorithm.
  I've done all the boilerplate, getting the monitors and tasks in
  order.  All done and audited and ready to test.  OK, now I have
  some debug output that looks pretty good and needs a careful look.

5 May 2026.  Looking at

    [ KheRdMonitorSolve(rdm, rds)
      initial monitor:
      [ KheRdMonitor(DemandConstraint:7A/2Tue:N, wt 0.00001, rg 13,
        max_limit 2, tasks 4)
	Skill-GroupA{A01, A02, A03, A04, A05, A06, A07, A08, A09, A10
	  A11, A12, A13}
	<= 2Tue:N.0(sig 12, dom RG:All)
	<= 2Tue:N.1(sig 12, dom RG:All)
	 > 2Tue:N.2(sig 12, dom Skill-GroupB)
	 > 2Tue:N.3(sig 0, dom {})
      ]
      reducing 2Tue:N.2 domain by Skill-GroupA
      reducing 2Tue:N.3 domain by Skill-GroupA
      final monitor:
      [ KheRdMonitor(DemandConstraint:7A/2Tue:N, wt 0.00001, rg 13,
        max_limit 2, tasks 4)
	Skill-GroupA{A01, A02, A03, A04, A05, A06, A07, A08, A09, A10,
	  A11, A12, A13}
	<= 2Tue:N.0(sig 12, dom RG:All)
	<= 2Tue:N.1(sig 12, dom RG:All)
	 > 2Tue:N.2(sig 12, dom {})
	 > 2Tue:N.3(sig 0, dom {})
      ]
    ] KheRdMonitorSolve returning true

  The resource group is correct because Skill-GroupA is the exact
  complement of Skill-GroupB, the domain of DemandConstraint:7A.

  Something is wrong with the way the signature is calculated.
  Instead of tasks whose reduction is as small as possible, what
  about tasks whose final value is as large as possible?

6 May 2026.  Audited yesterday's documentation proposing a more
  refined cost function for sorting tasks, implemented it, and
  tested it.  I got some pretty good debug output.  First results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 222.5 secs: cost 0.00023 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 259.4 secs:
      0.00018 0.00020 0.00021 0.00022 0.00023 0.00025 0.00027 0.00029
      0.00031 0.00031 0.00031 0.00124
    ] 0.00018 is best cost (first diversifier 2)

  So rather inferior results, but before abandoning task domain
  reduction we should look into what is actually going on.  Also
  we have to do job (2) on the to-do list below.

7 May 2026.  Working on the non_asst_cost value returned by Plus.
  All documented and implemented; debug output suggests that it
  is working as expected.  First results:

    [ "COI-Ikegami-3.1.2", 1 solution, in 260.0 secs: cost 0.00026 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 294.5 secs:
      0.00015 0.00018 0.00021 0.00022 0.00024 0.00024 0.00025 0.00026
      0.00029 0.00029 0.00031 0.00033
    ] 0.00015 is best cost (first diversifier 2)

  This is an OK result but not really an improvement.  Here is a
  run without rtr:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 285.1 secs:
      0.00014 0.00015 0.00016 0.00017 0.00018 0.00019 0.00020 0.00020
      0.00022 0.00023 0.00024 0.00024
    ] 0.00014 is best cost (first diversifier 9)

  Looked at overall this is better; but now we need to work out
  in detail what is going on.  On each pair of days, interval
  grouping is grouping N.0 with N.0, N.1 with N.1, and N.2 with
  N.2, which is probably the right thing to do.  So far so good.

  What are the actual domains of N.0, N.1, and N.2 tasks?

    N.0:  {A07, A08, A10, A11, A12, A13, B19, B20, B21, B22, B23, B24}
    N.1:  {A02, A03, A04, A05, A06, A07, A08, A10, A11, A12, A13}
    N.2:  Skill-GroupB
    N.3:  {}

  The problem here is that A01 and A09 don't get a go at all,
  whereas what the constraint actually says is max 1.  So what
  went wrong?  The answer is in op3 somewhere.  I think the
  task sorting is still wrong.  There should not have been
  any reduction due to DemandConstraint:33A, or one at most,
  but there are two.

  Trying out a new cost function, the ordered pair (c1, c2):

    [ "COI-Ikegami-3.1.2", 1 solution, in 213.2 secs: cost 0.00016 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 252.8 secs:
      0.00013 0.00014 0.00015 0.00015 0.00017 0.00017 0.00018 0.00018
      0.00020 0.00022 0.00022 0.00120
    ] 0.00013 is best cost (first diversifier 7)

  My best ever result was 12, so this is not bad.  But let's see
  what a bigger, longer run gives us, just for fun.  Here are 24
  solves, each running with a 10 minute time limit:

    [ "COI-Ikegami-3.1.2", 12 threads, 24 solves, 15.6 mins:
      0.00010 0.00011 0.00011 0.00012 0.00012 0.00013 0.00013 0.00013
      0.00013 0.00014 0.00014 0.00014 0.00015 0.00015 0.00015 0.00015
      0.00016 0.00017 0.00018 0.00019 0.00019 0.00022 0.00022 0.00118
    ] 0.00010 is best cost (first diversifier 23)

  So that's a new best for KHE on COI-Ikegami-3.1.2.  My previous
  best was 12 on 21 April 2026 (best of 12 5-minute runs), although
  that may have been an outlier since I have not been able to
  replicate it with rtr off.  Going back now to a regular run:

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 257.0 secs:
      0.00013 0.00014 0.00015 0.00015 0.00017 0.00017 0.00018 0.00018
      0.00020 0.00022 0.00116 0.00118
    ] 0.00013 is best cost (first diversifier 7)

  That finishes task domain reduction and the adjustments to Plus.
  This work started around 21 April, which is over two weeks ago.
  Anyway, back to grinding down COI-Ikegami-3.1.2.  Let's look at
  some defects and see what a whynot tells us.  Here are the defects
  from the cost 13 diversifier 7 solution:

    Constraint Id / Point        RG      Calculation        Inf.    Obj.
    -------------------------------------------------------------------
    DemandConstraint:2A/2Thu:N   A_SS    1 * Linear(1)               1
    DemandConstraint:22A/2Wed:N  all     1 * Linear(3 - 2 2Wed:N)    1
    DemandConstraint:2A/3Thu:N   A_SS    1 * Linear(1)               1
    DemandConstraint:22A/3Thu:N  all     1 * Linear(3 - 2 3Thu:N)    1
    DemandConstraint:2A/3Fri:N   A_SS    1 * Linear(1)               1
    DemandConstraint:3A/3Mon:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:3A/3Tue:N   B_SS_s  1 * Linear(1)               1
    DemandConstraint:12A/4Sun:D  B_SS_s  1 * Linear(2 - 1 4Sun:D)    1
    DemandConstraint:16A/4Tue:D  B_SS_s  1 * Linear(2 - 1 4Tue:D)    1
    DemandConstraint:32A/5Thu:D  all     1 * Linear(13 - 12 5Thu:D)  1
    DemandConstraint:11A/5Sat:D  A_SS    1 * Linear(2 - 1 5Sat:D)    1
    DemandConstraint:16A/5Mon:D  B_SS_s  1 * Linear(2 - 1 5Mon:D)    1
    DemandConstraint:16A/5Tue:D  B_SS_s  1 * Linear(2 - 1 5Tue:D)    1
    -------------------------------------------------------------------
      Total (13 points)                                             13

  Choosing DemandConstraint:3A/3Tue:N more or less at random for a
  whynot run.  It requests exactly one B_SS_s, seems to be one short.
  What is actually assigned then is {A05, B22, and B24}.  None of
  those are B_SS_s nurses (senior B nurses plus B25; altogether
  these are B14, B15, B16, B17, B18, and B25).  B14, B15, and B25
  are free that day, although B15 and B25 have no available workload.

8 May 2026.  Grinding down COI-Ikegami-3.1.2.  The whynot shows that
  none of the ejection chain repairs succeeded enough to justify a
  recursive call.  In order to get anywhere here, we are going to
  need some idea of how a repair could be made to work.

  What about a swap B14 <--> B22 at 3Tue and 3Wed?

    [ KheResourceSwapRepair+(B22, B14, 3Tue-3Wed, {9-10: 3Tue:N.0, 3Wed:N.0},
        {10-9: }, true)
      new defect 0.00000 -> 0.00100: [ A1 07327 Constraint:24/B14 ...
      new defect 0.00000 -> 0.00100: [ A1 03346 Constraint:7/B14/80 ...
      new defect 0.00000 -> 0.00001: [ A1 07643 DemandConstraint:3A/3Wed:N ...
      new defect 0.00000 -> 0.00001: [ A1 08182 DemandConstraint:34A/3Wed:N ...
      ...
    ]

  Constraint:24 is "Min 6 days between N shifts".
  Constraint:7 is unwanted pattern, N followed by D or similar.
  DemandConstraint:3A is at most one B_SS_s on 3Wed:N.
  DemandConstraint:34A is at most one B_SS on 3Wed:N.

  There seems to be no way forward here.  Unless it's to install
  a matching.  But according to the matching doc, demand nodes
  are only installed for tasks with assign resource monitors of
  weight at least W (usually set to hard cost 1), which is two
  steps removed from what we have in the Ikegami instances.
  We would still want to not install demand nodes for tasks
  with empty domains, but for the others we would need demand
  nodes.  So there is quite a lot of analysis and adjustment
  to do here before installing the matching.

  Actually MER is terminating now:

    [ "COI-MER", 1 solution, in 5.4 mins: cost 0.42605 ]

  This is not a great score, but it's better than KHE24's
  56048, which was the bests of 24.  Best of 12 did not
  terminate after 10 minutes, so there is still something
  going wrong.  Have to look into what.

  After 5 minutes, without rdv:

    [ "COI-MER", 12 threads, 12 solves, 5.0 mins:
      0.31690 0.33697 0.34552 0.35424 0.35540 0.36039 0.36618 0.37191
      0.40013 0.43892 0.49772 0.52487
    ] 0.31690 is best cost (first diversifier 4)

  So it seems that rdv is what is preventing MER from finishing.
  So I've decided to do a full run without rdv.

  When doing time_limited, if I get a lot of solutions and there
  is no improvement after (say) 50 solutions, I should stop.  This
  is aimed at COI-Musa, which is currently generating 1311 solutions,
  all with cost 175.

  Millions of these:

    parallel solve of COI-CHILD: starting solve 2179
    one solve of COI-CHILD (with diversifer 2167) aborted (out of memory)

  What's going on?  I've made a start on it by making sure that
  when one solve runs out of memory, no new solves can start.

  I've documented the 50 since new best and the out of memory things.

  Currently trying to solve all of COI without rtr, to see whether
  that fixes the memory problems.  Yep, it ran right through.
  Amazingly, MER came out at 11144, which is rel = 1.57.

9 May 2026.  Working on yesterday's rtr memory leak.  I've changed
  KHE_TASK_GROUP_DOMAIN_FINDER to KHE_TASK_DOMAIN_FINDER (its no
  longer used only for task grouping).  And I've changed rtr to use
  KHE_TASK_DOMAIN_FINDER.  It should use a lot less memory now.

  So it does, but it is still running out of memory, starting
  at COI-ERMGH.  I need to ponder what parallel is doing; are
  there opportunities for it to return more memory earlier?

  However, not all is bad.  I'm getting 166 for CHILD, compared
  with KHE24's 2824 and (in 60 minutes) 261.  So keep pressing on.
  Still running out of memory at COI-ERMGH, and failing altogether
  when I get to MER.

  Did another run without rtr, sure enough it went right through
  with no memory problems.  So rtr has to be the problem.

  I did a last audit of khe_sr_reduce_domains.c, to make sure there
  were no memory issues there.

  Tooling up for removing task bounds.  It will be a biggish job,
  but it will save time and memory and it will be worth it.  I've
  adjusted the documentation.

10 May 2026.  Removed task bounds today.  Have clean compile,
  testing now.  First results (including rtr):

    [ "COI-Ikegami-3.1.2", 1 solution, in 220.2 secs: cost 0.00016 ]

    [ "COI-Ikegami-3.1.2", 12 threads, 12 solves, 246.0 secs:
      0.00014 0.00014 0.00015 0.00017 0.00018 0.00019 0.00019 0.00020
      0.00022 0.00022 0.00023 0.00119
    ] 0.00014 is best cost (first diversifier 6)

  This is an OK solution.  Time for a long run, with rtr.  Still
  running out of memory!  Not as quickly, perhaps, but it's happening.

11 May 2026.  Need to look into the rtr memory problems in more
  detail.  I'm going through the whole supply chain lookimg for
  possible leaks, but also for opportunities to save memory.
  Found a leak, I was Initing the solution set in khe_soln.c
  when I should have been Clearing it.  So it was always there,
  but it became important when reduce_domains started to make
  a lot of soln resource groups.  But I'm still running out,
  during COI-ERMGH.

  Did a bit of tidying up in khe_sm_parallel_solve.c to make the
  state of an instance solve clearer.  This was prompted by a case
  where the solver declared that no new solves would start, but
  they did.

  At the first out of memory, we have this:

    arena set for thread #7 and inst COI-CHILD end of inst:
    [ Arena Set 0x5b11845639d8:
      free arenas              29
      busy arenas               1
      jmp_bufps                 0
      busy words        309057664
      max busy words    309057664
      free_chunk_list[0] has length 0
      free_chunk_list[1] has length 0
      free_chunk_list[2] has length 0
      free_chunk_list[3] has length 0
      free_chunk_list[4] has length 15
      free_chunk_list[5] has length 11
      free_chunk_list[6] has length 10
      free_chunk_list[7] has length 10
      free_chunk_list[8] has length 7
      free_chunk_list[9] has length 7
      free_chunk_list[10] has length 6
      free_chunk_list[11] has length 7
      free_chunk_list[12] has length 6
      free_chunk_list[13] has length 5
      free_chunk_list[14] has length 4
      free_chunk_list[15] has length 3
      free_chunk_list[16] has length 2
      free_chunk_list[17] has length 2
      free_chunk_list[18] has length 1
      free_chunk_list[19] has length 1
      free_chunk_list[20] has length 1
      free_chunk_list[21] has length 1
      free_chunk_list[22] has length 0
      free_chunk_list[23] has length 0
      free_chunk_list[24] has length 0
      free_chunk_list[25] has length 0
      free_chunk_list[26] has length 0
      free_chunk_list[27] has length 0
      free_chunk_list[28] has length 0
      free_chunk_list[29] has length 0
      free_chunk_list[30] has length 0
      free_chunk_list[31] has length 0
      free_chunk_list[32] has length 0
      free_chunk_list[33] has length 0
      free_chunk_list[34] has length 0
      free_chunk_list[35] has length 0
      free_chunk_list[36] has length 0
      free_chunk_list[37] has length 0
      free_chunk_list[38] has length 0
      free_chunk_list[39] has length 0
    ]

  And now if we run without rtr, towards the end we get stuff like this:

    [ Arena Set 0x5c450461f558:
      free arenas              17
      busy arenas              11
      jmp_bufps                 0
      busy words        279601696
      max busy words    307752662
      free_chunk_list[0] has length 0
      free_chunk_list[1] has length 0
      free_chunk_list[2] has length 0
      free_chunk_list[3] has length 0
      free_chunk_list[4] has length 3
      free_chunk_list[5] has length 8
      free_chunk_list[6] has length 6
      free_chunk_list[7] has length 1
      free_chunk_list[8] has length 5
      free_chunk_list[9] has length 5
      free_chunk_list[10] has length 5
      free_chunk_list[11] has length 7
      free_chunk_list[12] has length 8
      free_chunk_list[13] has length 8
      free_chunk_list[14] has length 4
      free_chunk_list[15] has length 1
      free_chunk_list[16] has length 1
      free_chunk_list[17] has length 1
      free_chunk_list[18] has length 0
      free_chunk_list[19] has length 5
      free_chunk_list[20] has length 5
      free_chunk_list[21] has length 0
      free_chunk_list[22] has length 0
      free_chunk_list[23] has length 0
      free_chunk_list[24] has length 0
      free_chunk_list[25] has length 0
      free_chunk_list[26] has length 0
      free_chunk_list[27] has length 0
      free_chunk_list[28] has length 0
      free_chunk_list[29] has length 0
      free_chunk_list[30] has length 0
      free_chunk_list[31] has length 0
      free_chunk_list[32] has length 0
      free_chunk_list[33] has length 0
      free_chunk_list[34] has length 0
      free_chunk_list[35] has length 0
      free_chunk_list[36] has length 0
      free_chunk_list[37] has length 0
      free_chunk_list[38] has length 0
      free_chunk_list[39] has length 0
    ]

  So it looks as though removing rtr sneaks under the limit but
  does not reduce memory usage in a significant way.  Here's
  another one from right at the end:

    busy words        292987920
    max busy words    307752662

  Evidently it's a near miss even without rtr.

  How much memory is buried in the free lists?  Apparently
  each chunk at index i has roughly 2^i words, so that
  would be (in the example above)

    5 * 2^20 + 5 * 2^19 + (smaller terms)

  which is roughly 7500000, so:

    in free chunks      7500000
    busy words        279601696
    max busy words    307752662

  In other words, cleaning out the chunks won't solve our
  problems; only about one quarter of the memory is in there.
  I've looked at several arena sets near the end, they all
  tell the same story.

  We aborted when asking for quite a small amount of memory,
  but that was at a moment when *all* of the free chunks
  were busy.  That is, they were all used up, and busy_words
  had reached max_busy_words, and that was that.  The abort
  is inside KheSolnMake, just putting a solution together.

  Now trying a run where the maximum chunk index is limited
  to 20 (so about 2^20 words of memory), except where an
  individual request for memory asks for more.  That still
  ran out of memory, so I'm trying 15.  still no good, in
  fact worse.  I need to think about something else, e.g.
  resizable blocks.  Meanwhile, I'm going back to 20.

12 May 2026.  I've enhanced the arena set debug print to
  include a debug print of the busy arenas, and I've enhanced
  the arena debug print to include a print of the number of
  free words held on free resizable block lists.  So I should
  get a good idea from that of how much space is being wasted
  on unused resizable blocks.

  I think there is a logic problem in the use of arenas.  Look
  at arena 0x5bc43f580b50 in thread #4.  It just gets larger and
  larger, what can it be holding?  Incredibly, the answer is
  looking like:  lots of copies of options.

  OK, I got through the whole archive in 84 minutes, no out
  of memory issues.  A typical thread memory usage is

    busy words        127205136
    max busy words    296836096

  so we have used up less than half the available memory.
  This was a run with rtr included but no rdv.  The result
  summary is

    Instances (27)     Misc                         KHE26
                       Cost            Rel.         Cost            Rel.
    --------------------------------------------------------------------
    COI-Ozkarahan      0.00000         1.00         0.00000         1.00
    COI-Musa           0.00175         1.00         0.00175         1.00
    COI-Millar-2.1     0.00000         1.00         0.00000         1.00
    COI-Millar-2.1.1   0.00000         1.00         0.00100         inf.
    COI-LLR            0.00301         1.00         0.00301         1.00
    COI-Azaiez         0.00000         1.00         0.00000         1.00
    COI-GPost          0.00005         1.00         0.00008         1.60
    COI-GPost-B        0.00003         1.00         0.00005         1.67
    COI-QMC-1          0.00013         1.00         0.00018         1.38
    COI-QMC-2          0.00029         1.00         0.00029         1.00
    COI-WHPP           0.00005         1.00         0.00005         1.00
    COI-BCV-3.46.2     0.00894         1.00         0.00895         1.00
    COI-BCV-4.13.1     0.00010         1.00         0.00010         1.00
    COI-SINTEF         0.00000         1.00         0.00000         1.00
    COI-ORTEC01        0.00270         1.00         0.00290         1.07
    COI-ORTEC02        0.00270         1.00         0.00300         1.11
    COI-ERMGH          0.00779         1.00         0.01061         1.36
    COI-CHILD          0.00149         1.00         0.00167         1.12
    COI-ERRVH          0.02001         1.00         0.03508         1.75
    COI-HED01          0.00136         1.00         0.00136         1.00
    COI-Valouxis-1     0.00020         1.00         0.00060         3.00
    COI-Ikegami-2.1    0.00000         1.00         0.00002         inf.
    COI-Ikegami-3.1    0.00002         1.00         0.00011         5.50
    COI-Ikegami-3.1.1  0.00003         1.00         0.00012         4.00
    COI-Ikegami-3.1.2  0.00003         1.00         0.00012         4.00
    COI-BCDT-Sep       0.00100         1.00         0.00260         2.60
    COI-MER            0.07081         1.00         0.34220         4.83
    --------------------------------------------------------------------
       Average         0.00453         1.00         0.01540         inf

  And here is another run without rtr:

    Instances (27)     Misc                         KHE26
                       Cost            Rel.         Cost            Rel.
    --------------------------------------------------------------------
    COI-Ozkarahan      0.00000         1.00         0.00000         1.00
    COI-Musa           0.00175         1.00         0.00175         1.00
    COI-Millar-2.1     0.00000         1.00         0.00000         1.00
    COI-Millar-2.1.1   0.00000         1.00         0.00100         inf.
    COI-LLR            0.00301         1.00         0.00301         1.00
    COI-Azaiez         0.00000         1.00         0.00000         1.00
    COI-GPost          0.00005         1.00         0.00008         1.60
    COI-GPost-B        0.00003         1.00         0.00005         1.67
    COI-QMC-1          0.00013         1.00         0.00018         1.38
    COI-QMC-2          0.00029         1.00         0.00029         1.00
    COI-WHPP           0.00005         1.00         0.00005         1.00
    COI-BCV-3.46.2     0.00894         1.00         0.00895         1.00
    COI-BCV-4.13.1     0.00010         1.00         0.00010         1.00
    COI-SINTEF         0.00000         1.00         0.00000         1.00
    COI-ORTEC01        0.00270         1.00         0.00290         1.07
    COI-ORTEC02        0.00270         1.00         0.00296         1.10
    COI-ERMGH          0.00779         1.00         0.01103         1.42
    COI-CHILD          0.00149         1.00         0.00161         1.08
    COI-ERRVH          0.02001         1.00         0.02637         1.32
    COI-HED01          0.00136         1.00         0.00136         1.00
    COI-Valouxis-1     0.00020         1.00         0.00060         3.00
    COI-Ikegami-2.1    0.00000         1.00         0.00000         1.00
    COI-Ikegami-3.1    0.00002         1.00         0.00012         6.00
    COI-Ikegami-3.1.1  0.00003         1.00         0.00016         5.33
    COI-Ikegami-3.1.2  0.00003         1.00         0.00017         5.67
    COI-BCDT-Sep       0.00100         1.00         0.00260         2.60
    COI-MER            0.07081         1.00         0.11167         1.58
    --------------------------------------------------------------------
        Average        0.00453         1.00         0.00655         inf

  On balance rtr seems better.  It has certainly done wonders for MER.

13 May 2026.  Sorting out the eval_table.c problems today.
  Did some work to remove old function EvalTableBuild from
  summary.c.  It's done and should not affect HTML prints,
  because the only call on EvalTableBuild was in one Latex print.

  Here is a run with both rtr and rdv:

    Instances (27)     Misc                         KHE26
                       Cost            Rel.         Cost            Rel.
    --------------------------------------------------------------------
    COI-Ozkarahan      0.00000         1.00         0.00000         1.00
    COI-Musa           0.00175         1.00         0.00175         1.00
    COI-Millar-2.1     0.00000         1.00         0.00000         1.00
    COI-Millar-2.1.1   0.00000         1.00         0.00100         inf.
    COI-LLR            0.00301         1.00         0.00301         1.00
    COI-Azaiez         0.00000         1.00         0.00000         1.00
    COI-GPost          0.00005         1.00         0.00008         1.60
    COI-GPost-B        0.00003         1.00         0.00005         1.67
    COI-QMC-1          0.00013         1.00         0.00018         1.38
    COI-QMC-2          0.00029         1.00         0.00029         1.00
    COI-WHPP           0.00005         1.00         0.00005         1.00
    COI-BCV-3.46.2     0.00894         1.00         0.00895         1.00
    COI-BCV-4.13.1     0.00010         1.00         0.00010         1.00
    COI-SINTEF         0.00000         1.00         0.00000         1.00
    COI-ORTEC01        0.00270         1.00         0.00290         1.07
    COI-ORTEC02        0.00270         1.00         0.00295         1.09
    COI-ERMGH          0.00779         1.00         0.01179         1.51
    COI-CHILD          0.00149         1.00         0.00161         1.08
    COI-ERRVH          0.02001         1.00         0.04476         2.24
    COI-HED01          0.00136         1.00         0.00136         1.00
    COI-Valouxis-1     0.00020         1.00         0.00060         3.00
    COI-Ikegami-2.1    0.00000         1.00         0.00000         1.00
    COI-Ikegami-3.1    0.00002         1.00         0.00011         5.50
    COI-Ikegami-3.1.1  0.00003         1.00         0.00012         4.00
    COI-Ikegami-3.1.2  0.00003         1.00         0.00014         4.67
    COI-BCDT-Sep       0.00100         1.00         0.00260         2.60
    COI-MER            0.07081         1.00         0.32909         4.65
    --------------------------------------------------------------------
        Average        0.00453         1.00         0.01531         inf.
  
  This is worse for some large instances (ERRVH and MER), presumably
  because rdv does not help these instances and instead takes time
  away from solvers like rec that do help.

  Turning now to the INCR1 data sets, with rdv:

    Instances (30)    GOAL                         KHE26
                      Cost            Rel.         Cost            Rel.
    --------------------------------------------------------------------
    INRC1-L01         0.00197         1.00         0.00198         1.01
    INRC1-L02         0.00219         1.00         0.00224         1.02
    INRC1-L03         0.00240         1.00         0.00240         1.00
    INRC1-L04         0.00303         1.00         0.00304         1.00
    INRC1-L05         0.00284         1.00         0.00285         1.00
    INRC1-LH01        0.00346         1.00         0.00353         1.02
    INRC1-LH02        0.00089         1.00         0.00091         1.02
    INRC1-LH03        0.00038         1.00         0.00042         1.11
    INRC1-LH04        0.00022         1.00         0.00028         1.27
    INRC1-LH05        0.00041         1.00         0.00046         1.12
    INRC1-LL01        0.00235         1.00         0.00251         1.07
    INRC1-LL02        0.00229         1.00         0.00245         1.07
    INRC1-LL03        0.00220         1.00         0.00254         1.15
    INRC1-LL04        0.00222         1.00         0.00241         1.09
    INRC1-LL05        0.00083         1.00         0.00085         1.02
    INRC1-M01         0.00240         1.00         0.00243         1.01
    INRC1-M02         0.00240         1.00         0.00243         1.01
    INRC1-M03         0.00236         1.00         0.00237         1.00
    INRC1-M04         0.00237         1.00         0.00241         1.02
    INRC1-M05         0.00303         1.00         0.00309         1.02
    INRC1-MH01        0.00111         1.00         0.00122         1.10
    INRC1-MH02        0.00221         1.00         0.00240         1.09
    INRC1-MH03        0.00034         1.00         0.00040         1.18
    INRC1-MH04        0.00078         1.00         0.00085         1.09
    INRC1-MH05        0.00119         1.00         0.00124         1.04
    INRC1-ML01        0.00157         1.00         0.00164         1.04
    INRC1-ML02        0.00018         1.00         0.00022         1.22
    INRC1-ML03        0.00029         1.00         0.00033         1.14
    INRC1-ML04        0.00035         1.00         0.00043         1.23
    INRC1-ML05        0.00107         1.00         0.00114         1.07
    --------------------------------------------------------------------
      Average         0.00164         1.00         0.00171         1.07 

    Instances (30)    GOAL                         KHE26
                      Cost            Rel.         Cost            Rel.
    --------------------------------------------------------------------
    INRC1-S01         0.00056         1.00         0.00056         1.00
    INRC1-S02         0.00058         1.00         0.00059         1.02
    INRC1-S03         0.00051         1.00         0.00052         1.02
    INRC1-S04         0.00059         1.00         0.00059         1.00
    INRC1-S05         0.00058         1.00         0.00058         1.00
    INRC1-S06         0.00054         1.00         0.00054         1.00
    INRC1-S07         0.00056         1.00         0.00056         1.00
    INRC1-S08         0.00056         1.00         0.00056         1.00
    INRC1-S09         0.00055         1.00         0.00056         1.02
    INRC1-S10         0.00052         1.00         0.00052         1.00
    INRC1-SH01        0.00032         1.00         0.00034         1.06
    INRC1-SH02        0.00032         1.00         0.00034         1.06
    INRC1-SH03        0.00062         1.00         0.00063         1.02
    INRC1-SH04        0.00066         1.00         0.00067         1.02
    INRC1-SH05        0.00059         1.00         0.00060         1.02
    INRC1-SH06        0.00130         1.00         0.00130         1.00
    INRC1-SH07        0.00153         1.00         0.00153         1.00
    INRC1-SH08        0.00204         1.00         0.00204         1.00
    INRC1-SH09        0.00338         1.00         0.00338         1.00
    INRC1-SH10        0.00306         1.00         0.00306         1.00
    INRC1-SL01        0.00037         1.00         0.00037         1.00
    INRC1-SL02        0.00042         1.00         0.00043         1.02
    INRC1-SL03        0.00048         1.00         0.00049         1.02
    INRC1-SL04        0.00073         1.00         0.00073         1.00
    INRC1-SL05        0.00044         1.00         0.00045         1.02
    INRC1-SL06        0.00042         1.00         0.00042         1.00
    INRC1-SL07        0.00042         1.00         0.00043         1.02
    INRC1-SL08        0.00017         1.00         0.00017         1.00
    INRC1-SL09        0.00017         1.00         0.00017         1.00
    INRC1-SL10        0.00043         1.00         0.00044         1.02
    --------------------------------------------------------------------
        Average       0.00078         1.00         0.00078         1.01

  We're doing slightly better than KHE24 on INCR1, as evidenced by the
  average relative cost of 1.07 on the Large and Medium instances,
  compared to KHE24's 1.11, although now we are using the full five
  minutes.  For the Sprint instances there is no improvement in the
  average relative cost, although since it was already 1.01 that was
  not to be expected.

  And now we have a core dump on INRC2-4-040-0-2061:

    parallel solve of INRC2-4-040-0-2061: starting solve 12
    KheAssignResourceGroupAugment internal error 3

14 May 2026.  Working on yesterday's bug.  The problem is that a
  KHE_SUBTAG_ASSIGN_RESOURCE group monitor has another group monitor
  as a child.  Function KheMTaskSetSliceGroupAssignResourceMonitors 
  in khe_se_solvers.c is probably the culprit.  It does some grouping
  of assign resource monitors without knowing or caring whether they
  are already grouped.  It needs some analysis.

  In khe_sm_correlation.c, event resources are grouped if they have
  the same leader tasks.  This will indeed mean that their assign
  resource monitors are correlated.

  I've enhanced KheAssignResourceGroupAugment so that it now
  handles trees of assign resource group monitors.  That seems
  to have fixed the problem.  I've done a best of 12:

    [ "INRC2-4-040-0-2061", 12 threads, 12 solves, 280.7 secs:
      0.01795 0.01855 0.01855 0.01860 0.01870 0.01895 0.01895 0.01895
      0.01905 0.01945 0.01950 0.01990
    ] 0.01785 is best cost (Nurse: 1 0.01795, Nurse:Trainee: 6 0.01895)

  Started a full run, but then found another bug, which is that
  the mtask set built for repair was empty.  That must be rare,
  so now we're just skipping the repair when it happens.

    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291         0.01695    1.00         0.01755    1.04
    INRC2-4-030-1-6753         0.01890    1.00         0.01915    1.01
    INRC2-4-035-0-1718         0.01425    1.00         0.01490    1.05
    INRC2-4-035-2-8875         0.01155    1.00         0.01235    1.07
    INRC2-4-040-0-2061         0.01685    1.00         0.01775    1.05
    INRC2-4-040-2-6106         0.01890    1.00         0.02020    1.07
    INRC2-4-050-0-0487         0.01505    1.00         0.01625    1.08
    INRC2-4-050-0-7272         0.01500    1.00         0.01505    1.00
    INRC2-4-060-1-6115         0.02505    1.00         0.02720    1.09
    INRC2-4-060-1-9638         0.02750    1.00         0.03070    1.12 *
    INRC2-4-070-0-3651         0.02435    1.00         0.02770    1.14 *
    INRC2-4-070-0-4967         0.02175    1.00         0.02380    1.09
    INRC2-4-080-2-4333         0.03340    1.00         0.03565    1.07
    INRC2-4-080-2-6048         0.03260    1.00         0.03595    1.10
    INRC2-4-100-0-1108         0.01245    1.00         0.01375    1.10
    INRC2-4-100-2-0646         0.01950    1.00         0.02335    1.20 *
    INRC2-4-110-0-1428         0.02440    1.00         0.02680    1.10
    INRC2-4-110-0-1935         0.02560    1.00         0.02755    1.08
    INRC2-4-120-1-4626         0.02170    1.00         0.02635    1.21 *
    INRC2-4-120-1-5698         0.02220    1.00         0.02580    1.16 *
    ----------------------------------------------------------------------
       Average                 0.02089    1.00         0.02289    1.09

  This is better than I was getting before:  an average relative cost
  of 1.09, and only five instances with a relative cost larger than 1.0.
  And for my old foe INRC2-4-100-0-1108, a relative cost of 1.10.

15 May 2026.  Working on INRC2-4-120-1-4626.  When I ran it I got

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02555 0.02705 0.02710 0.02715 0.02720 0.02735 0.02740 0.02760
      0.02765 0.02775 0.02790 0.02855
    ] 0.02555 is best cost (first diversifier 6)

  This is somewhat better than the 0.02635 I got yesterday, it is
  rel = 1.17.  Still the second worst rel value, worth working on.
  Here is the LOR summary:

    Summary                                     Inf.         Obj.
    -------------------------------------------------------------
    Assign Resource Constraint (15 points)                    450
    Avoid Unavailable Times Constraint (33 points)            440
    Cluster Busy Times Constraint (40 points)                1040
    Limit Active Intervals Constraint (9 points)              240
    -------------------------------------------------------------
      Grand total (97 points)                                2170

  And here is the KHE26 summary:

    Summary                                     Inf.         Obj.
    -------------------------------------------------------------
    Assign Resource Constraint (19 points)                    570
    Avoid Unavailable Times Constraint (35 points)            430
    Cluster Busy Times Constraint (45 points)                1300
    Limit Active Intervals Constraint (11 points)             255
    -------------------------------------------------------------
      Grand total (110 points)                               2555

16 May 2026.  Did some work on the PATAT paper, the revised
  version is now ready to submit, in directory conf2.  Also
  did some work on a possible larger version of the paper, by
  adding a section showing how the results on INRC2-4-100-0-1108
  have improved since the last paper.

17 May 2026.  Finished off the new section of the PATAT paper,
 simplifying the writing and tweaking the figure.  Made a start
 on some Journal of Scheduling refereeing I have to do.

18 May 2026.  Looking at the two tables (15 May), the problem
  is clearly in the cluster defects.  A big part of that is
  in the max busy weekends defects, which have cost 4 * 30 = 120
  in the LOR solution, and cost 14 * 30 = 420 in the KHE solution.
  This alone explains the 300 point difference.  The KHE solution
  also has two violations of the complete weekends constraint,
  costing 2 * 30 = 60.

  I guess the first quesion is, would a longer run help?  So
  here's a 10-minute run:

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 10.0 mins:
      0.02460 0.02535 0.02540 0.02550 0.02555 0.02555 0.02580 0.02590
      0.02600 0.02630 0.02750 0.02755
    ] 0.02435 is best cost (Nurse: 6 0.02460, Nurse:Trainee: 1 0.02555)

  This is 1.12, actually not far off target.  But still I'll have
  a look around, see what I can do with those busy weekends.  Back
  to the 5-minute run.  This time I got

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02685 0.02705 0.02705 0.02740 0.02750 0.02760 0.02770 0.02790
      0.02815 0.02830 0.02880 0.02935
    ] 0.02660 is best cost (Nurse: 3 0.02685, Nurse:Trainee: 6 0.02830)

    Summary                                     Inf.         Obj.
    -------------------------------------------------------------
    Assign Resource Constraint (19 points)                    570
    Avoid Unavailable Times Constraint (36 points)            490
    Cluster Busy Times Constraint (43 points)                1270
    Limit Active Intervals Constraint (14 points)             330
    -------------------------------------------------------------
      Grand total (112 points)                               2660

  which is rel = 1.22.   Still 14 * 30 = 420 cost in max busy weekends,
  so despite the change in cost the basic problem has not changed.

  Here are the workload balance tables:

    Nurse                            LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     29       26
    O  Available times (negative)     37       33
    Y  Unnecessary assignments         4        6
    X  Unassigned tasks                9       12
    ---------------------------------------------
    U - O + Y - X                    -13      -13

    Trainee                          LOR      KHE
    ---------------------------------------------
    U  Available times (positive)     11       14
    O  Available times (negative)      9        9
    Y  Unnecessary assignments        11        9
    X  Unassigned tasks                6        7
    ---------------------------------------------
    U - O + Y - X                      7        7

  This gives

    LOR:  O + X = (37 +  9) + (9 + 6) = 46 + 15 = 61
    KHE:  O + X = (33 + 12) + (9 + 7) = 45 + 16 = 61

  So there is nothing in this, which is good news in one way.  But
  it means that we have to look elsewhere for an explanation of
  the gap in cost, to the extra 300 in cost in max busy weekends
  violations identified above.  In LOR these defects have cost
  4 * 30 = 120. while in KHE they have cost 14 * 30 = 420. a
  300 point difference.  If we could remove this we would have
  rel = (2660 - 300) / 2170 = 1.08, instead of the current 1.22.

  In the KHE solutions, there are 10 nurses (not including trainees)
  who have too many busy weekends, and 33 nurses whose number of
  busy weekends is strictly below their maximum limit.  The case
  for trainees is similar.  So there are loads of opportunities for
  moving busy weekends to nurses who could accept them.  The problem
  is that these moves are very disruptive.  So what to do?  There is
  very little spare workload, as usual.  Every nurse who is working
  too many weekends is either overloaded or right on the limit.

  Why not TR101 <--> TR110 1Mon-1Fri?  It looks like it saves
  one workload overload, worth 20 points.  But it introduces
  problems for both resources, so is rightly rejected.

  The only solver that really tries to repair these defects
  is rdv.  It is in use now and presumably doing its best.
  Its default value is "targeted(4:8, 5:6, 6:3)".  But a
  debug print shows that it is only trying 7 neighbourhoods,
  not enough to change anything.  Nearly all the resources
  tried are HN resources.  All of the attempts return false.

19 May 2026.  It's hard to see how to repair these max busy
  weekends defects in KHE's solution to INRC2-4-120-1-4626.
  I've been thinking it over but it seems very hard.  So
  I wondered whether time sweep would be better at avoiding
  them to begin with than sequential, and so I've decided to
  try changing rs_drs_seq_frac.  Here is the result using
  the default value, which is currently 0.3:

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02690 0.02705 0.02710 0.02735 0.02740 0.02740 0.02750 0.02765
      0.02775 0.02775 0.02795 0.02855
    ] 0.02645 is best cost (Nurse: 10 0.02690, Nurse:Trainee: 0 0.02740)

  which is a bit different from yesterday and has rel = 1.21.  And
  here is the result using rs_drs_seq_frac=0.0:

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02685 0.02705 0.02725 0.02735 0.02740 0.02750 0.02780 0.02820
      0.02840 0.02855 0.02865 0.02905
    ] 0.02665 is best cost (Nurse: 3 0.02685, Nurse:Trainee: 7 0.02725)

  So it's much the same, slightly worse.  Here is frac=0.6:

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02655 0.02740 0.02780 0.02790 0.02790 0.02800 0.02825 0.02825
      0.02850 0.02875 0.02900 0.02930
    ] 0.02655 is best cost (first diversifier 0)

  So there is very little in it, but the default value, frac=0.3,
  is giving the best result here.

  Added "rex" to do-it-yourself solving, like rec except that it
  turns widening and balancing off beforehand and restores them
  afterwards.  I'm trying "rgr rex", which is an ejection chain
  solve that preserves existing runs of consecutive busy tasks,
  in place of the last "rec".  There were quite a few stupid
  bugs to fix, but here are the first results:

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02630 0.02645 0.02715 0.02725 0.02745 0.02750 0.02780 0.02820
      0.02835 0.02875 0.02885 0.02955
    ] 0.02605 is best cost (Nurse: 9 0.02630, Nurse:Trainee: 7 0.02725)

    Summary                                     Inf.         Obj.
    -------------------------------------------------------------
    Assign Resource Constraint (16 points)                    480
    Avoid Unavailable Times Constraint (29 points)            410
    Cluster Busy Times Constraint (49 points)                1430
    Limit Active Intervals Constraint (14 points)             285
    -------------------------------------------------------------
        Grand total (108 points)                             2605

  Amazing, things have actually improved, from 2645 to 2605, which
  is rel = 1.20.  But the part I thought I was going to improve, the
  cluster busy times cost, is worse compared with this result from
  18 May 2026:

    Summary                                     Inf.         Obj.
    -------------------------------------------------------------
    Assign Resource Constraint (19 points)                    570
    Avoid Unavailable Times Constraint (36 points)            490
    Cluster Busy Times Constraint (43 points)                1270
    Limit Active Intervals Constraint (14 points)             330
    -------------------------------------------------------------
      Grand total (112 points)                               2660

  Had to fix a bug in KheSolnAdjusterDoMonitorGroupEnd, then I got this:

  Using rex not at all:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01410 0.01495 0.01535 0.01545 0.01575 0.01575 0.01600 0.01605
      0.01635 0.01665 0.01675 0.01770
    ] 0.01410 is best cost (first diversifier 5)

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02620 0.02730 0.02755 0.02770 0.02790 0.02800 0.02805 0.02830
      0.02855 0.02860 0.02900 0.02965
    ] 0.02605 is best cost (Nurse: 8 0.02620, Nurse:Trainee: 7 0.02800)

  Using rex last:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 297.3 secs:
      0.01420 0.01500 0.01520 0.01535 0.01560 0.01585 0.01610 0.01645
      0.01650 0.01665 0.01665 0.01670
    ] 0.01420 is best cost (first diversifier 5)

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02615 0.02680 0.02725 0.02730 0.02740 0.02745 0.02770 0.02775
      0.02800 0.02830 0.02840 0.02840
    ] 0.02570 is best cost (Nurse: 8 0.02615, Nurse:Trainee: 6 0.02730)

  Using rex second:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01510 0.01515 0.01535 0.01540 0.01575 0.01585 0.01610 0.01680
      0.01695 0.01710 0.01710 0.01750
    ] 0.01470 is best cost (Nurse: 5 0.01540, Nurse:Trainee: 10 0.01710)

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02585 0.02640 0.02655 0.02720 0.02730 0.02740 0.02755 0.02760
      0.02765 0.02810 0.02825 0.02865
    ] 0.02555 is best cost (Nurse: 6 0.02585, Nurse:Trainee: 1 0.02730)

  The results for the two instances go in opposite directions.  But
  using rex last gives the smallest sum of costs.  So let's try a
  full run with that:

    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01775       1.05
    INRC2-4-030-1-6753      0.01890       1.00      0.01930       1.02
    INRC2-4-035-0-1718      0.01425       1.00      0.01480       1.04
    INRC2-4-035-2-8875      0.01155       1.00      0.01290       1.12 *
    INRC2-4-040-0-2061      0.01685       1.00      0.01770       1.05
    INRC2-4-040-2-6106      0.01890       1.00      0.01975       1.04
    INRC2-4-050-0-0487      0.01505       1.00      0.01600       1.06
    INRC2-4-050-0-7272      0.01500       1.00      0.01510       1.01
    INRC2-4-060-1-6115      0.02505       1.00      0.02725       1.09
    INRC2-4-060-1-9638      0.02750       1.00      0.03045       1.11 *
    INRC2-4-070-0-3651      0.02435       1.00      0.02795       1.15 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02405       1.11 *
    INRC2-4-080-2-4333      0.03340       1.00      0.03595       1.08
    INRC2-4-080-2-6048      0.03260       1.00      0.03620       1.11 *
    INRC2-4-100-0-1108      0.01245       1.00      0.01470       1.18 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02395       1.23 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02650       1.09
    INRC2-4-110-0-1935      0.02560       1.00      0.02790       1.09
    INRC2-4-120-1-4626      0.02170       1.00      0.02535       1.17 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02565       1.16 *
    ----------------------------------------------------------------------
         Average            0.02089       1.00      0.02296       1.10 

  This is worse than I was getting before (14 May 2026):  1.10 where I
  had 1.09 before, and 9 solutions over 1.10 where I had 5 before.  So
  here is a fresh run without rex at all:

    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01765       1.04
    INRC2-4-030-1-6753      0.01890       1.00      0.01930       1.02
    INRC2-4-035-0-1718      0.01425       1.00      0.01480       1.04
    INRC2-4-035-2-8875      0.01155       1.00      0.01290       1.12 *
    INRC2-4-040-0-2061      0.01685       1.00      0.01795       1.07
    INRC2-4-040-2-6106      0.01890       1.00      0.02020       1.07
    INRC2-4-050-0-0487      0.01505       1.00      0.01605       1.07
    INRC2-4-050-0-7272      0.01500       1.00      0.01510       1.01
    INRC2-4-060-1-6115      0.02505       1.00      0.02755       1.10
    INRC2-4-060-1-9638      0.02750       1.00      0.03065       1.11 *
    INRC2-4-070-0-3651      0.02435       1.00      0.02725       1.12 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02385       1.10
    INRC2-4-080-2-4333      0.03340       1.00      0.03595       1.08
    INRC2-4-080-2-6048      0.03260       1.00      0.03580       1.10
    INRC2-4-100-0-1108      0.01245       1.00      0.01485       1.19 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02325       1.19 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02670       1.09
    INRC2-4-110-0-1935      0.02560       1.00      0.02755       1.08
    INRC2-4-120-1-4626      0.02170       1.00      0.02570       1.18 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02565       1.16 *
    ----------------------------------------------------------------------
        Average             0.02089       1.00      0.02293       1.10

  On the whole it seems that rex is not helping.  The final average is
  the same, and there are only 7 solutions over 1.10, not 9.  Also the
  largest relative cost here is 1.19; it was 1.23 above.  So I'm
  dropping rex.

20 May 2026.  I seem to have lost ground on INRC2-4-100-0-1108, so
  today's job is to look into that.  Here's the usual run:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01425 0.01500 0.01500 0.01505 0.01575 0.01595 0.01600 0.01610
      0.01655 0.01655 0.01655 0.01665
    ] 0.01410 is best cost (Nurse: 5 0.01425, Nurse:Trainee: 4 0.01595)

  This is res = 1.13.  It is quite a lot better than yesterday, why?

  Decided to implement solving each instance by a separate binary.
  I'm doing this by generating a bash file and leaving it to the
  caller to call this file.  All done and under test.  Here is
  the first output, on an archive holding two instances;

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01475 0.01495 0.01500 0.01520 0.01530 0.01555 0.01575 0.01600
      0.01640 0.01645 0.01665 0.01800
    ] 0.01475 is best cost (first diversifier 8)

    [ "INRC2-4-120-1-4626", 12 threads, 12 solves, 5.0 mins:
      0.02595 0.02655 0.02690 0.02715 0.02720 0.02730 0.02765 0.02770
      0.02825 0.02870 0.02910 0.02945
    ] 0.02595 is best cost (first diversifier 7)

  It's working, but these are not great results; in fact, they are
  both worse than yesterday's results from the most recent full run.
  So much for the full run slowing things down.  Here's the same
  single run that worked well before:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01430 0.01495 0.01500 0.01505 0.01575 0.01585 0.01595 0.01635
      0.01655 0.01655 0.01665 0.01685
    ] 0.01415 is best cost (Nurse: 5 0.01430, Nurse:Trainee: 4 0.01495)

  Noticeably better.  And here it is again:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01475 0.01500 0.01500 0.01505 0.01540 0.01575 0.01580 0.01600
      0.01615 0.01655 0.01665 0.01695
    ] 0.01450 is best cost (Nurse: 8 0.01475, Nurse:Trainee: 4 0.01500)

  And again:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01430 0.01495 0.01495 0.01540 0.01570 0.01580 0.01585 0.01650
      0.01655 0.01655 0.01665 0.01745
    ] 0.01430 is best cost (first diversifier 5)

  There is more variability here than usual.

  Along the way I discovered that solution group metadata was not
  being preserved by "khe -m".  All fixed now.  Back to grinding
  down INRC2-4-100-0-1108:

    [ "INRC2-4-100-0-1108", 12 threads, 12 solves, 5.0 mins:
      0.01475 0.01475 0.01495 0.01545 0.01560 0.01575 0.01600 0.01610
      0.01665 0.01665 0.01685 0.01720
    ] 0.01465 is best cost (Nurse: 8 0.01475, Nurse:Trainee: 5 0.01475)

21 May 2026.  Decided to see whether 8 solves are better than 12.
  And indeed it is:

    [ "INRC2-4-100-0-1108", 8 threads, 8 solves, 5.0 mins:
      0.01375 0.01480 0.01490 0.01520 0.01565 0.01590 0.01620 0.01710
    ] 0.01360 is best cost (Nurse: 5 0.01375, Nurse:Trainee: 4 0.01490)

  Now what about 4626:

    [ "INRC2-4-120-1-4626", 8 threads, 8 solves, 5.0 mins:
      0.02450 0.02575 0.02705 0.02710 0.02740 0.02755 0.02760 0.02970
    ] 0.02450 is best cost (first diversifier 6)

  This too is a new best.  OK, it's time for a full run with 8
  threads per solve.

    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01805       1.06
    INRC2-4-030-1-6753      0.01890       1.00      0.01925       1.02
    INRC2-4-035-0-1718      0.01425       1.00      0.01505       1.06
    INRC2-4-035-2-8875      0.01155       1.00      0.01290       1.12 *
    INRC2-4-040-0-2061      0.01685       1.00      0.01770       1.05
    INRC2-4-040-2-6106      0.01890       1.00      0.01980       1.05
    INRC2-4-050-0-0487      0.01505       1.00      0.01615       1.07
    INRC2-4-050-0-7272      0.01500       1.00      0.01530       1.02
    INRC2-4-060-1-6115      0.02505       1.00      0.02725       1.09
    INRC2-4-060-1-9638      0.02750       1.00      0.03075       1.12 *
    INRC2-4-070-0-3651      0.02435       1.00      0.02770       1.14 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02375       1.09
    INRC2-4-080-2-4333      0.03340       1.00      0.03560       1.07
    INRC2-4-080-2-6048      0.03260       1.00      0.03540       1.09
    INRC2-4-100-0-1108      0.01245       1.00      0.01400       1.12 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02305       1.18 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02590       1.06
    INRC2-4-110-0-1935      0.02560       1.00      0.02790       1.09
    INRC2-4-120-1-4626      0.02170       1.00      0.02530       1.17 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02600       1.17 *
    ----------------------------------------------------------------------
        Average             0.02089       1.00      0.02284       1.09

  Sure enough this is slightly better.  Now what about COI:

    Instance       KHE24 (5 mins)   KHE26 (28 Jan)  KHE_26 (today)
    ------------------------------------------------------------
    Ozkarahan          0                ?                0
    Musa             175                ?              175
    Millar-2.1         0                ?                0
    Millar-2.1.1       0                ?                0
    LLR              301                ?              301
    Azaiez	       0                1                0
    GPost              8               12                6
    GPost-B            5               10                5
    QMC-1             16               22               16
    QMC-2             30                ?               29
    WHPP            2001             1003                5
    BCV-3.46.2	     896              895              805
    BCV-4-13.1        10                ?               10
    SINTEF             0                1                1  *
    ORTEC01          300              315              290
    ORTEC02          295              300              295
    ERMGH           1481             2359             1126
    CHILD           2824             3987              261
    ERRVH           6739             9003             4153
    HED01            139                ?              136
    Valouxis         100              160              100
    Ikegami-2.1        0               50                0
    Ikegami-3.1       10              283               10
    Ikegami-3.1.1     14              283               11
    Ikegami-3.1.2     15              292               13
    BCDT-Sep         240              280              260  *
    MER            56048            -- out of mem -- 38167
    ------------------------------------------------------------

  This is better than KHE24 (5 minutes), except that it is slightly
  worse on two instances, marked with asterisks.  A good result, then.

  COI-MER was in trouble again, going wildly over time.  I tracked
  it down to the very first SolnExpand in the dynamic resource solver.
  So now there are time limit checks inside SolnExpand, and all is well.

  OK, here is a full test of INRC2-4 with 8 threads and rds and
  rs_drs_seq_frac set to its default value, which is 0.3:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000       1.00      0.00000       1.00
    COI-Musa                0.00175       1.00      0.00175       1.00
    COI-Millar-2.1          0.00000       1.00      0.00000       1.00
    COI-Millar-2.1.1        0.00000       1.00      0.00000       1.00
    COI-LLR                 0.00301       1.00      0.00301       1.00
    COI-Azaiez              0.00000       1.00      0.00000       1.00
    COI-GPost               0.00005       1.00      0.00008       1.60
    COI-GPost-B             0.00003       1.00      0.00005       1.67
    COI-QMC-1               0.00013       1.00      0.00017       1.31
    COI-QMC-2               0.00029       1.00      0.00029       1.00
    COI-WHPP                0.00005       1.00      0.00005       1.00
    COI-BCV-3.46.2          0.00894       1.00      0.00895       1.00
    COI-BCV-4.13.1          0.00010       1.00      0.00010       1.00
    COI-SINTEF              0.00000       1.00      0.00000       1.00
    COI-ORTEC01             0.00270       1.00      0.00295       1.09
    COI-ORTEC02             0.00270       1.00      0.00336       1.24 *
    COI-ERMGH               0.00779       1.00      0.01105       1.42 *
    COI-CHILD               0.00149       1.00      0.00154       1.03
    COI-ERRVH               0.02001       1.00      0.04493       2.25 *
    COI-HED01               0.00136       1.00      0.00136       1.00
    COI-Valouxis-1          0.00020       1.00      0.00080       4.00
    COI-Ikegami-2.1         0.00000       1.00      0.00000       1.00
    COI-Ikegami-3.1         0.00002       1.00      0.00007       3.50
    COI-Ikegami-3.1.1       0.00003       1.00      0.00014       4.67
    COI-Ikegami-3.1.2       0.00003       1.00      0.00014       4.67
    COI-BCDT-Sep            0.00100       1.00      0.00290       2.90
    COI-MER                 0.07081       1.00      0.35098       4.96 *
    ----------------------------------------------------------------------
        Average             0.00453       1.00      0.01609       1.83


    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01775       1.05
    INRC2-4-030-1-6753      0.01890       1.00      0.01945       1.03
    INRC2-4-035-0-1718      0.01425       1.00      0.01550       1.09
    INRC2-4-035-2-8875      0.01155       1.00      0.01270       1.10
    INRC2-4-040-0-2061      0.01685       1.00      0.01840       1.09
    INRC2-4-040-2-6106      0.01890       1.00      0.01965       1.04
    INRC2-4-050-0-0487      0.01505       1.00      0.01585       1.05
    INRC2-4-050-0-7272      0.01500       1.00      0.01510       1.01
    INRC2-4-060-1-6115      0.02505       1.00      0.02800       1.12 *
    INRC2-4-060-1-9638      0.02750       1.00      0.03025       1.10
    INRC2-4-070-0-3651      0.02435       1.00      0.02700       1.11 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02395       1.10
    INRC2-4-080-2-4333      0.03340       1.00      0.03640       1.09
    INRC2-4-080-2-6048      0.03260       1.00      0.03660       1.12 *
    INRC2-4-100-0-1108      0.01245       1.00      0.01460       1.17 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02215       1.14 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02600       1.07
    INRC2-4-110-0-1935      0.02560       1.00      0.02835       1.11 *
    INRC2-4-120-1-4626      0.02170       1.00      0.02475       1.14 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02655       1.20 *
    ----------------------------------------------------------------------
        Average             0.02089       1.00      0.02295       1.10

  And here we are with rds and rs_drs_seq_frac=0.6:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000       1.00      0.00000       1.00
    COI-Musa                0.00175       1.00      0.00175       1.00
    COI-Millar-2.1          0.00000       1.00      0.00000       1.00
    COI-Millar-2.1.1        0.00000       1.00      0.00000       1.00
    COI-LLR                 0.00301       1.00      0.00301       1.00
    COI-Azaiez              0.00000       1.00      0.00000       1.00
    COI-GPost               0.00005       1.00      0.00007       1.40
    COI-GPost-B             0.00003       1.00      0.00005       1.67
    COI-QMC-1               0.00013       1.00      0.00016       1.23
    COI-QMC-2               0.00029       1.00      0.00029       1.00
    COI-WHPP                0.00005       1.00      0.00005       1.00
    COI-BCV-3.46.2          0.00894       1.00      0.00894       1.00
    COI-BCV-4.13.1          0.00010       1.00      0.00010       1.00
    COI-SINTEF              0.00000       1.00      0.00000       1.00
    COI-ORTEC01             0.00270       1.00      0.00325       1.20 *
    COI-ORTEC02             0.00270       1.00      0.00305       1.13 *
    COI-ERMGH               0.00779       1.00      0.00993       1.27 *
    COI-CHILD               0.00149       1.00      0.00169       1.13 *
    COI-ERRVH               0.02001       1.00      0.04386       2.19 *
    COI-HED01               0.00136       1.00      0.00136       1.00
    COI-Valouxis-1          0.00020       1.00      0.00080       4.00
    COI-Ikegami-2.1         0.00000       1.00      0.00000       1.00
    COI-Ikegami-3.1         0.00002       1.00      0.00010       5.00
    COI-Ikegami-3.1.1       0.00003       1.00      0.00012       4.00
    COI-Ikegami-3.1.2       0.00003       1.00      0.00014       4.67
    COI-BCDT-Sep            0.00100       1.00      0.00220       2.20
    COI-MER                 0.07081       1.00      0.35978       5.08 *
    ----------------------------------------------------------------------
     Average                0.00453       1.00      0.01632       1.82 


    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01740       1.03
    INRC2-4-030-1-6753      0.01890       1.00      0.01940       1.03
    INRC2-4-035-0-1718      0.01425       1.00      0.01515       1.06
    INRC2-4-035-2-8875      0.01155       1.00      0.01240       1.07
    INRC2-4-040-0-2061      0.01685       1.00      0.01840       1.09
    INRC2-4-040-2-6106      0.01890       1.00      0.01990       1.05
    INRC2-4-050-0-0487      0.01505       1.00      0.01600       1.06
    INRC2-4-050-0-7272      0.01500       1.00      0.01505       1.00
    INRC2-4-060-1-6115      0.02505       1.00      0.02695       1.08
    INRC2-4-060-1-9638      0.02750       1.00      0.03030       1.10
    INRC2-4-070-0-3651      0.02435       1.00      0.02805       1.15 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02410       1.11 *
    INRC2-4-080-2-4333      0.03340       1.00      0.03620       1.08
    INRC2-4-080-2-6048      0.03260       1.00      0.03550       1.09
    INRC2-4-100-0-1108      0.01245       1.00      0.01480       1.19 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02215       1.14 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02605       1.07
    INRC2-4-110-0-1935      0.02560       1.00      0.02850       1.11 *
    INRC2-4-120-1-4626      0.02170       1.00      0.02535       1.17 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02560       1.15 *
    ----------------------------------------------------------------------
        Average             0.02089       1.00      0.02286       1.09

  And finally rds with rs_drs_seq_frac=0.0:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000       1.00      0.00000       1.00
    COI-Musa                0.00175       1.00      0.00175       1.00
    COI-Millar-2.1          0.00000       1.00      0.00000       1.00
    COI-Millar-2.1.1        0.00000       1.00      0.00000       1.00
    COI-LLR                 0.00301       1.00      0.00301       1.00
    COI-Azaiez              0.00000       1.00      0.00000       1.00
    COI-GPost               0.00005       1.00      0.00006       1.20
    COI-GPost-B             0.00003       1.00      0.00005       1.67
    COI-QMC-1               0.00013       1.00      0.00016       1.23
    COI-QMC-2               0.00029       1.00      0.00029       1.00
    COI-WHPP                0.00005       1.00      0.00005       1.00
    COI-BCV-3.46.2          0.00894       1.00      0.00895       1.00
    COI-BCV-4.13.1          0.00010       1.00      0.00010       1.00
    COI-SINTEF              0.00000       1.00      0.00001       inf.
    COI-ORTEC01             0.00270       1.00      0.00290       1.07
    COI-ORTEC02             0.00270       1.00      0.00295       1.09
    COI-ERMGH               0.00779       1.00      0.01092       1.40 *
    COI-CHILD               0.00149       1.00      0.00261       1.75 *
    COI-ERRVH               0.02001       1.00      0.04164       2.08 *
    COI-HED01               0.00136       1.00      0.00136       1.00
    COI-Valouxis-1          0.00020       1.00      0.00100       5.00
    COI-Ikegami-2.1         0.00000       1.00      0.00000       1.00
    COI-Ikegami-3.1         0.00002       1.00      0.00010       5.00
    COI-Ikegami-3.1.1       0.00003       1.00      0.00011       3.67
    COI-Ikegami-3.1.2       0.00003       1.00      0.00013       4.33
    COI-BCDT-Sep            0.00100       1.00      0.00260       2.60
    COI-MER                 0.07081       1.00      0.35940       5.08 *
    ----------------------------------------------------------------------
        Average             0.00453       1.00      0.01630       inf

    Instances (20)             LOR17                   KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695       1.00      0.01805       1.06
    INRC2-4-030-1-6753      0.01890       1.00      0.01925       1.02
    INRC2-4-035-0-1718      0.01425       1.00      0.01505       1.06
    INRC2-4-035-2-8875      0.01155       1.00      0.01290       1.12 *
    INRC2-4-040-0-2061      0.01685       1.00      0.01770       1.05
    INRC2-4-040-2-6106      0.01890       1.00      0.01980       1.05
    INRC2-4-050-0-0487      0.01505       1.00      0.01575       1.05
    INRC2-4-050-0-7272      0.01500       1.00      0.01530       1.02
    INRC2-4-060-1-6115      0.02505       1.00      0.02725       1.09
    INRC2-4-060-1-9638      0.02750       1.00      0.03075       1.12 *
    INRC2-4-070-0-3651      0.02435       1.00      0.02770       1.14 *
    INRC2-4-070-0-4967      0.02175       1.00      0.02375       1.09
    INRC2-4-080-2-4333      0.03340       1.00      0.03570       1.07
    INRC2-4-080-2-6048      0.03260       1.00      0.03550       1.09
    INRC2-4-100-0-1108      0.01245       1.00      0.01400       1.12 *
    INRC2-4-100-2-0646      0.01950       1.00      0.02310       1.18 *
    INRC2-4-110-0-1428      0.02440       1.00      0.02590       1.06
    INRC2-4-110-0-1935      0.02560       1.00      0.02800       1.09
    INRC2-4-120-1-4626      0.02170       1.00      0.02515       1.16 *
    INRC2-4-120-1-5698      0.02220       1.00      0.02600       1.17 *
    ----------------------------------------------------------------------
        Average             0.02089       1.00      0.02283       1.09

  There is very little to choose between these results.  I suppose
  this means we should choose to omit rds, although frac=0.3 does
  look like a good option.  Anyway we need to look into the error
  messages being produced by it.

  Started looking into the inconsisent monitor errors in MER.  It's
  easy enough to get debug output, but harder to see what it means.
  Just near the end:

      new_dev = 0 = Dev(esf, 0.0 + 60.0, 12.0 + 0.0)

  That 12.0 (variable ub) is preventing any cost from being generated.
  When we started opening, it started from 0.0, not from 12.0.
  Needs looking into.  KheDrsOpenChildrenUpdateUpperBounds is
  responsible for setting ub; but it seems to be fine.  Yes,
  that 12.0 should be 0.0 because there are no open children
  at that point.

  The dynamic resource solver produces initial solutions four
  weeks at a time, so it first solves Nurse999081 on 1Sun - 4Sat,
  and then solves Nurse999081 on 5Sun - 6Sat.  I've established
  that the monitor inconsistency occurs whether expand by shifts
  is used or not.

  The times of the problem constraint (Constraint:103) are all
  times on all days from 5Sun to 6Sat inclusive (14 days).  These
  are also the days that the solve tackles.  The upper bound on
  each day is being found to be 12.0, which is correct.

  Got it (I think):  the oc->child_indexes array has a sentinel,
  which means that even when it is empty, the test in
  KheDrsOpenChildrenUpperBoundFloatAll, which is

    HaArrayCount(oc->child_indexes) == 0

  will never have value true.

23 May 2026.  Fixing the bug reported just above today.  I've
  made a careful job of it, but in the end it was a simple fix,
  which seems to be working.  Here is MER, with no error reports:

    [ "COI-MER", 12 threads, 12 solves, 5.0 mins:
      0.37333 0.37447 0.38117 0.38164 0.40302 0.40689 0.40968 0.44590
      0.55406 0.55709 0.56682 0.60953
    ] 0.37333 is best cost (first diversifier 11)

  Adjusted the pinst debug output slightly.  The various options
  for ps_make produce more consistent output now.

  I tidied up HSEval today.  I've determined that HSEval and KHE should
  not be unified, because KHE needs the solvers and HSEval does not.
  MonitorPrintTables and MonitorPrintLowerBoundTableRow are odd, but I
  can't see any easy way to get rid of them.  I'm leaving them for the
  next cleanup.  Othewise all done.  It seems to be working.

  Off-site backup today.

  Starting to work on COI-MER.  The Misc cost is 7081:

    Summary (Misc)                               Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  Best of 12 was 37333, but best of 8 is better than that, as usual:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.33820 0.37526 0.37931 0.38504 0.38800 0.39002 0.39556 0.40598
    ] 0.33820 is best cost (first diversifier 7)

    Summary (KHE26)                             Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (20 points)            590
    Cluster Busy Times Constraint (18 points)                2700
    Limit Busy Times Constraint (153 points)                17240
    Limit Workload Constraint (4 points)                     4000
    Limit Active Intervals Constraint (69 points)            8600
    Limit Resources Constraint (248 points)                   690
    -------------------------------------------------------------
      Grand total (512 points)                              33820

  KHE26 is a lot worse in every category.  Why?  I tried a planning
  timetable print; there are thousands of unassigned tasks, in both
  the Misc and KHE solutions.  Here's a 10-minute run:

    [ "COI-MER", 8 threads, 8 solves, 10.0 mins:
      0.29684 0.30283 0.30361 0.30667 0.30828 0.30837 0.31414 0.32540
    ] 0.29684 is best cost (first diversifier 6)

    Summary (KHE26)                             Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (17 points)            440
    Cluster Busy Times Constraint (5 points)                 2300
    Limit Busy Times Constraint (137 points)                15300
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (69 points)            8500
    Limit Resources Constraint (243 points)                   744
    -------------------------------------------------------------
      Grand total (474 points)                              29684

  It's better but not dramatically better.  Here's a 30-minute run:

    [ "COI-MER", 8 threads, 8 solves, 30.0 mins:
      0.15475 0.17453 0.18141 0.18270 0.19670 0.20353 0.20679 0.21503
    ] 0.15475 is best cost (first diversifier 7)

  This is dramatically better, so let's try a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.15606 0.15640 0.16492 0.16570 0.17772 0.18096 0.18344 0.18942
    ] 0.15606 is best cost (first diversifier 7)

  These results are better on the whole, but the best is worse.

24 May 2026.  Yesterday's results suggest that KHE26 is topping
  out on COI-MER around the thirty minute mark.  Time for some
  old-fashioned grinding down.  So then, back to 5 minutes:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.33853 0.36987 0.37526 0.38070 0.38504 0.39210 0.39578 0.40518
    ] 0.33853 is best cost (first diversifier 7)

    Summary (KHE26)                             Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (20 points)            600
    Cluster Busy Times Constraint (23 points)                4100
    Limit Busy Times Constraint (149 points)                16860
    Limit Workload Constraint (4 points)                     2800
    Limit Active Intervals Constraint (70 points)            8800
    Limit Resources Constraint (244 points)                   693
    -------------------------------------------------------------
      Grand total (510 points)                              33853

  The number of defects is high, but it does not seem to be beyond
  what ejection chains can handle.  Here is the Misc result again:

    Summary (Misc)                               Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  There are problems in every category.  It's a bit overwhelming.
  I need to do a careful fun facts, since this is new territory.

  The limit resources defects are all DemandConstraint:[2345]A
  defects.  So they are all about too few or (usually) too many
  nurses during a particular time interval.  The more expensive
  B and C versions of these constraints never spring.  So an idea
  I had for grouping these monitors would not help.

  The Misc solution has almost no limit active intervals defects.
  There is just one consecutive free weekend defect, one consecutive
  busy weekend defect, and one unwanted pattern defect.  KHE26 has
  many, many more than this.

25 May 2026.  Spent the day sorting out COI-MER's fun facts.

26 May 2026.  Analysing the COI-MER solutions.  Looking at Nurse1040.
  In the KHE26 solutio there are 5 defects, total cost 550.  In the
  best solution there is just the one defect, total cost 10.

  Started work on module wanter.c in src_hseval.  This is intended
  to give a more nuanced version of which tasks are wanted, which
  will hopefully reduce the masses of extra tasks being printed.
  All done, audited, and used, ready to test.  Code is running
  but still getting too many unassigned tasks.  Need to arrange
  to call it from the command line, then do some debugging.

  There seem to be two senses of needing assignment:

     * A task may be assigned or preassigned, and so needs
       assignment in that way, or not;

     * A task may be unassigned and not preassigned, but it
       may still need assignment in the sense that if it is
       not assigned, some monitor has non-zero cost.

  So we really have two booleans:
                                Not (pre)assigned   (Pre)assigned
     ------------------------------------------------------------
     Not required for monitor   Do not print        Print yellow
     Required for monitor       Unassigned print    Print white
     ------------------------------------------------------------

  But when a task is assigned or preassigned, can we tell whether
  that is needed for a monitor or not?  The test is, if you take
  the assignment away, does the cost of any event resource monitor
  increase?  (or does a preassignment become violated).  Needs thought.

  Treat preassignment like a combination assign resource monitor and
  prefer resources monitor.  So forget it.

  If the task is assigned, then if unassigning it would increase
  the cost of any event resource monitor, that is case A (white),
  otherwise we have case B (yellow).

  If the task is not assigned, then if assigning it would decrease
  the cost of any event resource monitor, that is case C (unassigned
  print), otherwise we have case D (do not print).

  So actually it would be good to return two booleans:

     assigned:  true or false
     need_asst:  true or false

                          assigned == false   assigned == true
     ---------------------------------------------------------
     need_asst == false   Do not print        Print yellow
     need_asst == true    Unassigned print    Print white
     ---------------------------------------------------------

  We can get "assigned" from KheTaskAsstResource.  We can
  get need_asst from the new module, although it needs some
  tweaking to get it to where we want.

  If a task is assigned, that assignment could be defective.
  So that gives us a third boolean:

      defective_asst:  true or false

  which is only defined when assigned == true.  Or perhaps we
  should say that when assigned == false it is always false.

  Our plan is to pick a set of tasks that need assignment, even
  if there is some arbitrariness in the choice.  We prefer to
  include assigned tasks over unassigned ones, but we may still
  find ourselves not declaring that some assigned task needs
  assignment.

    TaskState(KHE_TASK task, bool *assigned, bool *need_asst,
      bool *defective_asst);

  A task is *assigned* if KheTaskAsstResource(task) != NULL.

  A task is *needed for assign resource or limit resources monitor m*
  if it has been chosen as one of the tasks which need to be assigned
  in order to give m cost 0.  For assign resource monitors m, all
  tasks monitored by m are needed.  For limit resources monitors m,
  some subset of the tasks monitored by m are needed, as determined
  by the wanter module.  Assigned tasks, and tasks which are needed
  for other monitors (including preassigned tasks whose preassignment
  lies within m's domain) get priority.

  A task is *needed* if it is needed for some monitor m that monitors it.

  A task has a *defective assignment* when it is assigned a resource r
  and is monitored by a prefer resources monitor whose preferred
  resources do not include r, or when it is monitored by an avoid
  split assignments monitor m of non-zero cost.  An unassigned task
  cannot have a defective assignment.

    Assigned  A-Selected Defective-A    Action
    --------------------------------------------------------------
    false     false      false          Do not print
    false     false      true           Cannot arise
    false     true       false          Unassigned BoldItalic
    false     true       true           Cannot arise
    true      false      false          Yellow / Roman
    true      false      true           Yellow / BoldItalic
    true      true       false          White / Roman
    true      true       true           White / BoldItalic
    --------------------------------------------------------------

  Actually it's probably better to use SPACE_TASK_COND.  Five
  of these six conditions are available among its values:

    typedef enum {
      SPACE_TASK_UNREQUIRED_UNASSIGNED,
      SPACE_TASK_UNREQUIRED_ASSIGNED,
      SPACE_TASK_REQUIRED_UNASSIGNED,
      SPACE_TASK_REQUIRED_ASSIGNED,
      SPACE_TASK_DEFECTIVE,
    } SPACE_TASK_COND;

  although some renaming might be in order:

    typedef enum {
      SPACE_TASK_UNASSIGNED_UNNEEDED_UNDEFECTIVE,    /* Do not print          */
      /* SPACE_TASK_UNASSIGNED_UNNEEDED_DEFECTIVE,      cannot arise          */
      SPACE_TASK_UNASSIGNED_NEEDED_UNDEFECTIVE,	     /* Unassigned BoldItalic */
      /* SPACE_TASK_UNASSIGNED_NEEDED_DEFECTIVE,        cannot arise          */
      SPACE_TASK_ASSIGNED_UNNEEDED_UNDEFECTIVE,	     /* Yellow / Roman        */
      SPACE_TASK_ASSIGNED_UNNEEDED_DEFECTIVE,	     /* Yellow / BoldItalic   */
      SPACE_TASK_ASSIGNED_NEEDED_UNDEFECTIVE,	     /* White / Roman         */
      SPACE_TASK_ASSIGNED_NEEDED_DEFECTIVE,          /* White / BoldItalic    */
    } SPACE_TASK_COND;

  "Needs assignment" is still better than "selected", because what we
  are doing here is deciding whether tasks are selected for printing.
  But there is a problem here in that task conditions are about task
  fonts not cell colours, so the Yellow etc. do not really apply here.
  Perhaps we can include these values in SPACE_CELL_COND, and when
  present they mean that there is at least one task and we delegate
  the decision to the first task.  Stuff like

     SPACE_ASSIGNED_UNNEEDED_UNDEFECTIVE

  This condition holds for a task when the task is assigned, unneeded,
  and undefective.  It holds for a cell when the cell contains at
  least one task, and its first task is assigned, unneeded, and
  undefective.  And so on, giving this:

    typedef enum {

      /* these conditions apply to tasks and to cells */
      SPACE_UNASSIGNED_UNNEEDED_UNDEFECTIVE,	/* Do not print          */
      SPACE_UNASSIGNED_NEEDED_UNDEFECTIVE,	/* Unassigned BoldItalic */
      SPACE_ASSIGNED_UNNEEDED_UNDEFECTIVE,	/* Yellow / Roman        */
      SPACE_ASSIGNED_UNNEEDED_DEFECTIVE,	/* Yellow / BoldItalic   */
      SPACE_ASSIGNED_NEEDED_UNDEFECTIVE,	/* White / Roman         */
      SPACE_ASSIGNED_NEEDED_DEFECTIVE,		/* White / BoldItalic    */

      /* these conditions apply only to cells */
      SPACE_TIME_GROUP_EMPTY,
      SPACE_TIME_GROUP_NON_EMPTY,
      SPACE_RESOURCE_GROUP_UNAVAIL_HARD,
      SPACE_RESOURCE_GROUP_UNAVAIL_SOFT,
      SPACE_RESOURCE_GROUP_UNAVAIL_PART,
      SPACE_RESOURCE_GROUP_MUST_BE_BUSY_HARD,
      SPACE_RESOURCE_GROUP_MUST_BE_BUSY_SOFT,
      SPACE_TASKS_NONE,
      SPACE_TASKS_ONE_OR_MORE,
      SPACE_TASKS_TWO_OR_MORE,
      SPACE_CONSTRAINT_VIOLATED,
      SPACE_CONSTRAINT_UNVIOLATED,
      SPACE_CONSTRAINT_SLACK,
    } SPACE_COND;

27 May 2026.  Added an appendix to the KHE manual entitled "HSEval
  Implementation Notes", and added a section to that appendix entitled
  "Spaces", docmenting what the space.c module does.  All written
  except the cell formatting sub-section.  I need to write that in
  conjunction with revising SPACE_COND.

  All done except some parts of timetable.c marked "still to do"
  where further conversion to the new space.h interface is needed.
  Also space.c needs a careful audit, plus a few things there are
  also still to do.

28 May 2026.  Working on space.c, now renamed to mesh.c and given
  a major internal reorganization.  It now needs a careful audit.
  The doc is all done except for one or two things that I can't
  be bothered about.

29 May 2026.  Audited mesh.c, timetable.c, and needer.c (name
  changed from wanter.c), they are in very good shape now.  I've
  also added a detailed description of needer.c to the doc.
  In short, I'm ready to test.

30 May 2026.  Tested the new code, it worked perfectly first time.
  These revisions to HSEval began on 26 May, so four days' work
  plus this morning's testing.  I think I've done enough on HSEval
  now.  Anyway I can't see any other outstanding problems.

  Looking closely at the MER solutions.  In the KHE26 MER solution,
  everyone has the maximum workload but there are still 63 unassigned
  tasks.  So this means that there are too many assigned but unneeded
  tasks.  So is there a problem with repairs that replace assigned
  but unneeded tasks with unassigned needed tasks?  Should be easy,
  one would think.  But most of the unassigned but needed tasks have
  workload 12, whereas most of the assigned but unneeded tasks have
  workload 4 (they are D2, mostly).  In the best solution there are
  also many unneeded tasks, but, remarkably, most of them are N
  (workload 8).

  It looks like KHE26 is assigning lots of D1 and D2 tasks, many
  more than is needed.  Is that being done deliberately?  Look
  at 4Mon, for example:  there are X D2 assignments, all of which
  are marked unnecessary.  Why were they assigned at all?  None
  of the D2 assignments are needed, apparently.

31 May 2026.  I changed HSEval to prefer lower workload events when
  deciding which unassigned events are needed.  All implemented,
  documented, and tested.  This made a huge difference in the
  unassigned tasks it printed.  For example, all the S12 tasks
  disappeared and were replaced by N tasks.  It also greatly
  reduced the unassigned workload, from 676.0 to 340.0.

  I've also changed the names of time groups to prefer constructed
  names listing the times when there is a shift and only a few times.

  I thought about adding time on requests as blue rectangles.  It makes
  sense, but it will not help with MER, because although MER has a lot
  of time on requests, nearly all of them are not for the full day.
  I could include them anyway, in colour A if the request is being
  satisfied, and in colour B if it isn't.

     Colour A:  if the cell represents exactly one resource, and that
     resource has a time on request whose times are entirely within
     this day, and that time on request is satisfied.

     Colour B:  if the cell represents exactly one resource, and that
     resource has a time on request whose times are entirely within
     this day, and that time on request is not satisfied.

  What about combining somehow with unavailable times?

      Unavailable but busy - dark red
      Unavailable and not busy - light red
      Time on but not busy - dark red
      Time on and busy - light rec red

  Hmm.

1 June 2026.  Here is a possible description I wrote (it is not implemented):

      The background colour in each cell attempts to summarize
      the state of the resource constraints that apply to the
      resources of that cell at the times of that cell.  If these
      constraints discourage assignment of some or all of the
      resources at some or all of the times, the cell is red:
      light red if the constraints involved are all satisfied,
      medium red if any are not satisfied.  The constraints could
      be avoid unavailable times constraints, or limit busy times
      constraints with maximum limit 0, or limit active intervals
      constraints when history prohibits an assignment at the start
      of the cycle.

      If the resource constraints encourage assignment of some or
      all of the resources at some or all of the times, the cell
      is blue:  light blue if the constraints involved are all
      satisfied, medium blue if any are not satisfied.  The
      constraints could be limit busy times constraints with
      minimum limit 1, or limit active intervals constraints when
      history requires an assignment at the start of the cycle.

      When a cell should be coloured both red and blue, one of those
      two colours is chosen, with unsatisfied constraints taking
      priority.  When a cell is not coloured either red or blue, it
      is coloured green if it is empty, or else light yellow (see
      below), or else the colour of the event containing the cell's
      first event resource if it has a colour, or else white.

      As requested, constraints whose name or Id includes "weekend"
      are highlighted.  The background colour of their cells is purple:
      light purple when the constraint's determinant is strictly below
      a maximum limit, medium purple when it is right on the limit, and
      dark purple when it is over the maximum limit or below the minimum
      limit.  These colours take priority over all other colours.

      The font of each entry attempts to summarize the state
      of the event resource constraints that apply to the event
      resource depicted by the entry.  Roman indicates that all
      are satisfied, Bold indicates that at least one is not
      satisfied.  Italic indicates that the assignment could be
      removed without cost to any event resource constraints, and
      so is arguably consuming resource workload unnecessarily.
      Bold-Italic combines the meaning of Bold and Italic.  Italic
      and Bold-Italic entries may be highlighted further by a light
      yellow cell colour (see above).

2 June 2026.  Decided to leave changes to the way constraints are
  displayed by HSEval on the back burner for now.  I'm not sure
  what I want, I'm not sure that what I have is bad.

  Considering workload-balanced repairs, as opposed to duration-balanced
  repairs.  Added KheMTaskSetSliceTotalWorkload.

3 June 2026.  Working on defining ao->duration_is_tight and
  ao->workload_is_tight.  We don't worry about whether tasks
  are needed or not; we simply compare the actual workload
  of each resource with its maximum workload, and if it is
  within 20% (say) of the maximum, we count it as a case of
  tight demand.  Then if most resources (say 50%) are cases
  of tight demand, then we say that workload is tight.
  I've documented this in a new subsection of the resource
  supply and demand section of the structural resource solvers
  chapter.  It's audited, implemented, tested, and working.

4 June 2026.  Enhanced KHE_BALANCED_RESOURCE_SWAP_ITERATOR to
  balance either busy times or workload, depending on which
  is tight.  All written and audited and under tests.  First
  results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.27755 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.28828 0.28965 0.30138 0.30319 0.30646 0.30867 0.31672 0.33089
    ] 0.28828 is best cost (first diversifier 2)

  This is better than the 0.33853 I was getting before, although
  not dramatically better.  I guess I need to press on and add
  workload stuff to the balanced assign and unassign iterators.
  But anyway, here is a 30-minute run, just for fun:

    [ "COI-MER", 8 threads, 8 solves, 30.0 mins:
      0.13410 0.14868 0.19116 0.19711 0.19874 0.20189 0.20787 0.21138
    ] 0.13410 is best cost (first diversifier 2)

  And here is a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.09978 0.10194 0.10650 0.10822 0.11053 0.11057 0.11317 0.11421
    ] 0.09978 is best cost (first diversifier 2)

  This is encouraging, because the Misc solution has cost 0.07081,
  which gives us rel = 1.40, which is on the way to being decent.

5 June 2026.  Enhanced KHE_BALANCED_RESOURCE_ASSIGN_ITERATOR.  All
  done, have clean compile.  KHE_BALANCED_RESOURCE_UNASSIGN_ITERATOR
  is next.

  It's a mess because there are three booleans:

     assigned r vs not assigned r
     duration vs workload
     prefix vs suffix

  But I think the best way forward is to have four functions,
  (assigned r vs not assigned r) x (prefix vs suffix), with
  duration vs workload handled within each function.  The
  way the functions are used makes that the best option.

6 June 2026.  Finishing off the changes to the balancing
  iterators today.  All done, ready to audit and test.

7 June 2026.  Audited the changes to the balancing iterators.  All
  done and ready to test.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.26877 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.27548 0.29216 0.29751 0.29899 0.30177 0.30179 0.30842 0.32721
    ] 0.27548 is best cost (first diversifier 2)

  This is better than the 28828 that I was getting on 4 June, but
  sadly not a lot better.  Here is a 30-minute run:

    [ "COI-MER", 8 threads, 8 solves, 30.0 mins:
      0.12943 0.15687 0.15792 0.16123 0.16543 0.16816 0.17017 0.17433
    ] 0.12943 is best cost (first diversifier 5)

  Again, this is somewhat better than the 30-minut run from 4 June.
  So let's try a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.09337 0.09387 0.09435 0.09468 0.09563 0.09977 0.10159 0.10320
    ] 0.09337 is best cost (first diversifier 4)

  Once again this is better than 4 June.  Compared to the Misc
  solution which has cost 0.07081, it has rel = 1.31.
  Here is the Misc solution:

    Summary (Misc)                               Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  and here is the KHE26 solution:

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (8 points)             160
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (47 points)                  3980
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (215 points)                   497
    -------------------------------------------------------------
      Grand total (145 points)                               9337

  Many of these categories are in good shape.  The only real
  problem is the limit busy times constraints, although even
  there the points are similar, just the cost is worse.  The
  problem is many violations of day or shift on requests, so
  this is where the focus needs to go.

8 June 2026.  I need to look into why the KHE26 solution has so
  many violations of day and shift on requests.  These seem to
  be the biggest stumbling block at the moment.  For practical
  reasons I need to go back to 5-minute runs:

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (21 points)            410
    Cluster Busy Times Constraint (9 points)                 2700
    Limit Busy Times Constraint (124 points)                13640
    Limit Workload Constraint (4 points)                     2800
    Limit Active Intervals Constraint (61 points)            7800
    Limit Resources Constraint (245 points)                   771
    -------------------------------------------------------------
      Grand total (145 points)                              28121

  The day or shift on requests all have weight 10, and by their
  nature their cost is either 0 or 10.  This mans that there are
  1,364 defects (multiple defects per point of application).  So
  many defects, it would be better to avoid them in the first
  place.  Look at this, for example:

    TimeOn-Nurse987080-s10/Nurse987080:  10 * Linear(
      1 - 0 1Sat11;
      1 - 0 2Sun11;
      1 - 0 2Wed3;
      1 - 0 2Wed11;
      1 - 0 2Thu3;
      1 - 0 2Thu11;
      1 - 0 3Thu3;
      1 - 0 4Sun11;
      1 - 0 4Wed11;
      1 - 0 4Thu3;
      1 - 0 4Thu11;
      1 - 0 4Fri3;
      1 - 0 5Thu3;
      1 - 0 5Sat11;
      1 - 0 6Thu3;
      1 - 0 6Fri3
    )

  Some seem to contradict each other.  How can Nurse987080 be busy
  during both 2Wed3 and 2Wed11?  The best Misc solution also has a
  defect for this nurse on 2Wed:

    TimeOn-Nurse987080-s10/Nurse987080: 10 * Linear(
      1 - 0 1Thu3;
      1 - 0 1Fri3;
      1 - 0 2Wed11;
      1 - 0 2Thu11;
      1 - 0 3Thu3;
      1 - 0 4Thu3;
      1 - 0 4Fri3;
      1 - 0 5Thu3
    )

  Ditto on 2Thu and 4Thu.  So there is a contradiction here
  and some defects are unavoidable.  Actually it could be
  interpreted as saying "I want to work on either 2Wed3 or
  2Wed11".  It's just that the encoding always produces
  at least one cost.

  We need to look into these time on requests and see what we
  can do about encouraging time sweep to satisfy more of them.
  They are swamping the ejection chain algorithm, I believe.
  (I need to do a two-hour run some time, to verify that.)
  Could we preassign them before running time sweep?  Would
  that even help?

  Could I recode these contradictory times so that we ask
  for at least one of two times?  As it stands we are
  probably perpetually trying to remove one or the other.
  We could be wasting a lot of time doing that.

  Group together monitors that contradict each other, but
  add a cost_delta to the group monitor, so that before
  reporting its cost it always subtracts cost_delta.  In
  our case this would be 10.  So then when it reports a
  cost it can only be when both monitors have a cost.
  Need to make sure that the group monitors are defects,
  not the individual monitors.  This all fits a familiar
  pattern, only the cost_delta is new.

  I've verifed that khe_se_focus.c will handle group
  monitors of type KHE_SUBTAG_LIMIT_BUSY_TIMES correctly,
  provided someone else makes them (there are no cases
  at present where anyone is making group monitors of
  this type, so there is no danger of clashes - not
  true, KheGroupResourceType in khe_sm_correlation.c
  makes them, but only for preassigned resource types).

  I've updated KheLimitBusyTimesGroupAugment so that it tries
  to repair each of defects which are children of the group
  monitor, in turn.  No problems there.

  Added cost adjustment to group monitors.  All done,
  documentation, interface, and implementation, and audited.

  Here's a two-hour run:

    [ "COI-MER", 8 threads, 8 solves, 120.0 mins:
      0.08102 0.08270 0.08312 0.08345 0.08373 0.08383 0.08460 0.08586
    ] 0.08102 is best cost (first diversifier 2)

  This is very impressive, rel = 8102 / 7081 = 1.14.  But we
  need to get there faster.

  Added break_up_monitors parameter to KheSolnMake.  But I'm
  not using it yet, and I haven't yet changed the documentation
  of KheSolnMake or the many other public functions that now
  also have a break_up_monitors parameter.

9 June 2026.  Testing break-up monitors.  They seem to be working:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.30099 ]

  There are 122627 break-up monitors in COI-MER.

  Back to working on khe_sm_correlation.c.  I am now grouping
  the conflicting monitors, but I haven't added any group
  monitors yet.  I've verified, for the first resource
  (Nurse969084), that each day with a conflict appears as
  a defect in the best Misc solution.  So all well so far.

  Now building group monitors.  First test results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.25421 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.25642 0.27390 0.28261 0.29327 0.29480 0.30978 0.31330 0.32162
    ] 0.25642 is best cost (first diversifier 6)

  The single run is better, the best of 8 is also better than I was
  getting before (i.e. 0.27548 on 7 June).  Here is a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.09011 0.09389 0.09758 0.09831 0.09865 0.10022 0.10151 0.10184
    ] 0.09011 is best cost (first diversifier 2)

  which is rel = 1.27.  Somewhat better than the previous 60-minute run,
  on 7 June, which produced 0.09337.

  I've now documented break_up_monitors in general, and also for
  limit busy times monitors.  I still have to document the
  correlation grouping application.

10 June 2026.  Finished documenting negative correlation grouping.
  I've also audited the implementation to make sure that it and
  the documentation agree (including about AllowZero).  So
  negative correlation grouping is all done.  And I've also
  changed the monitor grouping in khe_sm_correlation.c so
  that it uses a solution adjuster.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.25915 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.26367 0.27442 0.27563 0.28417 0.29327 0.30611 0.31266 0.32224
    ] 0.26367 is best cost (first diversifier 6)

  This is just a bit worse than what we were getting.  I'm also
  worried that the fan was running during the single-threaded run.
  Has something gone wrong?  I'm now sourcing a separate arena
  from soln for augment options and their soln adjusters, etc.:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.25671 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.24568 0.27278 0.28271 0.29327 0.29400 0.30752 0.30874 0.32162
    ] 0.24568 is best cost (first diversifier 6)

  This is the best result so far for best of 8 in 5 minutes,
  although rel = 3.46 is still not a great result.  So let's
  try another 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.09059 0.09235 0.09272 0.09402 0.09760 0.10028 0.10168 0.10254
    ] 0.09059 is best cost (first diversifier 2)

  This is slightly worse than the previous 60-minute run (9 June).
  The second-best solution here is better.

11 June 2026.  Back to grinding down COI-MER.  Here is the usual
  run with 8 threads for 5 minutes:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.24568 0.27082 0.28261 0.29327 0.29472 0.30752 0.30874 0.32162
    ] 0.24568 is best cost (first diversifier 6)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (21 points)            390
    Cluster Busy Times Constraint (7 points)                 2500
    Limit Busy Times Constraint (111 points)                11770
    Limit Workload Constraint (4 points)                     2800
    Limit Active Intervals Constraint (53 points)            6500
    Limit Resources Constraint (219 points)                   608
    -------------------------------------------------------------
      Grand total (145 points)                              24568

  although a better guide might be the result of one of the earlier
  longer runs, where things were pretty good except for an extra
  2000 points' worth of limit busy times defects, which were caused
  by shift or day on defects.

  Changed from group monitor cost adjustment to monitor lower bound
  adjustment.  All done from top to toe, including changing
  khe_sm_correlation.c and documenting everything.  First tests:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.32195 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.26828 0.27992 0.28570 0.29725 0.30381 0.33755 0.33867 0.35123
    ] 0.26828 is best cost (first diversifier 2)

  These seem significantly worse than what I was getting before
  (e.g. at the start of today), although the second best is very
  close.  Can't think that anything could be wrong.

  Here's another 8-thread 5-minute run, this time with a random
  offset when we are choosing an mtask to assign to:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.26690 0.27694 0.27986 0.29735 0.30692 0.33755 0.33867 0.35181
    ] 0.26690 is best cost (first diversifier 2)

  This is marginally better, but still not as good as I was getting
  earlier today.  Still, it's a better plan and I'm sticking with it.
  Here's a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08851 0.09222 0.09587 0.09589 0.09594 0.09721 0.09744 0.10124
    ] 0.08851 is best cost (first diversifier 2)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (12 points)            180
    Cluster Busy Times Constraint (3 points)                 2100
    Limit Busy Times Constraint (46 points)                  3270
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (4 points)              400
    Limit Resources Constraint (236 points)                   501
    -------------------------------------------------------------
      Grand total (304 points)                               8851

  which is rel = 1.24 and a new best for KHE.  Virtue rewarded.
  And here is the best Misc solution again:

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

12 June 2026.  Thinking about how to find which parts of the cycle
  are linked by being in the same workload limit region.  I did
  consider traversing all limit workload constraints, but then I
  began to wonder whether they were adjacent in the instance,
  and now I'm looking into cases where where traverse all
  constraints in order to find those or a particular type:

    khe_cycle_meet.c:397:     to find all link events constraints
    khe_instance.c:996:       ditto
    khe_sl_layer_tree.c:52:   about half the constraints accessed
    khe_sl_layer_tree.c:964:  just two types accessed
    khe_sm_general_solve:193: just two kinds (the splits)
    khe_sm_matching.c:347:    to find all link events constraints
    assign by history:1247    limit active intervals constaints
    khe_sr_dynamic_vlsn.c     cluster busy times constraints

  and so on.  There are many examples.  It would cost us very
  little to add functions

    KheInstanceConstraintOfTypeCount(KHE_INSTANCE, KHE_CONSTRAINT_TYPE)
    KheInstanceConstraintOfType(KHE_INSTANCE, KHE_CONSTRAINT_TYPE, int i)

  It would be one array per constraint type, but so what?  We already
  have KheInstanceConstraintOfTypeCount.  I've added these functions,
  and updated all source files that call KheInstanceConstraintCount
  to call these ones instead, that is, when they are searchin for
  a particular type of constraint.  I've done some testing and it
  all seems to be working:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.26790 0.27544 0.28102 0.29944 0.30611 0.33758 0.33928 0.35366
    ] 0.26790 is best cost (first diversifier 2)

  Not that the result are any better.  I suppose it won't really run
  faster, but it feels better this way.  60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08959 0.09296 0.09406 0.09644 0.09687 0.09712 0.09876 0.10005
    ] 0.08959 is best cost (first diversifier 2)

  Slightly worse than the 8851 of 11 June, but respectable.

  I've decided to find frame intervals based on limit workload
  constraints, which are now easily accessible.  Have to start
  from scratch with a new solver for it.  So far I have done
  the documentation and created file khe_sr_frame_partition.c,
  with some code in it.

14 June 2026. 

  I've noticed, more or less by accident, that a run of the
  ejection chain solver with tight workloads only happens
  towards the end of the run - it must be the second repair.
  I would have thought that the first repair was tight as well.
  Yes, the first repair has many lines like this:

    KheWorkloadSupplyIsTightForResource(soln, Nurse3041, 0.9) =
      false (busy 60.0, avail 240.0)
    KheWorkloadSupplyIsTightForResource(soln, Nurse1090, 0.9) =
      false (busy 60.0, avail 192.0)

  And in fact none of the resources are considered tight at this
  point.  I guess that just means that the time sweep solver is
  not incentivised to produce tight solutions.  But on the second
  repair, things are very much tighter:

    KheWorkloadSupplyIsTightForResource(soln, Nurse969014, 0.9) =
      true (busy 220.0, avail 240.0)
    KheWorkloadSupplyIsTightForResource(soln, Nurse987080, 0.9) =
      true (busy 192.0, avail 192.0)

  and in fact all but two of the resources are tight.

  I suppose this means that ideally we would start without
  balancing but then switch to balancing part-way through.
  Not easy to organize; the simple way would be to call rec
  twice.

  The frame partition solver is all written, tested, and documented,
  including documenting the simple-minded algorithm used to implement it.
  I've also altered the three balanced iterators to obtain and use
  these partitions.  All done and ready to test.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.29677 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.25247 0.26949 0.27128 0.27788 0.28584 0.34462 0.34940 0.36251
    ] 0.25247 is best cost (first diversifier 2)

  Apart from the 0.24568 from 11 June, which is looked more and
  more like an outlier (the second best was 0.27082), this is
  the best so far for 8 threads in 5 minutes.  So it seems to
  be working.  Now here is "rec, rec":

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.26850 0.26851 0.27799 0.28707 0.28878 0.31504 0.33170 0.35306
    ] 0.26850 is best cost (first diversifier 6)

  Not quite as good, curionsly, so we'll leave that out.  OK, time
  for a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08589 0.08884 0.09120 0.09334 0.09339 0.09462 0.09495 0.09584
    ] 0.08589 is best cost (first diversifier 2)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (13 points)            220
    Cluster Busy Times Constraint (3 points)                 2100
    Limit Busy Times Constraint (45 points)                  2940
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (4 points)              400
    Limit Resources Constraint (221 points)                   529
    -------------------------------------------------------------
      Grand total (289 points)                               8589

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  The best here is better than 11 June, which was:

    11 June:
    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08851 0.09222 0.09587 0.09589 0.09594 0.09721 0.09744 0.10124
    ] 0.08851 is best cost (first diversifier 2)

  and better than every other 60-minute run.  So this is a win.
  Here rel = 1.21.

15 June 2026.  Now for something different.  It seems clear, comparing
  the KHE26 and Misc tables above, that the remaining issue is the
  limit busy times defects:  their KHE26 cost is 2940, their Misc cost
  is 1960.  If we could get their KHE26 cost down to the Misc cost, we
  would have rel = (8589 - 2940 + 1960) / 7081 = 7609 / 7081 = 1.07.

  In the best Misc solution, the 1960 points of limit busy times
  defects are almost all from day or shift on requests (just one
  unwanted pattern, costing 100).  The same is true for the KHE26
  solution, so we need to focus on day or shift on requests.  These
  are all, or virtually all, for specific times.  They should be
  easy to satisfy at the start, perhaps that is the way to go.  Or
  look closely at why time sweep is not doing better on them.  Is
  it to do with time sweep not including optional tasks?  Probably
  not, there are only 93 optional tasks, i.e. about 2 per resource.

  There is some weird stuff in the optimal timetable of Nurse969083:

    solving resource {Nurse969083} on days 0-27
    +---------+---------+---------+---------+---------+---------+---------+
    | D1      | D1      | D1      | D1      | D1      | N       |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         | D1      | D1      | D1      | D1      | D1      | N       |
    +---------+---------+---------+---------+---------+---------+---------+
    | D1      | D1      | D1      | D1      | D1      | N       |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         | D1      | D1      | D1      | D1      | D1      | N       |
    +---------+---------+---------+---------+---------+---------+---------+
    |         |         |         |         |         |         |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         |         |         |         |         |         |         |
    +---------+---------+---------+---------+---------+---------+---------+

    solving resource {Nurse969083} on days 28-41
    +---------+---------+---------+---------+---------+---------+---------+
    | D1      | D1      | D1      | D1      | D1      | N       |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         | D1      | D1      | D1      | D1      | D1      | N       |
    +---------+---------+---------+---------+---------+---------+---------+
    | D1      | D1      | D1      | D1      | D1      | N       |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         | D1      | D1      | D1      | D1      | D1      | N       |
    +---------+---------+---------+---------+---------+---------+---------+
    | D1      | D1      | D1      | D1      | D1      | N       |         |
    +---------+---------+---------+---------+---------+---------+---------+
    |         | D1      | D1      | D1      | D1      | D1      | N       |
    +---------+---------+---------+---------+---------+---------+---------+

  The weirdness is that D1 shifts can occur in sequences of length at
  most 1 (soft cost 100, Constraint:74), so that initial sequence of
  five D1 shifts has cost 100 * 4 = 400.  Why would that happen?
  Nurse1040 also has some weird stuff.  It seems to be totally
  ignoring the day or shift on requests.  In fact it is really
  hard to believe that the solutions we are getting are optimal.

  Could there be too many choices, could we be getting sub-optimal
  solutions?  I think that's very probable.  So I've decided to
  bypass rds and call rts instead.  Best of 8, 5 minutes:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.25653 0.26786 0.27009 0.27139 0.27262 0.27314 0.28054 0.28614
    ] 0.25653 is best cost (first diversifier 4)

  This compares with 0.26850 the previous time we did this run.  So
  I've decided to switch permanently to rts.  Here's a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.09053 0.09148 0.09152 0.09340 0.09510 0.09592 0.10035 0.10188
    ] 0.09053 is best cost (first diversifier 4)

  which is rel = 1.27.  Not quite as good as the 8851 of 11 June, but
  close, and the second-best is better:

    11 June:
    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08851 0.09222 0.09587 0.09589 0.09594 0.09721 0.09744 0.10124
    ] 0.08851 is best cost (first diversifier 2)

  Trying replacing rts by rrq (KheSolnAssignRequestedResources).  I've
  found that rrq makes over 803 assignments, which over 54 nurses is
  an average of almost 16 assignments per nurse.  Remarkable when
  there are only 42 days in the cycle.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.27058 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.27743 0.28119 0.28185 0.29439 0.29543 0.29703 0.29846 0.30578
    ] 0.27743 is best cost (first diversifier 5)

  These are not great results, but anyway let's press on and try
  a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.08641 0.08938 0.09005 0.09045 0.09078 0.09085 0.09328 0.09411
    ] 0.08641 is best cost (first diversifier 6)

  This is good (rel = 1.22) but not quite as good as 14 June (8589).
  Going back to time sweep for now anyway.

16 June 2026.  I've decided to try an initial solver which starts
  from the result of KheSolnAssignRequestedResources and then
  uses a fairly simple constructive heuristic to extend the
  solution as far as possible (until no further assignments
  that reduce cost can be found).

  There seems to be a bug, causing lots of tasks to have empty
  domains and thus preventing assignments.  I've worked out
  that KheReduceTaskDomains is doing it, but I don't know the
  details yet.

  Here's an algorithm for assigning tasks heuristically:

    For each resource r in turn:
      For each proper root task t assigned r:
        See what unassigning r from t does to total cost
      For each unassigned day of r:
        For each unassigned task t on day:
	  See what assigning r to an unassigned task t on day does
      If the best unassignment or assignment reduces cost, do it and repeat
      until no unassignments or assignments reduce cost

  OK, the bug is caused by rtr (KheReduceTaskDomains).  Needs looking into.
  I think that khe_sr_reduce_domains.c, line 646 is probably the culprit,
  since the complement of Skill-1 is probably empty.

  KheReduceTaskDomains is causing lots of tasks to get empty
  domains.  I need to understand exactly what KheReduceTaskDomains
  is doing before I change it.  But here are some clear points:

  * KheReduceTaskDomains was designed with reference to other
    instances (the Ikegami instances, see 17 April 2026) and
    is not currently working for COI-MER.

  * KheReduceTaskDomains needs to take time-on requests into
    account.  If someone requests a time on, we don't want to
    lock them out of that because of KheReduceTaskDomains.

  * When a limit resources constraint spans two (say) times, we
    can't know which of the times is best to reduce and which
    is best to keep.  At present we are not doing it well.  We
    might do better to spread the reductions across the times,
    although there is no reason why half-and-half should be best.
    Or perhaps we should weaken the reductions so that they only
    apply if the constraint covers a single time.  This would
    handle most instances but leave COI-MER in a looser state.
    The Ikegami instances have no constraints that cover two times.

  * When a task's domain has already been reduced, as in 1Sun:S12.22
    and 1Sun:N.22, it seems like a poor choice to reduce it again.
    In particular, if it's a minimum limit, then reducing it to
    empty will violate that limit.  Are we handling the monitors
    by largest cost first?  We should, and then we should not
    change things in ways that wreck our plans for earlier monitors.

17 June 2026.  Implemented the changes to KheReduceTaskDomains.
  It's still not taking time on requests into account, but the
  rest is done and ready to test.

18 June 2026.  Audited KheReduceTaskDomains and its documentation.
  All good so I've started testing.  When run on MER it finds no
  domain reductions at all, which is probably correct because the
  limit resources monitors' tasks are not acceptable.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.11309 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.11309 0.11540 0.11563 0.11828 0.11900 0.11922 0.12190 0.13623
    ] 0.11309 is best cost (first diversifier 2)

  This is a huge improvement on previous 5-minute runs, and indeed
  worth quoting a relative cost for, at last:  rel = 1.59.  Now for
  a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07680 0.07761 0.07766 0.07928 0.08004 0.08062 0.08141 0.08274
    ] 0.07680 is best cost (first diversifier 2)

  Best so far, rel = 1.08.  Who said COI-MER was hard to solve?
  But I need to get more bang out of the 5-minute solve.  So
  let's see what yourself tells us about where the time is going.
  OK, I've verified that virtually all of the time is going to
  rec (the main exception is 27 secs to rdv), which is as it
  should be.  So now I need to speed things up inside rec.  But
  how?  By focusing on the high-cost defects?

  Here is the result of an 8-thread 5-minute run:

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.11230 0.11417 0.11467 0.11671 0.11911 0.12531 0.12603 0.12654
    ] 0.11230 is best cost (first diversifier 7)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (14 points)            220
    Cluster Busy Times Constraint (7 points)                 2500
    Limit Busy Times Constraint (50 points)                  4410
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (12 points)            1200
    Limit Resources Constraint (190 points)                   500
    -------------------------------------------------------------
      Grand total (276 points)                              11230

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  This is rel = 1.58.  As usual the main problem is with limit busy
  times defects, although there are also extra cluster busy times
  and limit active intervals defects.  But if we could reduce the
  KHE26 limit busy times defects down to the Misc level, that would
  be rel = (11230 - 4410 + 1960) / 7081 = 8780 / 7081 = 1.23.

  And it's reasonable to be concerned about the 190 limit resources
  constraint defects taking up a lot of time.  That is 68% of the
  points, for just a small fraction (4%) of the cost.  Could these
  be grouped?  There is at least one example, DemandConstraint:3A/EGDC:81
  and DemandConstraint:3A/EGDC:162, where the exact same tasks are
  being monitored (No, not true); and there are others, such as
  DemandConstraint:3A/EGDC:80 and DemandConstraint:3A/EGDC:160,
  where one of the monitored groups is a subset of the other.  Fix
  one and you are likely to fix the other, so what about grouping them?

  We are currently grouping assign resource monitors that monitor
  the same tasks, and prefer resources monitors that monitor the
  same tasks with the same domains, but we are not grouping limit
  resources monitors.

19 June 2026.  Thinking about yesterdays's ideas.  I'm trying a
  tweak to ejection chains where, when it reaches the exact
  halfway point along the list of defects, if at least one
  has been fixed then it returns to the top of the list.  This
  is intended to give more time to repairing defects that have
  higher cost (because the list is sorted by decreasing cost).
  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.16753 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.14339 0.14551 0.15117 0.16155 0.17333 0.18242 0.18494 0.19960
    ] 0.14339 is best cost (first diversifier 5)

  The 8-thread 5-minute result compares poorly with yesterday's 11230.
  I guess though that it shows that fiddling with the ejection chain
  algorithm can have a significant effect.  Why should what we are
  doing now be best possible?

  So now I'm deleting "if( KheMonitorVisitNum(d) > curr_successful_visit )"
  to see if that helps:

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.11239 0.11239 0.11921 0.12271 0.12361 0.12989 0.13056 0.13320
    ] 0.11239 is best cost (first diversifier 4)

  This is worse, although only very marginally worse.  And now I
  am halving max_augments (from 200 to 100):

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10684 0.11332 0.11869 0.12062 0.12305 0.12670 0.13217 0.13679
    ] 0.10684 is best cost (first diversifier 7)

  This is a significant improvement in the best solution, but the
  second best is worse, so arguably no improvement overall.  And
  And now I am halving max_augments again (from 100 to 50):

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10865 0.11698 0.11736 0.11863 0.12060 0.12753 0.13076 0.13747
    ] 0.10865 is best cost (first diversifier 3)

  This is definitely worse than 100.  Now I am returning to 200
  and fiddling with es_max_repairs.  The default value is INT_MAX,
  now I am trying 200:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10573 0.11505 0.11532 0.11731 0.12210 0.12723 0.14896 0.16498
    ] 0.10573 is best cost (first diversifier 3)

  Not a consistent improvement.  What about es_max_repairs=400?

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10186 0.10425 0.11092 0.11224 0.11312 0.12377 0.13850 0.16024
    ] 0.10186 is best cost (first diversifier 3)

  This seems good.  Suppose we stick with this.  We have rel = 1.43.
  And es_max_repairs=600:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10931 0.10973 0.11213 0.11537 0.12441 0.12764 0.13943 0.15654
    ] 0.10931 is best cost (first diversifier 3)

  Not quite as good.  One more try, es_max_repairs=500:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10570 0.10651 0.11825 0.11873 0.11938 0.11952 0.14363 0.16011
    ] 0.10570 is best cost (first diversifier 3)

  Again, not quite as good as es_max_repairs=400.  Now es_max_repairs=300:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10555 0.10635 0.11846 0.11991 0.12460 0.13976 0.14274 0.15502
    ] 0.10555 is best cost (first diversifier 7)

  OK, it looks like es_max_repairs=400 is the go.  So now I am
  fiddling with the schedule, trying es_schedule="1+;2+;u-".

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10345 0.10471 0.11087 0.11412 0.11861 0.12240 0.13902 0.15519
    ] 0.10345 is best cost (first diversifier 3)

  Not quite as good.  Taking it away again.  Here's a 60-minute run:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 34.9 mins:
      0.09503 0.09899 0.10136 0.10213 0.10360 0.10496 0.10529 0.10921
    ] 0.09503 is best cost (first diversifier 3)

  This (rel = 1.34) is far worse than the 1.08 I was getting earlier.
  But notice that it is a 35-minute run, not a 60-minute run.  Let's
  go back to the unlimited es_max_repairs with a 60-minute run and
  make sure we haven't lost anything:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07914 0.07922 0.08000 0.08016 0.08038 0.08103 0.08183 0.08293
    ] 0.07914 is best cost (first diversifier 7)

  Not quite as good as the previous 7680 (18 June) but all right;
  rel = 1.1.  Might as well do a two-hour run while we are at it:

    COMPROMISED BY BUG
    [ "COI-MER", 8 threads, 8 solves, 111.7 mins:
      0.07838 0.07906 0.07924 0.07971 0.08014 0.08123 0.08222 0.08277
    ] 0.07838 is best cost (first diversifier 6)

  which is rel = 1.10.  Still short of 7680, but all right.  These
  last few results may be compromised by a failure to compile.  I
  need to redo them.  Bug-free from here on.  8 threads 5 minutes:

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.11084 0.11144 0.11467 0.11470 0.11506 0.12479 0.12668 0.13381
    ] 0.11084 is best cost (first diversifier 1)

20 June 2026.  I've been looking through the timetables generated
  by rrq alone, i.e. people's requested times.  They are not a
  good basis for solving, there are contradictions and workload
  overloads etc.  I think they represent preferred individual
  times more than a preferred overall timetable.  So it makes
  sense to ignore them initially and just allow them to influence
  things as we go along, similarly to soft unavailable times
  constraints but for time on rather than time off.  The bottom
  line is, these requested times are not a good guide to what
  is going on.

21 June 2026.  8 threads 5 minutes:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10890 0.11008 0.11293 0.11457 0.11711 0.11724 0.12423 0.12953
    ] 0.10890 is best cost (first diversifier 3)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (15 points)            260
    Cluster Busy Times Constraint (7 points)                 2500
    Limit Busy Times Constraint (49 points)                  4340
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (8 points)              900
    Limit Resources Constraint (200 points)                   490
    -------------------------------------------------------------
      Grand total (282 points)                              10890

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  This is rel = 1.53.  We really need something more.  If we could
  reduce the limit busy times defects to the Misc value, we would
  have rel = (10890 - 4340 + 1960) / 7081 = 8510 / 7081 = 1.20.

  Here is what happens if you replace rts by rrq, so that the
  initial solution to be repaired is just the requested assignments:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10292 0.10358 0.10380 0.10609 0.11047 0.11227 0.11857 0.12700
    ] 0.10292 is best cost (first diversifier 1)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (15 points)            260
    Cluster Busy Times Constraint (4 points)                 2200
    Limit Busy Times Constraint (45 points)                  4010
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (8 points)              900
    Limit Resources Constraint (196 points)                   522
    -------------------------------------------------------------
      Grand total (282 points)                              10292

  It's better but not much better, and would not work for other
  instances (so we'd need a test:  if there are a lot of requests,
  then use rrq, else use rts.  Not desirable for such a small gain.
  It's noticeable too that the main issue addressed by changing to
  rrq, namely the cost of limit busy times defects, improves only
  modestly, from 4340 to 4010.

  I think we are going to have to group limit resources monitors.
  It's not great but it is something to try.  We could randomly
  search for a single defect forwards or backwards.  Do it for
  elements of the same constraint whose events are in a subset
  relationship.

  KheEventResourceSigTypedCmp determines which event resources
  go into the same class (those which monitor the same tasks).
  This does not suit limit resources monitors so we will do
  them quite separately.

  I've now written code that groups event groups when they
  come from the same constraint and are subsets of each
  other.  I'm getting stuff like this:

    [ EventGroupClass:
      EventGroup EGDC:60{3Thu:D1, 3Thu:D, 3Thu:D12}
      EventGroup EGDC:120{3Thu:D1, 3Thu:D, 3Thu:D12, 3Thu:D22}
    ]

  and quite a lot of it too.

  I've been reminced about the relationship between DemandConstraint:3A,
  DemandConstraint:3B, and DemandConstraint:3C.  They are in fact
  groupable, but there are no 3B or 3C defects (or indeed any B or C
  defects), so such a grouping would not help solve COI-MER.

22 June 2026.  I've implemented some new functions in the platform:
  KheConstraintOfTypeIndex, KheSolnAddLimitResourcesMonitor, and
  KheLimitResourcesConstraintMonitor.  The purpose was to implement
  the last of these, which allows a limit resources monitor to be
  found quickly, given its constraint and event group index.

  Also finished the implementation of limit resources monitor
  grouping, in khe_sm_correlation.c.  All tested and working.
  And I've updated the handling of limit resources group
  monitors in khe_se_solvers.c to search the list of
  children starting at a random point (but to only try one).
  First results, including a 60-minute run:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10610 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10798 0.10974 0.11024 0.11199 0.11269 0.11927 0.12142 0.12476
    ] 0.10798 is best cost (first diversifier 1)

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07763 0.07798 0.07819 0.07828 0.07842 0.07853 0.08045 0.08141
    ] 0.07763 is best cost (first diversifier 1)

  This last result is rel = 1.09.  It's exasperating to see that the
  8-thread solve is doing worse than the single-thread solve.  In any
  case these are not wonderful results.  Without grouping limit resources
  monitors we get this:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10392 0.10707 0.10871 0.11335 0.11383 0.11555 0.11708 0.12087
    ] 0.10392 is best cost (first diversifier 6)

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07641 0.07927 0.07954 0.07962 0.08029 0.08047 0.08055 0.08131
    ] 0.07641 is best cost (first diversifier 3)

  which is clearly superior.  So much for grouping limit resources
  monitors.  Still, the 5-minute run is quite poor (rel = 1.46).
  The 60-minute run is quite close to its 1.05 target (rel = 1.07).

  It's fair to be concerned about the 190 limit resources constraint
  defects taking up a lot of time.  That is 68% of the points, for
  just a small fraction (4%) of the cost.  But I've just shown that
  grouping them in the most plausible way makes things worse.  So
  it's looking as though we won't be able to do anything there.

23 June 2026.  Here is an 8-thread 5-minute run using
  es_schedule="1+;20-":

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10261 0.10703 0.11204 0.11394 0.11504 0.11660 0.11764 0.12128
    ] 0.10261 is best cost (first diversifier 1)

  It's marginally better, probably not significantly (the third best
  is worse).  And here is a run using es_schedule="u-":

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.20247 0.21088 0.21630 0.22218 0.22295 0.22828 0.23775 0.24525
    ] 0.20247 is best cost (first diversifier 2)

  This is remarkably bad, but we won't pause to look into why; but
  it does show how changing the ejection chains setup can change
  the outcome dramatically.  And here is es_schedule="2+;u-":

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10395 0.10591 0.10687 0.10765 0.10789 0.11057 0.11489 0.12357
    ] 0.10395 is best cost (first diversifier 6)

  Marginally worse.  It looks like es_schedule="1+;u-" is the go.
  Returning to that, here is a run where we don't sort the defects:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10089 0.10943 0.10982 0.11077 0.11116 0.11246 0.11598 0.11942
    ] 0.10089 is best cost (first diversifier 5)

  Amazing, what we have here is a significant improvement.  Presumably
  it comes from the time saved by not sorting.  Plus turning off stats:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10515 0.10719 0.10941 0.11028 0.11180 0.11226 0.11484 0.11557
    ] 0.10515 is best cost (first diversifier 5)

  Actually it's looking like not sorting produced a lucky outlier,
  so I've turned it back on.

  I've generalized KheIncreaseOrDecreaseLoadMultiRepair so that when
  it is called from KheLimitWorkloadAugment, it tries to increase or
  decrease workload, not just busy times.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10011 ]

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.10699 0.11045 0.11156 0.11182 0.11186 0.11531 0.11648 0.12347
    ] 0.10699 is best cost (first diversifier 0)

  Another exasperating case of the single thread result (10011,
  which is rel = 1.41) being better than the 8-thread result
  (10699, which is rel = 1.50).  The single thread result is
  pretty good, relative to what else we've been getting;
  the 8-thread result is quite poor.  Here's a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07676 0.07690 0.07745 0.07774 0.07781 0.07863 0.07868 0.08046
    ] 0.07676 is best cost (first diversifier 2)

  Identical to last time, basically.  So we'll keep it but without
  expecting wonders from it.

24 June 2026.  Carrying on auditing the multi-repairs.

  KheMTaskIteratorTimeGroupInit now adjusted to include only mtasks
  whose domains contain a given resource, if non-NULL.  This is useful
  in KheIncreaseLoadMultiRepair, line 8123, which is its only use.

25 June 2026.  Finished auditing the multi-repairs.  Didn't find
  anything remarkable.  Changed want_duration to use_workload throughout.

  Anyway here are the usual tests:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10096 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10689 0.10745 0.11045 0.11084 0.11156 0.11293 0.11677 0.12347
    ] 0.10689 is best cost (first diversifier 0)

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07691 0.07705 0.07745 0.07781 0.07798 0.07863 0.07871 0.08046
    ] 0.07691 is best cost (first diversifier 2)

  and the results are as usual.

26 June 2026.  Now for some experiments with option es_balancing_max.
  The default value is 12.  Let's try reducing it to 8:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10684 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10312 0.11045 0.11075 0.11134 0.11186 0.11360 0.11648 0.12347
    ] 0.10312 is best cost (first diversifier 0)

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07676 0.07690 0.07745 0.07781 0.07797 0.07863 0.07868 0.08057
    ] 0.07676 is best cost (first diversifier 2)

  This is marginally better, but not enough better to suggest a move
  to this value.  Let's try increasing it to 20:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10138 ]

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.10586 0.11021 0.11045 0.11107 0.11204 0.11478 0.11677 0.12839
    ] 0.10586 is best cost (first diversifier 7)

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07676 0.07690 0.07745 0.07781 0.07798 0.07863 0.07882 0.08046
    ] 0.07676 is best cost (first diversifier 2)

  There are differences, but they seem random.  Back to the default.

27 June 2026.  Here are some ideas and why they are not likely to do
  any good:

    (1) When finding assignable tasks, we find just one example of them, and
    in COI-MER there are different choices with different workloads.  It
    would be better to try multiple examples, surely.  So let's look into
    something - an iterator, perhaps - for that.  Although at present we
    are trying multiple *initial* mtasks--it is the widened ones that
    don't get iterated over.  KheFindAssignableMTasksInInterval is the
    main thing that needs replacing.  All this is mitigated by balancing,
    which balances workloads when that is likely to be important.

    (2) Can we have a repair that tries both a swap and an ejecting move
    A?  But not both when they would do the same thing (when the other
    resource's mtss is empty)?  Low priority though.  The problem is
    that the legal intervals for swapping are not exactly the same as
    the legal intervals for ejecting moves.

    (3) It's fair to be concerned about the 190 limit resources constraint
    defects taking up a lot of time when solving COI-MER.  That is 68%
    of the points, for just a small fraction (4%) of the cost.  But I've
    just shown that grouping them in the most plausible way makes things
    worse.  So it's looking like we won't be able to do anything there.

  Updated the function names and enum names of the various repairs, to
  bring them closer together.  All implemented with a clean compile,
  including the needed changes to KheEjectionChainEjectorMake.

28 June 2026.  Working on graphs.  I'm getting number of repairs
  graphs now as well as the cost graphs.  All good.  The repairs
  graphs are rather remarkable:  they have repairs of length 1 for
  a very long time, then (presumably when we switch to the second
  major schedule) they spike up to 40 or even 100.

  Trying es_schedule="1+;50-":

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09914 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10700 0.11204 0.11319 0.11518 0.11602 0.11931 0.11970 0.12056
    ] 0.10700 is best cost (first diversifier 0)

  Overall, no better than before; it's looking like the exasperating
  9914 (rel = 1.40) is a lucky outlier.  Anyway, here is a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07670 0.07692 0.07767 0.07794 0.07859 0.07901 0.07989 0.08234
    ] 0.07670 is best cost (first diversifier 7)

  No improvement here.  Back to the default value of es_schedule.
  
  I've got the graphs and tables working well, but I can't say that
  I'm getting any inspiration from them.

  Just for a change, and to do a long test of the graphs, here is a
  single thread 60-minute run:

    [ "COI-MER", 1 thread, 1 solve, 60.0 mins: 0.07672 ]

  Virtually as good as the best of 8.  Grr.

  According to the tabular output, the balancing operations are
  contributing virtually nothing to the solve.  So here is a
  run without them:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10886 0.10900 0.10974 0.11049 0.11142 0.11419 0.11847 0.12006
    ] 0.10886 is best cost (first diversifier 6)

  This is worse than with them, so we'll keep them.

29 June 2026.  After generating some graphs and tables, I've
  decided that they are not giving me any useful leads.

  Returning now to the traditional grinding down of COI-MER.
  Here is a standard 8-thread 5-minute run:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10905 0.11045 0.11054 0.11162 0.11275 0.11558 0.11677 0.12125
    ] 0.10905 is best cost (first diversifier 0)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (12 points)            230
    Cluster Busy Times Constraint (4 points)                 2200
    Limit Busy Times Constraint (46 points)                  3780
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (17 points)            1800
    Limit Resources Constraint (205 points)                   495
    -------------------------------------------------------------
      Grand total (282 points)                              10905

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  This is rel = 1.54 and virtually the same cost as I was getting
  on 21 June.  So what can I do about it?  The two main problems
  are limit busy times defects and limit active intervals defects.
  Most of the latter are violations of "At most 1 consecutive free
  weekend".  Can we do something about this?  Start with a whynot?

  Now visiting widened intervals in a different order which
  begins with the smallest interval, not the leftmost interval.
  It included a bug fix in existing code, not sure if that will
  change anything.  Here is the usual 5-minute runs:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10267 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10924 0.11047 0.11139 0.11191 0.11412 0.11517 0.11666 0.11799
    ] 0.10924 is best cost (first diversifier 3)

  No significant difference here.

30 June 2026.  Found a nasty bug that afflicted all three balanced
  iterators (assign, unassign, swap); it was causing the iterator
  to start work just before the end of the enclosing interval, not
  just before the start.  First runs after bug fix:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09892 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.09972 0.09986 0.10030 0.10036 0.10169 0.10187 0.10553 0.10558
    ] 0.09972 is best cost (first diversifier 3)

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (11 points)            210
    Cluster Busy Times Constraint (3 points)                 2100
    Limit Busy Times Constraint (47 points)                  3760
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (10 points)            1000
    Limit Resources Constraint (204 points)                   502
    -------------------------------------------------------------
      Grand total (278 points)                               9972

    Summary (Misc)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (10 points)            180
    Cluster Busy Times Constraint (2 points)                 2000
    Limit Busy Times Constraint (43 points)                  1960
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (3 points)              300
    Limit Resources Constraint (84 points)                    241
    -------------------------------------------------------------
      Grand total (145 points)                               7081

  The usual exasperating better result from one thread than from
  eight, but this is better than I have been getting lately, in
  fact it's a new best (I believe) for 5 minutes; rel = 1.40.

  I did a whynot on Constraint:72/Nurse852180 and it actually
  found an improvement, leading to a solution with cost

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09551 ]

    Summary (KHE26)                              Inf.         Obj.
    -------------------------------------------------------------
    Avoid Unavailable Times Constraint (13 points)            190
    Cluster Busy Times Constraint (4 points)                 2200
    Limit Busy Times Constraint (47 points)                  3450
    Limit Workload Constraint (3 points)                     2400
    Limit Active Intervals Constraint (8 points)              800
    Limit Resources Constraint (204 points)                   511
    -------------------------------------------------------------
      Grand total (278 points)                               9551


  which is rel = 1.34.  It's a freak, but still it's interesting.

  I should try some of the limit busy times whynots now.  Trying
  es_whynot_monitor_id="TimeOn-Nurse11052-s10/Nurse11052".  It
  found an improvement.  Trying TimeOn-Nurse988102-s10/Nurse988102
  but it succeeded immediately too!

  I've fiddled with the ejector to make it retry a defective
  monitor d when a repair of d succeeded but d's cost is still
  higher than its lower bound.  Originally I was only going to
  do this for limit busy times defects, but I could not get
  that to work on khe_se_solvers.c, because the target cost
  was changing.  This way it works correctly but is applied
  to all defects.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10188 ]

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.09555 0.09963 0.10012 0.10104 0.10363 0.10395 0.10402 0.10804
    ] 0.09555 is best cost (first diversifier 7)

  OK, this seems to have helped; rel = 1.34.  I've documented it
  and it is now an accepted part of the ejection chains code.
  Time for a 60-minute solve:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07726 0.07735 0.07735 0.07836 0.07839 0.07871 0.07999 0.08046
    ] 0.07726 is best cost (first diversifier 2)

  This is rel = 1.09.  Not a new best (see the 0.07641 solution,
  rel = 1.07, on 22 June) but pretty good.  And it's only the
  best which is worse than 22 June, the second best and all the
  rest are better than 22 June:

    22 June soln:
    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07641 0.07927 0.07954 0.07962 0.08029 0.08047 0.08055 0.08131
    ] 0.07641 is best cost (first diversifier 3)

  The 22 June solution was an outlier; this solution is not.

  Removed KheSolnAdjusterMonitorAddCorrelation.  All tested and
  un-documented.

1 July 2026.  I discovered a lot of old things to do buried between
  fun facts in the to do section.  So I've moved all the fun facts
  to a separate file (diary/fun_facts) and now I'm working through
  these old things to do.

  Removed two obsolete solvers (resource reassign and single
  resource solving), which allowed me to remove task finding.  The
  source files are renamed old_*.c, the makefile is updated, so is
  khe_solvers.h, and the documentation is updated (i.e. the sections
  describing this stuff are removed).  All done with a clean compile.

2 July 2026.  I've been running with rrq as the initial solver, not
  rts.  So this has compromised the last few days' results.  Returned
  to rts now, here is what I'm getting:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.10175 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.09982 0.10042 0.10092 0.10225 0.10297 0.10334 0.10432 0.10593
    ] 0.09982 is best cost (first diversifier 2)

  These results are OK, rel = 1.40, typical of where I'm at just now.

  Now using KHE_WIDEN_NONE in the KheClearIntervalMultiRepair case of
  KheLimitActiveIntervalsAugment.  First results:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.10052 0.10246 0.10289 0.10309 0.10528 0.10930 0.11143 0.11272
    ] 0.10052 is best cost (first diversifier 7)

  This is systematically worse, let's return to KHE_WIDEN_BOTH:

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.09786 0.10035 0.10079 0.10268 0.10497 0.10501 0.10857 0.10926
    ] 0.09786 is best cost (first diversifier 7)

  Working on the KheClearIntervalMultiRepair case.  Partially done:

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.09995 0.10252 0.10270 0.10383 0.10427 0.10656 0.10687 0.11594
    ] 0.09995 is best cost (first diversifier 5)

    [ "COI-MER", 8 threads, 8 solves, 5.1 mins:
      0.10008 0.10308 0.10396 0.10427 0.10587 0.10794 0.11095 0.11298
    ] 0.10008 is best cost (first diversifier 1)

  Curious, I would have thought that the second version at least would
  do better.  Anyway we'll stick with it and carry on.

3 July 2026.  Working on KHE_BALANCED_RESOURCE_EJECTING_ASSIGN_ITERATOR.
  Have clean compile, needs a careful audit, and also the internals
  of the iterator are not written yet.

4 July 2026.  Working on KHE_RESOURCE_OP_TYPE, KHE_RESOURCE_MOVE, and
  KHE_RESOURCE_MOVE_SET.  Those types are done, and the widening
  iterator is using them, giving rise to a new foreach:

    KheWideningIteratorForEachResourceMoveSet(wi, op, rms)

  which should be working now.  The next step would be to update
  the calls on the iterators, or perhaps add balancing first.

5 July 2026.  Working on adding balancing to the widening iterator.
  KheWideningIteratorNextBalanced is next.  It should be able to
  get everything it needs from its balance variable.

6 July 2026.  Working on adding balancing to the widening iterator.
  Done most of it, including getting rid of the old balancing iterators.
  I've also added monitor grouping to KheResourceMoveSetRepair.
  See the to do list for remaining things to do.

7 July 2026.  Looking at the disallow_preassigned (second-last) and
  unassign_extreme_unneeded (last) parameters of KheMTaskSetMoveResource
  and similar functions.  These are called only from khe_se_solvers.c.
  In fact, KheMTaskSetMoveResource is no longer called at all, and
  KheMTaskSetSliceMoveResource is called only from
  KheResourceEjectingMoveARepair (probably destined for removal) and
  KheResourceMoveApply.  In commented-out calls to KheMTaskSetMoveResource,
  both parameters are always true, and in commented-out calls to
  KheMTaskSetSliceMoveResource, KheResourceSwapRepair has an
  unassign_extreme_unneeded parameter which is true when it is
  called from KheResourceSwapMultiRepair.

  So it seems that both parameters are always true in practice.  The
  current plan is to get rid of disallow_preassigned, which should be
  taken care of by other means, and re-analyse unassign_extreme_unneeded.

  I've removed the disallow_preassigned parameter of the mtask resource
  assignment functions, replacing it by a disallow_preassigned_unassignments
  flag in KheMTaskFinderMake.

  I've made a plan for unassign_extreme_unneeded:  true for cases where
  both resources are non-NULL (I've documented this point) and we are
  not aiming for an exact amount of load, and false for everything else.

  Written KheMTaskSetSliceMoveResourceFromDuration etc. for finding
  the true change of load, taking unassign_extreme_unneeded into
  account.  And I've changed KheResourceMoveSetFindBalanceSet to
  use these functions, so that its result includes the effect of
  unassign_extreme_unneeded now.

  I wrote this: "In KheWideningIteratorNextBalancedMove, can we
  integrate things more?  At present we do a lot of work and then
  end with a call on KheResourceFreeForInterval, which seems later
  than ideal."  But looking more carefully at it, the lot of work
  is just finding the tasks assigned a given resource, which is
  not much.  We could integrate it but it would be messy, given
  that tasks can have different lengths, so let's leave it as is.

8 July 2026.  Working on KheIncreaseLoad2MultiRepair.  I've
  added KheTimeGroupCmpInitTwoGroups which accepts two time
  groups, I just have to use it now.

9 July 2026.  Working on KheIncreaseLoad2MultiRepair.

10 July 2026.  Working on KheIncreaseLoad2MultiRepair.  I've
  changed KheMTaskIteratorForEach to ensure that it returns
  mtasks that need assignment before mtasks that don't, so
  there is no longer a need for two passes over the iterator.

  Also finished KheIncreaseLoad2MultiRepair.  It's a bit of
  a string-and-chicken-wire production but it seems right.
  I've audited it; it's ready to test.

11 July 2026.  Found a bug with mtask sets, I was freeing
  a widening iterator (including freeing b_curr_mts) before
  b_curr_mts was initialized.  Fixed now and running better.

  Testing the new iterator code, and also the improved repairs
  for limit active intervals defects of length 2.  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09548 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.09013 0.09128 0.09204 0.09645 0.09840 0.09840 0.10197 0.10382
    ] 0.09013 is best cost (first diversifier 3)

  From memory, this is the best so far for a 5-minute run; it
  is rel = 1.27.  Here's a 60-minute run:

    [ "COI-MER", 8 threads, 8 solves, 60.0 mins:
      0.07606 0.07628 0.07712 0.07775 0.07816 0.07933 0.08098 0.08101
    ] 0.07606 is best cost (first diversifier 0)

  This is rel = 1.07.

  Now removing ordinary assignments; using ejecting assignments only:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09586 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.09224 0.09385 0.09506 0.09532 0.09607 0.09667 0.09672 0.09746
    ] 0.09224 is best cost (first diversifier 3)

  This is slightly worse, so I guess we put them back again.

12 July 2026.  Trying -flto.  I've made these changes:

    Added -flto to CFLAGS
    Deleted -g from CFLAGS (doc says incompatible with -flto)
    Changed ar to gcc-ar (doc says needed when using archives and -flto)

  I've done these things in src_platform/makefile, src_solvers/makefile,
  and src_khe/makefile.  The link steps were slower but not a problems.
  First results:

    [ "COI-MER", 1 thread, 1 solve, 5.0 mins: 0.09187 ]

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.08767 0.08934 0.09297 0.09304 0.09339 0.09603 0.09705 0.10164
    ] 0.08767 is best cost (first diversifier 3)

  This is rel = 1.23, the best so far for a five-minute run.  The
  improvement is (9224 - 8767) / 9224 = 0.04, that is, a 4%
  improvement.  Not a game changer, but definitely worthwhile.
  But then I found a nasty bug which suggests that balanced repairs
  have not been working properly.  After fixing that I got this:

    [ "COI-MER", 8 threads, 8 solves, 5.0 mins:
      0.08451 0.08523 0.08536 0.08750 0.08894 0.09194 0.09282 0.09338
    ] 0.08451 is best cost (first diversifier 3)

  which is rel = 1.19.  Now we're getting somewhere!

  I've completed a full COI run.  The results seem to be pretty
  good.  The run is without -flto, so let's do it again with -flto:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000      1.00       0.00000       1.00
    COI-Musa                0.00175      1.00       0.00175       1.00
    COI-Millar-2.1          0.00000      1.00       0.00000       1.00
    COI-Millar-2.1.1        0.00000      1.00       0.00000       1.00
    COI-LLR                 0.00301      1.00       0.00301       1.00
    COI-Azaiez              0.00000      1.00       0.00000       1.00
    COI-GPost               0.00005      1.00       0.00008       1.60
    COI-GPost-B             0.00003      1.00       0.00005       1.67
    COI-QMC-1               0.00013      1.00       0.00015       1.15
    COI-QMC-2               0.00029      1.00       0.00029       1.00
    COI-WHPP                0.00005      1.00       0.00005       1.00
    COI-BCV-3.46.2          0.00894      1.00       0.00895       1.00
    COI-BCV-4.13.1          0.00010      1.00       0.00010       1.00
    COI-SINTEF              0.00000      1.00       0.00001       inf.
    COI-ORTEC01             0.00270      1.00       0.00310       1.15 *
    COI-ORTEC02             0.00270      1.00       0.00305       1.13 *
    COI-ERMGH               0.00779      1.00       0.01055       1.35 *
    COI-CHILD               0.00149      1.00       0.00166       1.11 *
    COI-ERRVH               0.02001      1.00       0.02182       1.09
    COI-HED01               0.00136      1.00       0.00136       1.00
    COI-Valouxis-1          0.00020      1.00       0.00100       5.00
    COI-Ikegami-2.1         0.00000      1.00       0.00000       1.00
    COI-Ikegami-3.1         0.00002      1.00       0.00010       5.00
    COI-Ikegami-3.1.1       0.00003      1.00       0.00007       2.33
    COI-Ikegami-3.1.2       0.00003      1.00       0.00012       4.00
    COI-BCDT-Sep            0.00100      1.00       0.00270       2.70
    COI-MER                 0.07081      1.00       0.08495       1.20 *
    ----------------------------------------------------------------------
         Average            0.00453      1.00       0.00536       inf.
  
  This is within striking distance of 1.10 on average.  Probably best
  to keep slogging on.  Here are the INRC2-4 results (with -flto):

    Instances (20)         LOR17         KHE26
                           Cost         Rel.         Cost         Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291      0.01695      1.00       0.01795      1.06
    INRC2-4-030-1-6753      0.01890      1.00       0.01920      1.02
    INRC2-4-035-0-1718      0.01425      1.00       0.01560      1.09
    INRC2-4-035-2-8875      0.01155      1.00       0.01205      1.04
    INRC2-4-040-0-2061      0.01685      1.00       0.01780      1.06
    INRC2-4-040-2-6106      0.01890      1.00       0.02040      1.08
    INRC2-4-050-0-0487      0.01505      1.00       0.01615      1.07
    INRC2-4-050-0-7272      0.01500      1.00       0.01565      1.04
    INRC2-4-060-1-6115      0.02505      1.00       0.02690      1.07
    INRC2-4-060-1-9638      0.02750      1.00       0.03160      1.15 *
    INRC2-4-070-0-3651      0.02435      1.00       0.02820      1.16 *
    INRC2-4-070-0-4967      0.02175      1.00       0.02575      1.18 *
    INRC2-4-080-2-4333      0.03340      1.00       0.03740      1.12 *
    INRC2-4-080-2-6048      0.03260      1.00       0.03770      1.16 *
    INRC2-4-100-0-1108      0.01245      1.00       0.01450      1.16 *
    INRC2-4-100-2-0646      0.01950      1.00       0.02290      1.17 *
    INRC2-4-110-0-1428      0.02440      1.00       0.02680      1.10
    INRC2-4-110-0-1935      0.02560      1.00       0.02815      1.10
    INRC2-4-120-1-4626      0.02170      1.00       0.02480      1.14 *
    INRC2-4-120-1-5698      0.02220      1.00       0.02580      1.16 *
    ----------------------------------------------------------------------
         Average            0.02089      1.00       0.02326      1.11

  This is worse than the 1.09 we got on 21 May 2026.

13 July 2026.  Two obvious instances to go after are COI-MER (which we
  have been working on anyway) and INRC2-4-100-0-1108 (an old friend
  that seems to have blown out again).  Also it would be good to get
  the SINTEF result down from 1 to 0.

  Decided to do some work on SINTEF, just for a change.  The solver
  runs very quickly on SINTEF; it starts 62 solves, and their final
  costs range from 1 to just 6.  Evidently the solver it runs out
  of things to repair quite quickly.  The sole defect in the best
  KHE26 solution is

    TimeOff-Nurse23-s1/Nurse23  (the time in question is 3Sat3)

  Looking over the solution, it does not look very hard to repair.
  We should start with a whynot.  Why not move that 3Sat3 task from
  Nurse23 to the only available nurse, Nurse24?

14 July 2026.  Working on a whynot for SINTEF.  Cost 1, sole defect is

    TimeOff-Nurse23-s1/Nurse23 (again, 3Sat3)

  OK, I've got the whynot run, but I don't have the fun facts yet.  So
  I'm getting those together now.

15 July 2026.  Started looking at the SINTEF whynot run.  I've found

    Resource swap+(Nurse23 --> Nurse24 {10-10: 3Sat:260086974.0}E,
      Nurse24 --> Nurse23 {2-1: }E)

  but there is no sign of a balanced swap.  There should be:

    KheAugmentOptionsMake:  busy_times_supply_is_tight = true,
      workload_supply_is_tight = false

  As it stands the code is working out that the supply of busy
  times is tight.  Because of that it does not check whether the
  supply of workload is tight.  That is all as it should be.
  There are no balanced swaps in the whynot, because none are
  available.

  I tried switching to a beam of length 2 at depth 1 but it
  did not help, so I've taken it away again.

  Nurse23 is Contract-C4 (14 - 15 day shifts), and it has 14
  shifts in the solution I'm currently looking at.  Nurse24 is
  Contract-C5 (exactly 3 day shifts), and it has 3 shifts in
  that solution.

16 July 2026.  Looking into how VLSN search behaves on SINTEF.
  File he_sr_dynamic_vlsn.c, line 2782.  Nurse23 has 23 followers,
  but this line limits our search to the first 5*(count - 1),
  which when there are four resources is the first 15, leaving
  out Nurse24 in all cases.  I added a random offset here so
  that cases with 4 nurses and 8 times will allow Nurse24
  to be included from time to time, and yes I got a solution
  with cost 0.  At first I added a second rdv to the end of
  the solve, but I'm still getting that optimal solution even
  after taking that rdv away.  So great.  I did a full COI run,
  and it includes the zero cost SINTEF result, but some other
  results are slightly worse than the 12 July 2026 results:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000      1.00       0.00000      1.00
    COI-Musa                0.00175      1.00       0.00175      1.00
    COI-Millar-2.1          0.00000      1.00       0.00000      1.00
    COI-Millar-2.1.1        0.00000      1.00       0.00000      1.00
    COI-LLR                 0.00301      1.00       0.00301      1.00
    COI-Azaiez              0.00000      1.00       0.00000      1.00
    COI-GPost               0.00005      1.00       0.00008      1.60
    COI-GPost-B             0.00003      1.00       0.00005      1.67
    COI-QMC-1               0.00013      1.00       0.00017      1.31
    COI-QMC-2               0.00029      1.00       0.00029      1.00
    COI-WHPP                0.00005      1.00       0.00005      1.00
    COI-BCV-3.46.2          0.00894      1.00       0.00895      1.00
    COI-BCV-4.13.1          0.00010      1.00       0.00010      1.00
    COI-SINTEF              0.00000      1.00       0.00000      1.00
    COI-ORTEC01             0.00270      1.00       0.00310      1.15
    COI-ORTEC02             0.00270      1.00       0.00305      1.13
    COI-ERMGH               0.00779      1.00       0.01079      1.39
    COI-CHILD               0.00149      1.00       0.00166      1.11
    COI-ERRVH               0.02001      1.00       0.02196      1.10
    COI-HED01               0.00136      1.00       0.00136      1.00
    COI-Valouxis-1          0.00020      1.00       0.00120      6.00
    COI-Ikegami-2.1         0.00000      1.00       0.00001      inf.
    COI-Ikegami-3.1         0.00002      1.00       0.00011      5.50
    COI-Ikegami-3.1.1       0.00003      1.00       0.00010      3.33
    COI-Ikegami-3.1.2       0.00003      1.00       0.00013      4.33
    COI-BCDT-Sep            0.00100      1.00       0.00270      2.70
    COI-MER                 0.07081      1.00       0.08599      1.21
    ----------------------------------------------------------------------
         Average            0.00453      1.00       0.00543      inf.

  So let's do some work on COI-Ikegami-2.1.  Comparing the evaluation
  with the fun facts, the problem is that none of the Skill-Skilled
  resources (that is, none of A01, A02, A03, B11, B12, C20, C21) are
  on the 4Sun Night shift.

17 July 2026.  Looking at the KHE solution to COI-Ikegami-2.1.  It's
  time for a whynot.

  There are an awful lot of calls on ejection chains in the whynot.
  These are calls on KheEjectionChainRepairInitialResourceAssignment.
  They come from resource matching, and their start_gm is the set of
  limit resources monitors.  I should look into what good these are
  doing and whether I want to keep them as is.

18 July 2026.  Modified HSEval to omit relative costs when the smaller
  cost is 20 (soft) or less.

  Added an extra "rdv, rec" to the solve, aiming to convince the
  solver to spend more time on each solve rather than to start
  a lot of small solves.  That was for COI-ORTEC01 especially,
  but the final result was no better.

  I've decided to work on COI-ORTEC01, COI-Valouxis-1, and COI-BCDT-Sep,
  to see if I can break through the bottlenecks that have held the
  solver back on these instances for a long time.  COI-ORTEC01 is first:

    [ "COI-ORTEC01", 8 threads, 13 solves, 245.1 secs:
      0.00310 0.00315 0.00326 0.00330 0.00330 0.01310 0.01320 0.01325
      0.01325 0.01335 0.01340 0.02335 0.02340
    ] 0.00310 is best cost (first diversifier 1)

  The defects are partly cases of too few shifts per week, and
  partly too few consecutive busy days.

20 July 2026.  Had yesterday off.  Working on COI-ORTEC01.  I've
  completed the fun facts, and now I am comparing the KHE solution
  with the best known Misc solution.  It seems that in Week 1 there
  are not enough shifts to go around, and both solutions are wearing
  cost 210 (Constraint:24) because of that.  The KHE solution then
  has three more of these defects in later weeks that the Misc
  solution does not have, costing 30.  Both solutions also have
  cases of less than the minimum number of consecutive busy days
  (three instead of four).  The best solution has 6 of these, KHE's
  solution has 7, so that's another 10 points, making 40 in
  total which is the difference between the best cost (270)
  and KHE's cost (310).

  KheSolnMakeExpensiveTasksUnassignable is documented and
  implemented, in khe_sr_structure.c.  It is also in
  yourself, under name "ret" (now documented).  Ready to
  audit and test.

21 July 2026.  Testing KheSolnMakeExpensiveTasksUnassignable.
  It seems to be working as expected.  When the solution cost
  is low enough (in three of the first eight solves) it is reducing
  the domains of 410 tasks to empty.  First results:

    [ "COI-ORTEC01", 8 threads, 13 solves, 244.9 secs:
      0.00310 0.00315 0.00320 0.00330 0.00330 0.01310 0.01320 0.01325
      0.01325 0.01335 0.01340 0.02335 0.02340
    ] 0.00310 is best cost (first diversifier 1)

  So KheSolnMakeExpensiveTasksUnassignable is working but not
  producing any improvement in the best cost.  There is a small
  improvement in the third-best cost, which could be chance.

  The only hope for improvement in the COI-ORTEC01 result is with
  the three defects, totalling 30 points, which are caused by too
  few shifts per week in weeks 2 and 3:

    Constraint:29/Nurse13   10 * Quadratic(4 - 2Fri - 2Sat - 2Sun) 
    Constraint:31/Nurse13   10 * Quadratic(4 - 2Mon - 2Tue - 3Wed) 
    Constraint:33/Nurse1    10 * Quadratic(4 - 3Mon - 3Tue - 4Wed) 

  I guess it's time for a whynot.  But I suspect that Nurse13 has
  got off to a bad start by having 5 shifts, including three N
  shifts, in Week 1.

  What is this repair about:

    Resource assign+(--> Nurse13 {4-4: 2Wed:D.0})

  It seems to be saying that 2Wed:D.0 was unassigned at the start
  of the repair.  I guess it means the mtask, not the task.
  Could it be that the mtask finder is not taking account of
  the domains of tasks, only of the domains of their constraints?
  No, I've just checked, and root domains are part of signatures.

  I need a whynot run that prints the domains of the mtasks.

23 July 2026.  Doing some detailed whynot work on COI-ORTEC01.
  KheSolnMakeExpensiveTasksUnassignable does not seem to be
  preventing the assignments it is supposed to prevent.

24 July 2026.  Found yesterday's problem, it was caused by the
  called to EnlargDomains.  So I'm now making a second call to
  KheSolnMakeExpensiveTasksUnassignable immediately after that:

    [ "COI-ORTEC01", 1 thread, 1 solve, 181.4 secs: 0.01325 ]

    [ "COI-ORTEC01", 8 threads, 13 solves, 245.4 secs:
      0.00310 0.00315 0.00320 0.00330 0.00330 0.01310 0.01320 0.01325
      0.01325 0.01335 0.01340 0.02335 0.02340
    ]

  No improvement over 21 July, and it's running slightly slower.
  I've more or less decided to omit ret - but what else is there?

25 July 2026.  The three defects I'm targeting are as they were on
  22 July:

    Constraint:29/Nurse13   10 * Quadratic(4 - 2Fri - 2Sat - 2Sun) 
    Constraint:31/Nurse13   10 * Quadratic(4 - 2Mon - 2Tue - 3Wed) 
    Constraint:33/Nurse1    10 * Quadratic(4 - 3Mon - 3Tue - 4Wed)

  I've looked at how combinatorial grouping is doing.  It is finding
  a lot of weekend groups but strangely not Friday night.  And this
  is the problem:

    [ KheMTaskGrouper (1 mtasks, cost 0.00000)
	[ MTask 1Fri:N.0 1Fri RG:All asst_count 0
	  n0.01000 a0.00000 false 1Fri:N.0
	  n0.00000 a0.01000 true 1Fri:N.1
	  n0.00000 a0.01000 true 1Fri:N.2
	]
    ]

  The grouper seems to think that 1Fri:N alone has cost zero.
  It has missed the thing about no Friday night before a free
  weekend.  So the fault is in KheMTaskGrouperCost.  I've fixed
  it by passing an interval that it is to take its monitors from,
  and bingo:

    [ "COI-ORTEC01", 8 threads, 28 solves, 274.6 secs:
      0.00295 0.00305 0.00305 0.00310 0.00310 0.00315 0.00320 0.00320
      0.00320 0.00320 0.00325 0.00325 0.00326 0.00330 0.00330 0.00330
      0.00335 0.00335 0.00335 0.00335 0.00335 0.00335 0.00340 0.00340
      0.00345 0.00345 0.00345 0.00360
    ] 0.00295 is best cost (first diversifier 23)

  I think that will do for COI-ORTEC01.  It is rel = 295 / 270 = 1.09.
  Although there is one constraint of cost 5 that it would be good
  to get rid of (L shift followed by E shift).  For example, why not
  2Mon-2Tue Nurse4 <--> Nurse5 ?

  I've been wondering why some of the whynot branches are terminating,
  and I've added some extra debug output.  My current question is
  about op2 line 48224:

    failure: min_gap 0.00000 <= 0

  This seems to be saying that in order to recurse, the current
  cost must be strictly larger than the target (original) cost.
  This seems wrong, so I've taken it out to see what happens:

    [ "COI-ORTEC01", 8 threads, 29 solves, 270.2 secs:
      0.00290 0.00300 0.00300 0.00300 0.00305 0.00305 0.00310 0.00310
      0.00310 0.00310 0.00310 0.00310 0.00310 0.00310 0.00315 0.00315
      0.00315 0.00315 0.00320 0.00320 0.00320 0.00320 0.00325 0.00330
      0.00330 0.00330 0.00340 0.00340 0.00370
    ] 0.00290 is best cost (first diversifier 8)

  It's better again, rel = 290 / 270 = 1.07.  I really need a full
  run now to see if there is any problem with this change, and also
  to better test the change I made to combinatorial grouping.  I'm
  getting some very good results:

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ----------------------------------------------------------------------
    COI-Ozkarahan           0.00000      1.00       0.00000      1.00
    COI-Musa                0.00175      1.00       0.00175      1.00
    COI-Millar-2.1          0.00000      1.00       0.00000      1.00
    COI-Millar-2.1.1        0.00000      1.00       0.00000      1.00
    COI-LLR                 0.00301      1.00       0.00301      1.00
    COI-Azaiez              0.00000      1.00       0.00000      1.00
    COI-GPost               0.00005      1.00       0.00008        
    COI-GPost-B             0.00003      1.00       0.00006        
    COI-QMC-1               0.00013      1.00       0.00016        
    COI-QMC-2               0.00029      1.00       0.00029      1.00
    COI-WHPP                0.00005      1.00       0.00005      1.00
    COI-BCV-3.46.2          0.00894      1.00       0.00894      1.00
    COI-BCV-4.13.1          0.00010      1.00       0.00010      1.00
    COI-SINTEF              0.00000      1.00       0.00000      1.00
    COI-ORTEC01             0.00270      1.00       0.00290      1.07
    COI-ORTEC02             0.00270      1.00       0.00300      1.11
    COI-ERMGH               0.00779      1.00       0.01095      1.41
    COI-CHILD               0.00149      1.00       0.00260      1.74
    COI-ERRVH               0.02001      1.00       0.02483      1.24
    COI-HED01               0.00136      1.00       0.00137      1.01
    COI-Valouxis-1          0.00020      1.00       0.00060        
    COI-Ikegami-2.1         0.00000      1.00       0.00000      1.00
    COI-Ikegami-3.1         0.00002      1.00       0.00009        
    COI-Ikegami-3.1.1       0.00003      1.00       0.00013        
    COI-Ikegami-3.1.2       0.00003      1.00       0.00011        
    COI-BCDT-Sep            0.00100      1.00       0.00200      2.00
    COI-MER                 0.07081      1.00       0.08904      1.26
    ----------------------------------------------------------------------
         Average            0.00453      1.00       0.00563      1.14

  Looking into COI-Valouxis-1.  Initial results.  We got to "no more
  solves will start (50 solns since new best)":

    [ "COI-Valouxis-1", 8 threads, 75 solves, 50.3 secs:
      0.00060 0.00080 0.00100 0.00100 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00120 0.00120 0.00120 0.00120 0.00120
      0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120
      0.00120 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140
      0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00160
      0.00160 0.00160 0.00160 0.00160 0.00160 0.00160 0.00160 0.00160
      0.00160 0.00160 0.00160 0.00180 0.00180 0.00180 0.00180 0.00180
      0.00180 0.00180 0.00180 0.00180 0.00180 0.00180 0.00200 0.00200
      0.00200 0.00200 0.00200 0.00200 0.00220 0.00220 0.00220 0.00220
      0.00220 0.00240 0.00240
    ] 0.00060 is best cost (first diversifier 18)

  The 60 points are made up of three limit active intervals defects
  of cost 20 each:

    Constraint:15/Nurse1   20 * Linear(4 - 3Thu - 3Fri - 3Sat)   20
    Constraint:15/Nurse6   20 * Linear(4 - 4Thu - 4Fri - 4Sat)   20
    Constraint:15/Nurse7   20 * Linear(4 - 2Mon - 2Tue - 2Wed)   20

  The best known solution has just one of these three defects:

    Constraint:15/Nurse6   20 * Linear(4 - 4Thu - 4Fri - 4Sat)   20
  
  Here's a possible whynot to fix the Nurse6 defect:

    4Sun Nurse15 --> Nurse6
    3Sun Nurse6 <--> Nurse7

  but not quite because Nurse6 would then violate Max 3 Sundays.
  You could add 2Sun Nurse6 --> Nurse13, but that is not a
  proper chain, and anyway it makes another sequence of length 3.

  Really we need repairs that will wriggle across the timetable
  to the end where lengths don't matter.  But how?  I've tried
  tilting, and I've tried grouping, but no luck.  What about
  having a close look at what time sweep is producing?

26 July 2026.  Tidied up khe_sm_yourself.c.  Added "quit" command.
  Tried to implement it using longjmp but that did not work owing
  to unreturned arenas.  So switched to a status return value and
  that seems to be working.

  Had a look at what time sweep is producing for COI-Valouxis-1
  and it is not inspiring.  There are several places where length
  3 sequences are being created right at the start.  These will
  then be very hard to get rid of later.

27 July 2026.  I've documened a variant of interval grouping for
  when the number of consecutive days is fixed, as in COI-Valouxis-1,
  and called it "day grouping".  And I've made a stub implementation
  in khe_sr_day_grouping.c and added it to yourself (and documented).
  I've done some basic code that finds the constraint class we need:

    [ ConstraintClass(Constraint:13, 3 constraints)
      Constraint:13
      Constraint:14
      Constraint:15
    ]

  plus other stuff.  I need to carry on from here.

28 July 2026.  Worked on the documentation of day grouping.  There
  are a few murky issues, no doubt about it.  Anyway, let's press
  on and see where it takes us.

  Done some more implementing.  I now have a solver object holding
  the right day objects holding the right task objects.  I guess
  the next thing to do is a recursive construction of the initial
  runs with suitable run lengths.

29 July 2026.  Worked on day grouping.  I seem to be enumerating
  the initial groupings properly now:

    DayGrouping(0.00000: | 4 4 4 4 4 4 4 4 4 4)
    DayGrouping(0.00000: | 3 4 4 4 4 4 4 4 4 4)
    DayGrouping(0.00000: | 3 3 4 4 4 4 4 4 4 4)
    ...
    DayGrouping(0.00000: | 1 1 1 1 1 1 1 1 1 3)
    DayGrouping(0.00000: | 1 1 1 1 1 1 1 1 1 2)
    DayGrouping(0.00000: | 1 1 1 1 1 1 1 1 1 1)

  There are 298 - 11 = 287 initial groupings.  It's doable, but
  I might have to insert some kind of sanity check later.

31 July 2026.  Workinbg on day grouping.  All done, now it needs
  an audit and test.  But I am not currently finding good ways
  to choose which tasks go into the groups.

1 August 2026.  Finished auditing day grouping.  I need to sort
  out one "still to do" point, then I'm ready to test.  The
  choice of tasks will be poor, so I am not currently building
  the groups, although the code for that is written.

2 August 2026.  Added KheConstraintClassHistoryAfter to the
  constraint class module.  I need it for day grouping.  I'm now
  using it:  unfinished groups at the end of the cycle contribute
  to cost only when KheConstraintClassHistoryAfter is 0.

  Done some testing, worked virtually first time.  I now have a
  beautiful display, produced by the KHE_GROUPED_TASKS_DISPLAY
  module, of the groups.  And the best solution has unfinished
  duration zero, which is excellent.

4 August 2026.  There are 165 equal best groupings.  Not a lot.
  But then, if the other constraints don't go well, they will
  not be the best groupings at all.

6 August 2026.  Thinking about assigning tasks to runs.  I've
  written some stuff but it's still not ready to implement.

7 August 2026.  Documentation seems ready to implement now.
  It includes a paragraph which seems to show that the best
  place to call day grouping is at the end of the grouping
  phase, after combinatorial grouping, weekend grouping,
  and interval grouping.

8 August 2026.  I've written the code to build start_gm.  It
  would be good to check what it is producing, but it looks
  good.  It adds in all cluster busy times and limit busy times
  monitors that cover less than 2 * dgs->fixed_length days, plus
  all limit active intervals monitors whose time groups are
  all positive (we don't want costs for sequences of free days).

9 August 2026.  Prepared overheads for PATAT 2026 conference.

10 August 2026.  Finished preparing overheads for PATAT 2026 conference.
  Updated doc_khe with some suggestions about the order to run
  the task grouping solvers.

11 August 2026.  I've added code to associate a resource with each run
  and only accept a task into a run if it can be assigned that resource.
  It needs an audit.

12 August 2026.  Working on day grouping.  Messy but progressing.

13 August 2026.  Adding KHE_DAY_GROUPING_DAY.  Boilerplate all
  done except for KheDayGroupingDayCopy.

14 August 2026.  Working on day grouping.  I am now only
  adding runs when I know they will actually be needed.
  I'm getting good groups again, solving is next.

  No longer allowing runs with NULL resources.  Struggling to find
  enough unreserved resources, but we are just making it.  We
  seem to be doing what's wanted now.

16 August 2026.  Bad cold yesterday.  Worked on the day grouping
  documentation today.  I think I have something now that I can
  implement.

17 August 2026.  Added rs_day_grouping_extra_days option to day
  grouping (documented and implemented).

18 August 2026.  Working on day grouping.  It seems to be all done
  except for redistributing the tasks to the runs based on their
  assignments.  Also an option which limits ejection chains to
  swaps only is needed.

19 August 2026.  Working on day grouping.  Doing some tidying up
  based on the invariant I documented yesterday.  Ready for another
  audit.

20 August 2026.  Working on day grouping.  Finished an audit.  Now
  redistributing the tasks to runs after solving.  Also I've added
  a swaps_only parameter to KheAugmentOptionsMake, and used it to
  ensure that day grouping's task assignment part only tries swaps.

21 August 2026.  Working on day grouping.  Finished a new section
  of the documentation, "Grouping cost", which is good stuff.

23 August 2026.  Working on day grouping.  I've updated ejection
  chains to have a cost_m.  All implemented and documented, and
  being used as intended by day grouping.  I've saved the old
  code in save_khe_se_ejector.c and save_khe_se_solvers.c.

  I've also updated ejection chains by changing swaps_only to
  exact_swaps_only, which means not only that only swaps are
  allowed, but also that those swaps must be of intervals that
  are busy at both ends, as required by day grouping.  All
  implemented and documented.

  I've also deleted total_unfinished_durn and replaced it with
  total_cost.

24 August 2026.  Leaving for PATAT 2026 today.  Had a bit of
  spare time, did some auditing of khe_sr_day_grouping.c.
  Then did an off-site backup.

1 October 2026.  Back from PATAT + holiday.  Started work on
  the new Krystallidis constraints.  Here are some notes:

  StudentChoiceConstraint needs a new name, what about
  SelectAssignmentsConstraint.  Its points of
  application are resources, so I guess it counts as a
  resource constraint.  However its value does not depend
  on the timetable of the resource; it depends on which
  event resources the resource is assigned to.  For
  consistency with the Limit Resources Constraint, I
  need to allow individual events, treating each as an
  event group of cardinality one.

  The implementation challenge here is that the constraint
  is affected by a (resource, event group) pair.  That is,
  it fires when a particular resource is assigned to a
  particular event group.  That's new and will be hard
  to implement efficiently.  For each such pair we need
  to maintain a count of the number of such assignments.

  BalanceClassSizeConstraint also needs a new name, what
  about BalanceAssignmentsConstraint.  It
  monitors a set of event resources, so it is clearly an
  event resource constraint.  The monitoring is straightforward,
  we just need to keep track of how many event resources have
  non-NULL assignments.  The calculation is a bit tricky.

  The change to the avoid split assignments constraint
  looks to be pretty straightforward.

11 October 2026.  Struggling to find time for working on KHE.
  Today I added the third model to KHE_MODEL, but I'm not
  doing anything with it yet.  Added the new code to khe_archive.c
  but not yet to khe_instance.c.

12 October 2026.  Checked khe_instance.c, no changes needed
  to model.  Working on spec.c now, I've done a fair bit of
  boilerplate.  ExtendedHighSchoolAvoidSplitAssignmentsSpec,
  ExtendedHighSchoolSelectAssignmentsSpec, and
  ExtendedHighSchoolBalanceAssignmentsSpec still to do.

  Sent to_andreas12, now waiting for response.

  Are we using "timetable" or "timetabling" on the spec pages?
  We're using "Schedule" and "Timetable" in the XML, but we are
  using "scheduling" and "timetabling" in the text of the spec.
  All updated now.

13 October 2026.  Finished off hseval spec page for XEHSTT.
  Although there are a few points that I am waiting for
  Andreas on.

14 October 2026.  Finished off the spec page, sent it to
  Andreas for checking.  The whole thing is basically ready to
  implement.  Avoid split assignments are done.  The new code
  needs testing but it's morally certain that it will work.

15 October 2026.  Andreas has signed off on the spec except for
  one typo and one awkard semantic problem with balance constraints.
  I've corrected both of these issues in spec.c now.

  Working on khe_select_assignments_constraint.c.  All done
  and audited except for creating monitors.  Now working on
  getting khe_balancet_assignments_constraint.c to the same point.

16 October 2026.  Worked on khe_balance_assignments_constraint.c.

17 October 2026.  Worked on both new constraints and monitors.
  Boilerplate all done with clean compile, including odds and
  ends (density count, monitor Id, time range).

18 October 2026.  Written a beautiful explanation of how the
  monitoring works.  Gosh I'm good.

19 October 2026.  Audited yesterday's beautiful explanation.
  It's ready to implement now.  I've finished implementing
  khe_monitored_event_group.c, except the debug function.

  Now I have to write the bodies of various functions in
  select.c and balance.c, and I have to create the monitored
  event group objects I need (including no duplicates!) and
  add them to event resource in solution objects.  I have
  already added an array of them and am calling the monitor
  functions on them.

20 October 2026.  Audited khe_monitored_event_group.c, added
  debug function.  That module is now ready for testing.  Also
  audited khe_event_resource_in_soln.c, all good there.  And
  I've made KHE_MONITORED_EVENT_GROUP attach itself to the
  event resource in solution objects it needs when the first
  monitor attaches to it.  I've also made a table of monitored
  event groups, in event in soln objects, so that we only
  make a new monitored event group object when there is not
  already one available.

  I seem to have finished khe_select_assignments_monitor.c.
  That happened rather suddenly.  I am also now creating monitors
  in khe_select_assignments_constraint.c, following the model
  of cluster constraints.  So that is select completely done!

21 October 2026.  File khe_select_assignments_constraint.c is
  completely done and audited; khe_balance_assignments_monitor.c
  is next, and it is all done except calculating the deviation,
  including attach and detach.

22 October 2026.  Working on KheBalanceUpdate.  All done but I
  suspect that when it is first attached it is not right.

23 October 2026.  Finished khe_balance_assignments_monitor.c
  and audited it.  It's ready to test.

24 October 2026.  Now working on solvers.  I've worked
  through all the solvers that call KheMonitorTag, making sure
  that they are at least basically ready to handle the two new
  monitors.  The only thing still to do is that the functions
  within khe_se_solvers.c are stubs at present.  I need to do
  a halfway decent job of those, which could involved installing
  better reporting functions in the platform.

25 October 2026.  Working on KheSelectAssignmentsAugment.
  Amazing, I seem to have finished it, including asssembling
  assigned mtasks into an mtask set and unassigning the set.

26 October 2026.  Did some thinking about the balance assignments
  cost function, and wrote a little document, in the form of an
  email to Andreas, about it.  But not sent yet.

27 October 2026.  Didn't get much done today, other jobs.

28 October 2026.  Nothing today, working elsewhere.

29 October 2026.  Working on Chernikov's bug.  At present I'm
  stumped by why my own version of HSEval is crashing on it.
  Is it crashing on other variants?

30 October 2026.  Working on Chernikov's bug.  Fixed it by
  ensuring that HSEval reads stdin right to the end.

31 October 2026.  Worked out a solution to the resource ordering
  problem:  if you visit the resources in reverse order, you visit
  them all even though they are being reordered.

  Updated khe_monitored_event_group.c so that it now makes its
  meg resources only on demand.  Also it now records which tasks
  are assigned and is able to report them.  And its type is now
  public and its query operations are declared in khe_platform.h
  and documented in the user guide.

  Did an audit of the select assignments repairs in khe_se_solvers.c
  and changed several things, partly to utilize the new queries on
  monitored event groups, and partly to fix bugs.

  Augment function for balance repairs is now written.  It needs
  an audit, but it's looking good.

1 November 2026.  Audited khe_monitored_event_group.c, it's looking
  good.  Also audited the augment functions in khe_se_solvers.c,
  they look good too.

  Testing.  Fixed one bug, carrying on now.

2 November 2026.  Revising kml_read.c to make it more robust, or
  rather, to make it robust.  The other file, kml.c, is fine as is.

  There is a problem with curr_decl_stack:  it is used both when
  declaring and when reading.  That can't be right!  I need to
  build a tree of declarations with parent pointers and then
  just traverse it.

  I've revised the documentation of segmented file reading in
  a way that should simplify the implementation, and now I'm,
  starting in on revising the implementation.

3 November 2026.  Worked over the kml_read documentation again,
  it is in very good shape now.  Implementing.  Got it down to
  just a few error messages.  An audit which includes a lot of
  tidying up is needed now.

5 November 2026.  Redoing the interface and implementation of KML.
  All the doc is done, as is kml.h, kml.c, and kml_read.c except
  for a few points noted below.  Also I've started work on the
  users of KML.  I've done khe_archive.c; khe_soln_group.c is next.

6 November 2026.  Redone all uses of the KML module; have clean
  compile.  Sorted out the special case code needed for KmlReadFile.

7 November 2026.  Tidied up file reading in khe_archive.c.  It seems
  to be in good shape now, all implemented and audited, including
  the new handling of metadata elements.

8 November 2026.  Started testing.  Fixed a couple of bugs, tightened
  up some things.  It's all good at the moment.

9 November 2026.  Testing.  I've added one avoid split assignments
  constraint (with CountNonAssignment), one select assignments
  constraint, and one balance assignments constraint.  After a
  couple of minor bug fixes, KHE seems to be reading them correctly.
  Now adding a solution.  Discovered a lot of switches in khe_monitor.c
  that did not have cases for the two new monitor types.  Fixed now.
  I've tried various combinations in the solution.  The avoid split
  assignments and balance assignments monitors seem to be working
  correctly, but the select assignments monitor always has assignment
  count 0 when it should have non-zero values.

  There aren't as many retrievals of monitored event groups as
  there should be, because:

    KheSelectAssignmentsMonitorMake count = 0

  And this in turn means that KheConstraintAddEventGroupsFromKml
  or KheConstraintAddEventsFromKml is going wrong.  Actually there
  is a syntax error (Event where EventGroup is expected):

      <EventGroups>
	<EventGroup Reference="eg1"/>
	<EventGroup Reference="eg2"/>
	<Event Reference="E3"/>
      </EventGroups>

  Why was it not picked up?  Could the whole category have been
  missed, somehow?

  Check all calls on KheConstraintAddEventGroupsFromKml and
  KheConstraintAddEventsFromKml - they return a bool which
  needs to be checked.  This is the source of the current bug.

10 November 2026.  Testing.  Yesterday's fix worked.  I've now
  expanded the test instance into something that could be solved.
  I've discovered that most places in KHE that test KheInstanceModel
  had not been updated to handle the new model.  Very naughty of
  me, all fixed now.

11 November 2026.  I've done some solving.  All working, although
  I had to fix a few HSEval problems with viewing the result file.

13 November 2026.  Done some more testing.  I used -w to read and
  write Alexsandr's instance, then evaluated it.  No problems.  I
  need to do some more solving, then it will be ready to post.

  Removed rdg from between rig and rah in KheCombinedResourceAssign,
  since day grouping was crashing.  Now I'm getting a cost 120
  solution, which is the going rate for KHE.

  Working on day grouping.  I've fixed one or two small bugs, and
  now I seem to be getting a complete day grouping, although its
  cost is given as -0.22800, which does not inspire confidence.

  Got it running, first results are encouraging:

    [ "COI-Valouxis-1", 1 thread, 1 solve, 7.3 secs: 0.00060 ]

    [ "COI-Valouxis-1", 8 threads, 8 solves, 14.8 secs:
      0.00060 0.00060 0.00060 0.00060 0.00080 0.00100 0.00140 0.00160
    ] 0.00060 is best cost (first diversifier 0)

  remembering that KHE was previously getting 120.  It's likely
  that KHE had to break up some sequences of length 4 in order
  to handle other constraints that could not be satisfied with
  sequences of length 4.  Here is a time_limited 5 minute run:

    [ "COI-Valouxis-1", 8 threads, 61 solves, 88.2 secs:
      0.00060 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060
      0.00060 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060
      0.00060 0.00060 0.00060 0.00060 0.00060 0.00060 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00100 0.00100 0.00120 0.00120 0.00120
      0.00120 0.00120 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140
      0.00140 0.00140 0.00140 0.00160 0.00180
    ] 0.00060 is best cost (first diversifier 0)

  Getting below 60 will require randomness at least.

14 November 2026.  The source of the negative costs seems to be
  Constraint:10, which is "max 13 days off".  This should not be
  in the group monitor - why is it?  Just a stupid cut and paste
  error, fixed now.

  I've added quite a lot of randomness into the day grouping, and
  sure enough it has helped:

    [ "COI-Valouxis-1", 8 threads, 81 solves, 75.4 secs:
      0.00040 0.00040 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060
      0.00060 0.00060 0.00060 0.00060 0.00060 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00100 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00100 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00100 0.00120 0.00120 0.00120 0.00120
      0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120
      0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140
      0.00140 0.00140 0.00140 0.00160 0.00160 0.00160 0.00180 0.00180
      0.00200
    ] 0.00040 is best cost (first diversifier 26)

  Hurrah, this is pretty good now, best known is 20.

  Added sanity check option rs_day_grouping_max_groupings, with
  default value 1000.  Same good results as before:

    [ "COI-Valouxis-1", 8 threads, 81 solves, 75.5 secs:
      0.00040 0.00040 0.00060 0.00060 0.00060 0.00060 0.00060 0.00060
      0.00060 0.00060 0.00060 0.00060 0.00060 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080 0.00080
      0.00080 0.00080 0.00080 0.00100 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00100 0.00100 0.00100 0.00100 0.00100
      0.00100 0.00100 0.00100 0.00100 0.00120 0.00120 0.00120 0.00120
      0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120 0.00120
      0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140 0.00140
      0.00140 0.00140 0.00140 0.00160 0.00160 0.00160 0.00180 0.00180
      0.00200
    ] 0.00040 is best cost (first diversifier 26)

  And that is basically that for day grouping.

15 November 2026.  Doing a long nurse rostering test in preparation
  for publishing a new release of KHE and HSEval.

    Instances (27)             Misc                    KHE26
                               Cost       Rel.         Cost       Rel.
    ------------------------------------------------------------------
    COI-Ozkarahan           0.00000       1.00       0.00000      1.00
    COI-Musa                0.00175       1.00       0.00175      1.00
    COI-Millar-2.1          0.00000       1.00       0.00000      1.00
    COI-Millar-2.1.1        0.00000       1.00       0.00000      1.00
    COI-LLR                 0.00301       1.00       0.00301      1.00
    COI-Azaiez              0.00000       1.00       0.00000      1.00
    COI-GPost               0.00005       1.00       0.00008           
    COI-GPost-B             0.00003       1.00       0.00006           
    COI-QMC-1               0.00013       1.00       0.00016           
    COI-QMC-2               0.00029       1.00       0.00029      1.00
    COI-WHPP                0.00005       1.00       0.00005      1.00
    COI-BCV-3.46.2          0.00894       1.00       0.00894      1.00
    COI-BCV-4.13.1          0.00010       1.00       0.00010      1.00
    COI-SINTEF              0.00000       1.00       0.00000      1.00
    COI-ORTEC01             0.00270       1.00       0.00290      1.07
    COI-ORTEC02             0.00270       1.00       0.00300      1.11
    COI-ERMGH               0.00779       1.00       0.00991      1.27
    COI-CHILD               0.00149       1.00       0.00257      1.72
    COI-ERRVH               0.02001       1.00       0.02480      1.24
    COI-HED01               0.00136       1.00       0.00137      1.01
    COI-Valouxis-1          0.00020       1.00       0.00040           
    COI-Ikegami-2.1         0.00000       1.00       0.00000      1.00
    COI-Ikegami-3.1         0.00002       1.00       0.00009          
    COI-Ikegami-3.1.1       0.00003       1.00       0.00013           
    COI-Ikegami-3.1.2       0.00003       1.00       0.00011           
    COI-BCDT-Sep            0.00100       1.00       0.00210      2.10
    COI-MER                 0.07081       1.00       0.09105      1.29
    ------------------------------------------------------------------
       Average              0.00453       1.00       0.00566      1.14

  So there are still problems with COI-ERMGH, COI-CHILD, COI-ERRVH,
  COI-BCDT-Sep, and COI-MER.  And now for INRC2-4:

    Instances (20)         LOR17                    KHE26
                           Cost         Rel.         Cost        Rel.
    ----------------------------------------------------------------------
    INRC2-4-030-1-6291   0.01695       1.00       0.01770       1.04
    INRC2-4-030-1-6753   0.01890       1.00       0.01885       1.00
    INRC2-4-035-0-1718   0.01425       1.00       0.01530       1.07
    INRC2-4-035-2-8875   0.01155       1.00       0.01260       1.09
    INRC2-4-040-0-2061   0.01685       1.00       0.01795       1.07
    INRC2-4-040-2-6106   0.01890       1.00       0.02030       1.07
    INRC2-4-050-0-0487   0.01505       1.00       0.01635       1.09
    INRC2-4-050-0-7272   0.01500       1.00       0.01545       1.03
    INRC2-4-060-1-6115   0.02505       1.00       0.02815       1.12 *
    INRC2-4-060-1-9638   0.02750       1.00       0.03165       1.15 *
    INRC2-4-070-0-3651   0.02435       1.00       0.02810       1.15 *
    INRC2-4-070-0-4967   0.02175       1.00       0.02490       1.14 *
    INRC2-4-080-2-4333   0.03340       1.00       0.03770       1.13 *
    INRC2-4-080-2-6048   0.03260       1.00       0.03810       1.17 *
    INRC2-4-100-0-1108   0.01245       1.00       0.01485       1.19 *
    INRC2-4-100-2-0646   0.01950       1.00       0.02220       1.14 *
    INRC2-4-110-0-1428   0.02440       1.00       0.02645       1.08
    INRC2-4-110-0-1935   0.02560       1.00       0.02835       1.11 *
    INRC2-4-120-1-4626   0.02170       1.00       0.02410       1.11 *
    INRC2-4-120-1-5698   0.02220       1.00       0.02585       1.16
    ----------------------------------------------------------------------
        Average          0.02089       1.00       0.02324       1.11

  Now getting ready for posting the current version of KHE and HSEval
  on my web site.  It will be Version 2.15.  I've set that in externs.h.
  The HSEval binary goes in directory /usr/lib/cgi-bin (or equivalently
  /lib/cgi-bin), both at home and on my web site.


To Do
=====

  Do some testing to make sure that the order in which I am
  currently calling the grouping algorithms is the best.

  I've decided to work on COI-ORTEC01, COI-Valouxis-1, and COI-BCDT-Sep,
  to see if I can break through the bottlenecks that have held the
  solver back on these instances for a long time.  COI-ORTEC01 is
  first and going very well.  Also COI-GPost and COI-GPost-B.

  Now that -flto is working, I might need one version of the compile
  with -flto and without -g, and another version without -flto and with
  -g.  So that's something to do.  At present I'm running with -g.

  Grinding down COI-MER.  Don't whynot Nurse997061, it is very anomalous.
  Also not Nurse960032's free and busy weekend defects, because the
  best solution also has them.
  .
  Grinding down COI-MER.  The focus now needs to be on limit busy
  times defects.  These are where the problems are after 60 minutes.
  If we are going to do this properly, we should find optimal
  timetables for each resource independently and see what
  constraints are violated by those optimal solutions.

  ------------------------------------------------
  The to do list is low priority below this point.
  ------------------------------------------------

  In INRC2-8-030-1-27093606 there are mtasks that do not satisfy the
  usual conditions (no gaps etc.).  I need to look into these mtasks.
  At present DRS just returns, after doing nothing, in these cases.

  Combination reduction has a way of identifying complete
  weekends constraints even when they are not explicitly
  present.  Shouldn't this be imported into weekend grouping?

  Added KheResourceTimetableMonitorAddProperRootTasksInTimeRange
  and KheResourceTimetableMonitorAddProperRootTasksInInterval.
  But I note that there is already a function in the mtask finder:
  KheAddResourceProperRootTasksInInterval, which seems to be
  unused.  It has a slightly different `wholly within' aspect.

  Resource matching has a task equivalencing aspect that might
  be replaceable by multi-tasks.  I need to look into that.
  There is an issue in that there is potentially a lot of task
  grouping going on, which doesn't interact well with mtasks.

  If swapping to the end helped, what about swapping back to
  the front?  There is a history problem, but anyway.

  What about some more non-trivial repairs?  Let's look for them.
  .
  Here's an idea for a repair:  if a sequence is too short, try
  moving it all to another resource where there is room to make
  it longer.  KheResourceUnderloadAugment will in fact do nothing
  at all in these cases, so we really do need to do something,
  even an ejecting move on that day.
  .
  What about a repair that breaks a run of length 2 into two 
  runs and reassigns them to different resources?  There are
  a lot of options, we'd have to be careful to limit the choices,
  e.g. to suitable resources that are free at those times.  Need
  an example where it would help before diving in.

  We have several layers:

      the platform (KheTaskMove etc.)
      the task grouper (KheTaskGrouperMakeGroup)
      the mtask finder, which needs adjusting as tasks change
      the solution adjuster, which needs to be able to undo

  I'm not convinced that these are currently fitting together
  in the right way.

  Can we do just narrow widening at first and save the more
  expensive wider repairs and similar things for last resort?

  The shift just to the left or right in a limit active intervals
  defect does not influence the choice of tasks.  Instead, all
  mtasks are tried as kernel tasks.  And the assignments are not
  ejecting assignments either.  So there are improvements to be
  made here - or are there?

  What about resource rematching?  Does it work on specific
  defects, does it work over several days?  No and yes.  We
  could target it at specific defects, if we wanted to.
  Something like we do with VLSN search, perhaps the same.
  Could we even *call* it from VLSN search?

  Perhaps it's a mistake to stick to tasks with the same frame
  offset.  Perhaps we need to be able to move night shifts to
  adjacent to day shifts, etc.  Anyway I'm doing it for now.

  It would be good to make creation and deletion of iterators more
  uniform.  Some of them definitely need creation and deletion,
  others not so much.  Could we have exactly two versions?

  Do I have this right?  In COI-Mer, to remove the consecutive
  free weekends defects, one option is to assign 2Sat-3Sun.  But
  if you do that, you are increasing workload during two monitored
  intervals: 1Sun-2Sat, and 3Sun-4Sat.

  Can we do workload is tight *per resource*?

  Could we accept chains whose cost increases by a small amount?

  Perhaps we could exclude low-cost monitors from start_gm on
  the first run of ejection chains.  Anyway we could do it as
  an experiment.  But just getting ejection chains to run faster
  would be the simple way forward.  If we could do in 5 minutes
  what we are doing now in something closer to 60 minutes (a
  speedup factor of 12, not impossible), that would be brilliant.

  Do something about constraints with step cost functions, if only
  so that I can say in the paper that it's done.

  Change KHE's general policy so that operations that change
  nothing succeed.  Having them fail composes badly.  The user
  will need to avoid cases that change nothing.

  In Ozk*, there are two skill types (RN and Aid), and each
  nurse has exactly one of those skills.  Can this be used to
  convert the limit resources constraints into assign resource
  and prefer resources constraints?

  Ejection chains idea:  include main loop defect ejection trees
  in the major schedule, so that, at the end when main loop defects
  have resisted all previous attempts to repair them, we can try
  ejection trees on each in turn.  Make one change, produce several
  defects, and try to repair them all.  A good last resort?

  Ejection chains idea:  instead of requiring an ejection chain
  to improve the solution by at least (0, 1), require it to
  improve it by a larger amount, at first.  This will run much
  faster and will avoid trying to fix tiny problems until there
  is nothing better to do.  But have I already tried it?  It
  sounds a lot like es_limit_defects.

  (High school timetabling)  Take a look at UK-SP-06 from XHSTT-2014.
  The results are quite a lot worse than they used to be.

  (High school timetabling)  Is there a repair that swaps the times
  of two meets that share a preassigned resource?  There ought to be,
  and it ought to work pretty darn well.

  (High school timetabling)  There are places when KheSwapRepair and
  KheMoveRepair can't be called because there is no mtask finder
  during time repair.  I need to be able to execute these kinds of
  repairs not just on mtasks but also on tasks - or something.

  --------- An interesting variant of ejection chains -------
  -Here's an interesting proposal for a variant of ejection chains.
  -Have just one repair operation, which is a minimum-cost bipartite
  -matching of all resources to their tasks, over an arbitrary
  -sequence of adjacent days.  Each resource can match with the
  -sequence of tasks initially assigned to itself or to some
  -other resource, or alternatively to a free day.
  -
  -When building the bipartite graph, we may choose to leave
  -out certain edges.  For example, if we are trying to unassign
  -a resource at a certain time, we leave out all the edges that
  -assign it to some task.  Or if we are trying to assign it
  -then, we leave out its current edge, the one that causes
  -it to be unassigned.  Actually we could just nominate the
  -resource or task and declare that its current edge should
  -be omitted.
  -
  -Then we link together these rematchings using ejection
  -chains.  We decide on a repair of a single task or set of
  -tasks, which is to either force their assignment or force
  -their unassignment, and we make this happen by building
  -the bipartite graph with the appropriate omissions.
  -
  -How to prevent cycling within one chain is a question.
  -We could use the usual "don't visit the same monitor
  -twice" or rather "don't alter the same monitor twice".
  -Alternatively, we could insist that no chain visit any
  -given day twice.
  -
  -The existing rematch module allows you to build the
  -demand nodes for a given set of supply nodes and re-use
  -those demand nodes.  I could use that; I could cache
  -sets of demand nodes as they are built for the first time,
  -and re-use the cached values.  The actual solve call
  -would need to be passed a fixed non-edge separately.
  -
  -(1) Decide to move some task, or sequence of adjacent tasks.  We
      need good analysis to produce a smallest set of adjacent
      tasks that is likely to work well for the current defect.
  -
  -(2) Weighted bipartite match over that sequence of adjacent days.
  -
  -Before building the whole matching, see the effect of the
  -proposed change on the resource or task affected, and only
  -proceed if it improves the initial defect and does not
  -introduce any more.  Then build the full graph and proceed.
  -Could bury this whole aspect into the repairer.
  -
  -One repair equals one time interval plus a (supply, demand)
  -edge such that that edge must be omitted from the graph.
  -This will drive the solution away from the current solution.
  --------- An interesting variant of ejection chains -------

  -------------------- XUTT -----------------------------------
  +Currently giving XUTT a rest for a while.  Here is its to do
  +list, prefixed by + characters:

  +Can distinct() be used for distinct times?  Why not?  And also
  +using it for "same location" might work.

  +I've finished university course timetabling, except for MaxBreaks
  +and MaxBlock, which I intend to leave for a while and ponder over
  +(see below).  I've also finished sports scheduling except for SE1
  +"games", which I am waiting on Bulck for but which will not be a
  +problem.

  +MaxBreaks and MaxBlock
  +----------------------

    +These are challenging because they do the sorts of things that
    +pattern matching does (e.g. idle times), but the criterion
    +which determines whether two things are adjacent is different:

      +High school timetabling - adjacent time periods
      +Nurse rostering - adjacent days
      +MaxBreaks and MaxBlock - intervals have gap of at most S.

    +It would be good to have a sequence of blocks to iterate over,
    +just like we have some subsequences to iterate over in high
    +school timetabling and nurse rostering.  Then MaxBreaks would
    +utilize the number of elements in the sequence, and MaxBlock
    +would utilize the duration of each block.

    +We also need to allow for future incorporation of travel time 
    +into MaxBreaks and MaxBlock.  Two events would be adjacent if
    +the amount of time left over after travelling from the first
    +to the second was at most S.

    +Assuming a 15-week semester and penalty 2:

    +MaxBreaks(R, S):

	+<Tree val="sum|15d">
	    +<ForEach v="$day" from="Days">
		+<Tree val="sum:0-(R+1)|2">
		    +<ForEachBlock v="$ms" gap="S" travel="travel()">
			+<AtomicMeetSet e="E" t="$day">
			+<Tree val="1">
		    +</ForEachBlock>
		+</Tree>
	    +</ForEach>
	+</Tree>

    +MaxBlock(M, S):

	+<Tree val="sum|15d">
	    +<ForEach v="$day" from="Days">
		+<Tree val="sum:0-M|2">
		    +<ForEachBlock v="$ms" gap="S" singles="no" travel="travel">
			+<AtomicMeetSet e="E" t="$day">
			+<Tree val="$ms.span:0-M|1s">
		    +</ForEachBlock>
		+</Tree>
	    +</ForEach>
        +</Tree>

    +Actually it might be better if each iteration produced a meet set.
    +We could then ask for span and so forth as usual.  There is also
    +a connection with spacing(a, b).  In fact it would be good to
    +give a general expression which determines whether two
    +chronologically adjacent meets are in the same block.
    +Then we could use "false" to get every meet into a separate
    +block, and then spacing(a, b) would apply to each pair of
    +adjacent blocks in the ordering.  If "block" has the same
    +type as "meet set", we're laughing.

    +I'll let this lie fallow for a while and come back to it.

  +Rather than sorting meets and defining cost functions which
  +are sums, can we iterate over the sorted meets?

  +The ref and expr attributes of time sequences and event sequences
  +do the same thing.

  +There is an example of times with attributes in the section on
  +weighted domain constraints.  Do we want them?  How do they fit
  +with time pattern trees?  Are there weights for compound times?

  +Moved history from Tree to ForEachTimeGroup.  This will be
  +consistent with pattern matching, and more principled, since
  +history in effect extends the range of the iterator.  But
  +what to do about general patterns?  We need to know how each
  +element of the pattern matches through history.

  +Could use tags to identify specific task sets within patterns.

  +UniTime requirements not covered yet:

    +Need an efficient way to list available rooms and their
    +penalties.  Nominally this is done by task constraints but
    +something more concise, which indicates that the domain
    +is partitioned, would be better.

    +Ditto for the time domain of a meet.

    +SameStart distribution constraint.  Place all times
    +with the same start time in one time group, have one
    +time group for each distinct starting time, and use
    +a meet constraint with type count and eval="0-1|...".

    +SameTime is a problem because there is not a simple
    +partition into disjoint sets of times.  Need some
    +kind of builtin function between pairs of times, but
    +then it's not clear how this fits in a meet set tree.

    +DifferentTime is basically no overlap, again we seem
    +to need a binary attribute.

    +SameDays and SameWeeks are cluster constraints, the limit
    +would have to be extracted from the event with the largest
    +number of meets, which is a bit dodgy.

    +DifferentDays and DifferentWeeks just a max 1 on each day
    +or week.

    +Overlap and NotOverlap: need a binary for the amount of
    +overlap between two times, and then we can constrain it
    +to be at least 1 or at most 0.  NB the distributive law

       +overlap(a+b, c+d) = overlap(a, c) + overlap(a, d)
         ++ overlap(b, c) + overlap(b, d)

    +but this nice property is not going to hold for all
    +binary attributes.

    +Precedence: this is the order events constraint, with
    +"For classes that have multiple meetings in a week or
    +that are on different weeks, the constraint only cares
    +about the first meeting of the class."  No design for
    +this yet.

    +WorkDay(S): "There should not be more than S time slots
    +between the start of the first class and the end of the
    +last class on any given day."  This is a kind of avoid
    +idle times constraint, applied to events rather than to
    +resources (which for us is a detail).
      +One task or meet set per day, and then a special function
    +(span or something) to give the appropriate measure.  But
    +how do you define one day?  By a time group.

    +MinGap(G): Any two classes that are taught on the same day
    +(they are placed on overlapping days and weeks) must be at
    +least G slots apart.  Not sure what to make of this.
    +I guess it's overlap(a, b, extension) where extension
    +applies to both a and b.

    +MaxDays(D): "Given classes cannot spread over more than D days
    +of the week".  Just a straight cluster constraint.

    +MaxDayLoad(S): "Given classes must be spread over the days
      +of the week (and weeks) in a way that there is no more
      +than a given number of S time slots on every day."  Just
      +a straight limit busy times constraint, measuring durations.
      +But not the full duration, rather the duration on one day.

      +This is one of several indications that we cannot treat
      +a non-atomic time as a unit in all cases.

    +MaxBreaks(R,S): "MaxBreaks(R,S) This constraint limits the
      +number of breaks during a day between a given set of classes
      +(not more than R breaks during a day). For each day of week
      +and week, there is a break between classes if there is more
      +than S empty time slots in between."  A very interesting
      +definition of what it means for two times to be consecutive.

    +MaxBlock(M,S): "This constraint limits the length of a block
      +of consecutive classes during a day (not more than M slots
      +in a block). For each day of week and week, two consecutive
      +classes are considered to be in the same block if the gap
      +between them is not more than S time slots."  Limit active
      +intervals, interpreted using durations rather than times.

  +Need a way to define time *groups* to take advantage of symmetries.
  +e.g. 1-15{MWF}3 = {1-15M3, 1-15W3, 1-15F3}.  All doubles:
  +[Mon-Fr][12 & 23 & 45 & 67 & 78] or something.
  +{MWF:<time>} or something.  But what is the whole day anyway?
  +All intervals, presumably. {1-15:{MTWRF:1-8}

  +See 16 April 2019 for things to do with the XUTT paper.
  --------------------------- XUTT--------------------------------
