Package jline.lib.mom.util
Class MomUtils
java.lang.Object
jline.lib.mom.util.MomUtils
MOM-specific utility functions for combinatorial operations
Complements the existing jline.util.Maths class
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcountNonZeros(int[] array) Count non-zero elements in an array.static inthashPop(int[] population, int[] maxPop) Hash a population vector to a unique index.static int[][]sortByNnzPos(int[][] combinations) Sort combinations by number of non-zeros and their positions.
-
Method Details
-
sortByNnzPos
public static int[][] sortByNnzPos(int[][] combinations) Sort combinations by number of non-zeros and their positions. This is used to optimize the order of processing in the solver.- Parameters:
combinations- Array of combinations to sort- Returns:
- Sorted array of combinations
-
countNonZeros
public static int countNonZeros(int[] array) Count non-zero elements in an array.- Parameters:
array- The array to count non-zeros in- Returns:
- Number of non-zero elements
-
hashPop
public static int hashPop(int[] population, int[] maxPop) Hash a population vector to a unique index. This is used for efficient lookup of population states.- Parameters:
population- The population vectormaxPop- Maximum population per class (for hash calculation)- Returns:
- Hash index
-