![]() ![]() %Create an initial xij matrix, each column of which consists of a random binary xij sequence, but sum of ones in each column equals to sj In order to keep track of the amount of ones, the du is lowered by 1 every time a 1 is added to the corresponding row, and likewise the desired value s(j) is subtracted by 1 every time a 1 is added to that column of the xij matrix. The if statement in the first for loop ensures that a 1 isn't added if that column has already reached its desired value, and the if statement in the second for loop ensures that a 1 isn't added to a row that would put it over the maximum value of the row. The next for loop adds 1s along the columns such that each column adds up to the desired value. The first for loop adds 1s along the rows such that each row satisfies the minimum constraint. ![]() %make sure the columns all add to their specified values ![]() %make sure the lower bounds are first satisfied After this has been done, the following code should be one solution to the problem, but given the nature of the problem, there will probably not be a unique solution. First, you must check that the sum of s(j), sum(s) is greater than the sum of the lower bound constraints, sum(dl), and also less than the sum of the upper bound constraints, sum(du).Ī simple if statement should be able to check this. There are a couple things to first take into account, mainly if the problem can even be solved with the given constraints.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |