I'm looking for a way in C# that finds all the possible combinations with constraints.
I've got a list of machines. The machines have capabilities and limitations. I also have a document that defines the starting material and end result.
The machine capabilities is a flag enum with cut, print, joint. Constraints are specific to the capability of the machine. Constraint for cut example would be length/width of the starting material. print would be the number of different print patterns that can be done at once. Joint constraint is a list of GUIDs that refer to a joint object. if the machine has the joint GUID declared in the product document in it's list of joints it is capable of, then the machine should be selected as an option.
currently I've got functions that finds machines for each operation out of all the machines. I then intersect (linq intersect) the 3 lists (one list for each capability), and that produces my list of capable all-in-one machines.
but with these three lists, I now need to find all the combinations going from cut to print to joint. each combination goes into a flow object that represents this combination. basically a name and the list of machines in order.
As another wrench, the printing doesn't always happen.
Can someone help me finding or devising a solution for this please?
Edit for example:
lets say I have 6 machines. 3 that cut, 1 that prints, 2 that joints. I need to create a list for each possible combination that has 1 cut machine, 1 print machine, and 1 joint machine.
the desired outcome here would be:
{cut1, print1, joint1},
{cut1, print1, joint2},
{cut2, print1, joint1},
{cut2, print1, joint2},
{cut3, print1, joint1},
{cut3, print1, joint2}
sometimes, the provided instructions (document that defines the starting material and product size) don't call for printing. When this happens, using the same 6 machines, I need to create a list for each possible combination for 1 cut machine and 1 joint machine.
the desired outcome for this would be:
{cut1, joint1},
{cut1, joint2},
{cut2, joint1},
{cut2, joint2},
{cut3, joint1},
{cut3, joint2}
I've figured out how to filter out machines that don't have the capabilities defined in the instructions document and put those into list of capable cut/print/joint machines. Now i just need to find all the possible permutations of these three list, where each permutation includes one item from each list.