There is a matrix of elements (rows - type of element, columns - a type of type in a row), the value of elements can be from 0 to 10 (such as rating of elements, 0 - no element).
There are logical limitations (for example: the elements [1,2] and [2,3] cannot be simultaneously located in the solution), their number can vary. With the help of restrictions, a solution is selected in the form of a specific set of elements, and the number of these elements must not exceed a certain value that the user sets before solving the problem.
It is necessary to solve this problem in C #, you can use third-party free libraries. I use Visual Studio 2013.
The main problem is how to check logical constraints when they can change during the course of the program.
This problem is currently being solved with the help of ILOG OPL Studio 3.5. This studio is morally obsolete, and there is no possibility to buy anything new.
An example of restrictions in the ILOG:
// the final result must include one type of parts
Y [1,1] + Y [1,2] + Y [1,3] + Y [1,4] + Y [1,5] + Y [1,6] = 1;
// the first part is not combined with the second
Y [3,1] -Y [4,1] = 0;