Given the following:
- A set of input types $I$ = {a, b, d, ...}
- A set of functions $F$ (With associated costs, and possibly identical signatures) = {($c_1$, a -> d), ($c_2$, (a,b) -> e), ($c_3$, e -> (d,f)), ...}
- A set of desired output types $O$ = {f, g, h, ...}
I would like to build a system that can return the lowest cost set of functions in $F$ which need to be called to generate $O$ from $I$, if such a set exists (Let's call this subset $R$ ).
By "generate" I mean that for each $o \in O$ there is a function in the returned subset $R$ that includes $o$ among its outputs; and for each function in $R$, all of its inputs are either in $I$ or are outputs of other earlier functions.
If $F$ consisted of only single-variable functions this would be easy, as I could just use a graph with types as vertices and functions as edges, then find the shortest path from available input type vertices to desired output type vertices. With multi-input/multi-output functions I can still do this, but I have to make multiple re-traversals through the graph if I find that I do not yet have a function in the selected collection that can generate one or more of the inputs required for a particular function.
The best idea I've come up with to deal with the multi-input/multi-output function scenario is to still use a graph (a DAG specifically), but have each vertex represent a full collection of currently available types, with each edge representing a function, and many duplicate edges representing the same function being called using the required inputs from many different overlapping collections in the graph.
I'm looking for confirmation on whether or not this is a good approach, and any recommendations on alternative data structures or algorithms to solve this problem effectively.