0

In the documentation and all examples I can find... in terms of nurse scheduling at least, everyone just declares shift values within the search space of {1,4} lets say for shift 1,2,3,4....

solver = pywrapcp.Solver("schedule_shifts")

  num_nurses = 4
  num_shifts = 4     # Nurse assigned to shift 0 means not working that day.
  num_days = 7
  # [START]
  # Create shift variables.
  shifts = {}

  for j in range(num_nurses):
    for i in range(num_days):
      shifts[(j, i)] = solver.IntVar(0, num_shifts - 1, "shifts(%i,%i)" % (j, i))
  shifts_flat = [shifts[(j, i)] for j in range(num_nurses) for i in range(num_days)]

  # Create nurse variables.
  nurses = {}

  for j in range(num_shifts):
    for i in range(num_days):
      nurses[(j, i)] = solver.IntVar(0, num_nurses - 1, "shift%d day%d" % (j,i))

I want to avoid the use of range of values when I call solver.IntVar(lowerbound, upperbound, ...)

I want IntSolver([available values that you can choose], ...)

I created a matrix of all shifts as the columns flowing from the first day to last. My row indexes don't matter but in each day/shift column, I have the index values of nurses in ranked descending order of who bid the highest for that shift. I want to create then a constraint where if I choose a nurse, I choose the maximum bid that is allowed via other constraints from the column, however I don't know how to do that given the limited documentation ortools has with python IntVar.

Gilles-Antoine Nys
  • 1,481
  • 16
  • 21
RobRen
  • 101
  • 11

1 Answers1

0

Can you try

solver.IntVar([values...], 'name')

It should work.

See https://github.com/google/or-tools/blob/master/examples/python/einav_puzzle2.py

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22