public static TObjectIntMap < VM > getWeights ( ReconfigurationProblem rp , List < CShareableResource > rcs ) { Model mo = rp . getSourceModel ( ) ; int [ ] capa = new int [ rcs . size ( ) ] ; int [ ] cons = new int [ rcs . size ( ) ] ; TObjectIntMap < VM > cost = new TObjectIntHashMap <> ( ) ; for ( Node n : mo . getMapping ( ) . getAllNodes ( ) ) { for ( int i = 0 ; i < rcs . size ( ) ; i ++ ) { capa [ i ] += rcs . get ( i ) . virtRcUsage . get ( rp . getNode ( n ) ) . getUB ( ) * rcs . get ( i ) . ratios . get ( rp . getNode ( n ) ) /*.getLB()*/ ; } } for ( VM v : mo . getMapping ( ) . getAllVMs ( ) ) { for ( int i = 0 ; i < rcs . size ( ) ; i ++ ) { cons [ i ] += rcs . get ( i ) . getVMAllocation ( rp . getVM ( v ) ) ; } } for ( VM v : mo . getMapping ( ) . getAllVMs ( ) ) { double sum = 0 ; for ( int i = 0 ; i < rcs . size ( ) ; i ++ ) { double ratio = 0 ; if ( cons [ i ] > 0 ) { ratio = 1.0 * rcs . get ( i ) . getVMAllocation ( rp . getVM ( v ) ) / capa [ i ] ; } sum += ratio ; } cost . put ( v , ( int ) ( sum * 10000 ) ) ; } return cost ; }
Estimate the weight of each VMs with regards to multiple dimensions . In practice it sums the normalised size of each VM against the total capacity