public override Bid GetWinnerBid() { if (Bids.Count == 0) { return(null); } else { //Steps //1 : I only send push requests that are valid //2 : Find all containers migration costs average var avgCost = Bids.Select(x => x.ContainerId).Select(x => Containers[x].MigrationCost).Average(); var NewBids = Bids.Where(x => Containers[x.ContainerId].MigrationCost >= avgCost).ToList(); ForsmanBid winner = NewBids.First(); var lds = ToBeHostLoadInfos(NewBids[0].BiddingHost, NewBids[0].NewLoadInfo); var bentropy = AccountingHelpers.CalculateEntropy(lds); //3: Find the new entropy after migration for (int i = 1; i < NewBids.Count; i++) { lds = ToBeHostLoadInfos(NewBids[i].BiddingHost, NewBids[i].NewLoadInfo); var entropy = AccountingHelpers.CalculateEntropy(lds); if (entropy > bentropy) { bentropy = entropy; winner = NewBids[i]; } } return(winner); } }
public void AddBid(ForsmanBid bid, double min, double max) { if (bid.Valid) { var state = bid.NewLoadInfo.CalculateTotalUtilizationState(min, max); if (state == UtilizationStates.Normal) { Bids.Add(bid); } } else { throw new NotImplementedException(); //InValidBids.Add(bid); } }