Here you can find the source of createNormativeTroopAllocation( List
Parameter | Description |
---|---|
probs | a parameter |
public static List<Integer> createNormativeTroopAllocation( List<Integer> probs)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**/* w ww. j av a 2 s . co m*/ * Creates a troop allocation where 100% of troops are allocated against the group or location with the highest probability. * * @param probs * @return */ public static List<Integer> createNormativeTroopAllocation( List<Integer> probs) { if (probs != null && !probs.isEmpty()) { ArrayList<Integer> I = new ArrayList<Integer>(probs.size()); int maxProb = Integer.MIN_VALUE; int maxProbIndex = 0; int i = 0; for (Integer prob : probs) { if (prob > maxProb) { maxProb = prob; maxProbIndex = i; } i++; } for (i = 0; i < probs.size(); i++) { if (i == maxProbIndex) { I.add(100); } else { I.add(0); } } return I; } return null; } }