Search code examples
constraint-programmingor-toolsmixed-integer-programminginteger-programming

What is the CP/MILP problem name for the assignment of agents to tasks with fixed start time and end time?


I'm trying to solve a Constraint Satisfaction Optimisation Problem that assigns agents to tasks. However, different then the basic Assignment Problem, a agent can be assigned to many tasks if the tasks do not overlap. Each task has a fixed start_time and end_time. The agents are assigned to the tasks according to some unary&binary constraints.

Variables = set of tasks

Domain = set of compatible agents (for each variable)

Constraints = unary&binary

Optimisation fct = some liniar function

An example of the problem: the allocation of parking space (or teams) for trucks for which we know the arrival and departure time.

I'm interested if there is in the literature a precise name for these type of problems. I presume it is some kind of assignment problem. Also, if you ever approach the problem, how do you solve it?

Thank you.


Solution

  • I would interpret this as: rectangular assignment-problem with conflicts which is arguably much more hard (NP-hard in general) than the polynomially-solvable assignment-problem.

    The demo shown in the other answer might work and ortools' cp-sat is great, but i don't see a good reason to use discrete-time based reasoning here like it's done: interval-variables, edge-finding and co. based scheduling constraints (+ conflict-analysis / explanations). This stuff is total overkill and the overhead will be noticable. I don't see any need to reason about time, but just about time-induced conflicts.

    Edit: One could label those two approaches (linked + proposed) as compact formulation and extended formulation. Extended formulations usually show stronger relaxations and better (solving) results as long as scalability is not an issue. Compact approaches might become more viable again with bigger data (bit it's hard to guess here as scheduling-propagators are not that cheap).

    What i would propose:

    • (1) Formulate an integer-programming model following the basic assignment-problem formulation + adaptions to make it rectangular -> a worker is allowed to tackle multiple tasks while all tasks are tackled (one sum-equality dropped)
    • (2) Add integrality = mark variables as binary -> because the problem is not satisfying total unimodularity anymore
    • (3) Add constraints to forbid conflicts
    • (4) Add constraints: remaining stuff (e.g. compatibility)

    Now this is all straightforward, but i would propose one non-naive improvement in regards to (3):

    • The conflicts can be interpreted as stable-set polytope
    • Your conflicts are induced by a-priori defined time-windows and their overlappings (as i interpret it; this is the core assumption behind this whole answer)
    • This is an interval graph (because of time-windows)
    • All interval graphs are chordal
    • Chordal graphs allow enumeration of all max-cliques in poly-time (implying there are only polynomial many)
    • The set (enumeration) of all maximal cliques define the facets of the stable-set polytope
    • Those (a constraint for each element in the set) we add as constraints!
    • (The stable-set polytope on the graph in use here would also allow very very powerful semidefinite-relaxations but it's hard to foresee in which cases this would actually help due to SDPs being much more hard to work with: warmstart within tree-search; scalability; ...)

    This will lead to a poly-size integer-programming problem which should be very very good when using a good IP-solver (commercials or if open-source needed: Cbc > GLPK).

    Small demo about (3)

    import itertools
    import networkx as nx
    
    # data: inclusive, exclusive
    # --------------------------
    time_windows = [
      (2, 7),
      (0, 10),
      (6, 12),
      (12, 20),
      (8, 12),
      (16, 20)
    ]
    
    # helper
    # ------
    def is_overlapping(a, b):
      return (b[1] > a[0] and b[0] < a[1])
    
    # raw conflicts
    # -------------
    binary_conflicts = [] 
    for a, b in itertools.combinations(range(len(time_windows)), 2):
      if is_overlapping(time_windows[a], time_windows[b]):
        binary_conflicts.append( (a, b) )
    
    # conflict graph
    # --------------
    G = nx.Graph()
    G.add_edges_from(binary_conflicts)
    
    # maximal cliques
    # ---------------
    max_cliques = nx.chordal_graph_cliques(G)
    
    print('naive constraints: raw binary conflicts')
    for i in binary_conflicts:
      print('sum({}) <= 1'.format(i))
    
    print('improved constraints: clique-constraints')
    for i in max_cliques:
      print('sum({}) <= 1'.format(list(i)))
    

    Output:

    naive constraints: raw binary conflicts
    sum((0, 1)) <= 1
    sum((0, 2)) <= 1
    sum((1, 2)) <= 1
    sum((1, 4)) <= 1
    sum((2, 4)) <= 1
    sum((3, 5)) <= 1
    improved constraints: clique-constraints
    sum([1, 2, 4]) <= 1
    sum([0, 1, 2]) <= 1
    sum([3, 5]) <= 1
    

    Fun facts:

    • Commercial integer-programming solvers and maybe even Cbc might even try to do the same reasoning about clique-constraints to some degree although without the assumption of chordality where it's an NP-hard problem
    • ortools' cp-sat solver has also a code-path for this (again: general NP-hard case)
      • Should trigger when expressing the conflict-based model (much harder to decide on this exploitation on general discrete-time based scheduling models)

    Caveats

    Implementation / Scalability

    There are still open questions like:

    • duplicating max-clique constraints over each worker vs. merging them somehow
    • be more efficient/clever in finding conflicts (sorting)
    • will it scale to the data: how big will the graph be / how many conflicts and constraints from those do we need

    But those things usually follow instance-statistics (aka "don't decide blindly").