private static void distributeShareFair ( double total , final Collection < ? extends Schedulable > schedulables ) { BinarySearcher searcher = new BinarySearcher ( ) { @ Override protected double targetFunction ( double x ) { return totalShareWithRatio ( schedulables , x ) ; } } ; double ratio = searcher . getSolution ( total ) ; for ( Schedulable schedulable : schedulables ) { schedulable . share = shareWithRatio ( schedulable , ratio ) ; } }
Distribute the total share among the list of schedulables according to the FAIR model . Finds a way to distribute the share in such a way that all the min and max reservations of the schedulables are satisfied