Feature proposal: Add restricted/allowed assignments to quadratic_assignment()

Hello SciPy developers and maintainers,

During my PhD, I modified the implementation of the ‘faq' algorithm inside scipy.optimize.quadratic_assignment() so that it can handle forbidden assignments between nodes.

Motivation

During my PhD in neuroscience, I frequently needed to forbid certain node-to-node mappings, and I believe that restricting the assignment of a node to only a subset of nodes would be useful for other scientific domains.

Proposed feature

Add a new optional argument, for example allowed, which is a boolean matrix of shape (n_nodes, n_nodes).

  • allowed[i, j] = True means assignment of node i to node j is allowed,

  • allowed[i, j] = False means this assignment is forbidden.

The FAQ algorithm would then respect these constraints when solving the quadratic assignment problem.

I would be happy to open a pull request for this implementation, including documentation and tests. So please let me know if this feature is worth integrating.

Thank you for your time and for maintaining SciPy!

How substantial is the modification, a few lines or many?

A few lines,

Thank you,

Yanis