|
Lines 37-43
Link Here
|
| 37 |
public static boolean DEBUG_GROUPING = false; |
37 |
public static boolean DEBUG_GROUPING = false; |
| 38 |
public static boolean DEBUG_CYCLES = false; |
38 |
public static boolean DEBUG_CYCLES = false; |
| 39 |
private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10; |
39 |
private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10; |
| 40 |
private static long MAX_COMBINATIONS = 1000000; |
40 |
private static int MAX_USES_TIME_BASE = 30000; // 30 seconds |
|
|
41 |
private static int MAX_USES_TIME_LIMIT = 90000; // 90 seconds |
| 41 |
|
42 |
|
| 42 |
private static String[][] CURRENT_EES; |
43 |
private static String[][] CURRENT_EES; |
| 43 |
|
44 |
|
|
Lines 585-591
Link Here
|
| 585 |
} |
586 |
} |
| 586 |
ResolverConstraint[][] multipleSuppliers = getMultipleSuppliers(bundles, packageConstraints, bundleConstraints); |
587 |
ResolverConstraint[][] multipleSuppliers = getMultipleSuppliers(bundles, packageConstraints, bundleConstraints); |
| 587 |
ArrayList conflicts = null; |
588 |
ArrayList conflicts = null; |
| 588 |
if (multipleSuppliers.length > 0 && getNumCombinations(multipleSuppliers) < MAX_COMBINATIONS) { |
589 |
if (multipleSuppliers.length > 0) { |
| 589 |
int[] bestCombination = new int[multipleSuppliers.length]; |
590 |
int[] bestCombination = new int[multipleSuppliers.length]; |
| 590 |
conflicts = findBestCombination(bundles, multipleSuppliers, bestCombination, initialConflicts); |
591 |
conflicts = findBestCombination(bundles, multipleSuppliers, bestCombination, initialConflicts); |
| 591 |
for (int i = 0; i < bestCombination.length; i++) { |
592 |
for (int i = 0; i < bestCombination.length; i++) { |
|
Lines 601-616
Link Here
|
| 601 |
return conflicts; |
602 |
return conflicts; |
| 602 |
} |
603 |
} |
| 603 |
|
604 |
|
| 604 |
private long getNumCombinations(ResolverConstraint[][] multipleSuppliers) { |
|
|
| 605 |
if (multipleSuppliers == null || multipleSuppliers.length == 0) |
| 606 |
return 0; |
| 607 |
long numCombinations = multipleSuppliers[0][0].getNumPossibleSuppliers(); |
| 608 |
for (int i = 1; i < multipleSuppliers.length; i++) |
| 609 |
if (multipleSuppliers[i].length > 0) |
| 610 |
numCombinations *= multipleSuppliers[i][0].getNumPossibleSuppliers(); |
| 611 |
return numCombinations; |
| 612 |
} |
| 613 |
|
| 614 |
private int[] getCombination(ResolverConstraint[][] multipleSuppliers, int[] combination) { |
605 |
private int[] getCombination(ResolverConstraint[][] multipleSuppliers, int[] combination) { |
| 615 |
for (int i = 0; i < combination.length; i++) |
606 |
for (int i = 0; i < combination.length; i++) |
| 616 |
combination[i] = multipleSuppliers[i][0].getSelectedSupplierIndex(); |
607 |
combination[i] = multipleSuppliers[i][0].getSelectedSupplierIndex(); |
|
Lines 621-629
Link Here
|
| 621 |
// now iterate over every possible combination until either zero conflicts are found |
612 |
// now iterate over every possible combination until either zero conflicts are found |
| 622 |
// or we have run out of combinations |
613 |
// or we have run out of combinations |
| 623 |
// if all combinations are tried then return the combination with the lowest number of conflicts |
614 |
// if all combinations are tried then return the combination with the lowest number of conflicts |
|
|
615 |
long initialTime = System.currentTimeMillis(); |
| 616 |
long timeLimit = MAX_USES_TIME_BASE + (bundles.length * 30); |
| 617 |
if (timeLimit > MAX_USES_TIME_LIMIT) |
| 618 |
timeLimit = MAX_USES_TIME_LIMIT; |
| 624 |
int bestConflictCount = getConflictCount(bestConflicts); |
619 |
int bestConflictCount = getConflictCount(bestConflicts); |
| 625 |
ResolverBundle[] bestConflictBundles = getConflictedBundles(bestConflicts); |
620 |
ResolverBundle[] bestConflictBundles = getConflictedBundles(bestConflicts); |
| 626 |
while (bestConflictCount != 0 && getNextCombination(multipleSuppliers)) { |
621 |
while (bestConflictCount != 0 && (System.currentTimeMillis() - initialTime) < timeLimit && getNextCombination(multipleSuppliers)) { |
| 627 |
if (DEBUG_GROUPING) |
622 |
if (DEBUG_GROUPING) |
| 628 |
printCombination(getCombination(multipleSuppliers, new int[multipleSuppliers.length])); |
623 |
printCombination(getCombination(multipleSuppliers, new int[multipleSuppliers.length])); |
| 629 |
// first count the conflicts for the bundles with conflicts from the best combination |
624 |
// first count the conflicts for the bundles with conflicts from the best combination |