public static Map . Entry < Object , Object > hurwiczAlpha ( DataTable2D payoffMatrix , double alpha ) { if ( payoffMatrix . isValid ( ) == false ) { throw new IllegalArgumentException ( "The payoff matrix does not have a rectangular format." ) ; } AssociativeArray minPayoffs = new AssociativeArray ( ) ; AssociativeArray maxPayoffs = new AssociativeArray ( ) ; for ( Map . Entry < Object , AssociativeArray > entry : payoffMatrix . entrySet ( ) ) { //Object event = entry.getKey(); AssociativeArray optionList = entry . getValue ( ) ; for ( Map . Entry < Object , Object > entry2 : optionList . entrySet ( ) ) { Object option = entry2 . getKey ( ) ; Double payoff = TypeInference . toDouble ( entry2 . getValue ( ) ) ; Double currentMinPayoffOption = minPayoffs . getDouble ( option ) ; if ( currentMinPayoffOption == null || payoff < currentMinPayoffOption ) { minPayoffs . put ( option , payoff ) ; } Double currentMaxPayoffOption = maxPayoffs . getDouble ( option ) ; if ( currentMaxPayoffOption == null || payoff > currentMaxPayoffOption ) { maxPayoffs . put ( option , payoff ) ; } } } AssociativeArray combinedPayoffs = new AssociativeArray ( ) ; for ( Map . Entry < Object , Object > entry : maxPayoffs . entrySet ( ) ) { Object option = entry . getKey ( ) ; combinedPayoffs . put ( option , TypeInference . toDouble ( entry . getValue ( ) ) * alpha + minPayoffs . getDouble ( option ) * ( 1.0 - alpha ) ) ; } Map . Entry < Object , Object > entry = MapMethods . selectMaxKeyValue ( combinedPayoffs ) ; return entry ; }
Returns the best option and the payoff under hurwiczAlpha strategy