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;

  • > At the moment, this problem is 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. Use Visual Studio Express. And the task itself is not very clear. Perhaps give a small example with the decision? - Donil
  • In short, as follows: There is a set of different parts (for example, many different processors, video cards, motherboards, and something else). As constraints there will be incompatibility of various processors, video cards with mat boards defined. kind of. At the beginning of the solution of the problem, restrictions are placed on the number of parts, for example, no more than five, and a rating of parts is set (the higher the values, the greater the chance that it will be included in the result of the solution). When deciding to go through all the restrictions and choose the most appropriate set of parts. - PastoriXx
  • Well, what exactly is the problem? Problems with the algorithm (here we will not help you) or with the implementation (then tell me what exactly does not work)? - VladD
  • @VladD: "The main problem is how to check logical constraints, when they can change, during the course of the program." Those. if the restrictions were not changed, then there are no problems, just write them all in a row and pass an array through them. But since in the course of the program they can be added, then I do not know what to do. It is impossible to add restrictions to the code after compilation. I would create some kind of array with restrictions that can be updated during the program and each element of which would return a result (whether the elements are suitable or not). - PastoriXx
  • Code - not. Data - you can. - alexlz

0