private static int BinPackComparer(BinPack a, BinPack b, Stuff s) { //tolerance double nearDecidingRate = 1.2; //binPackSet double aVolume = a.Volume; double bVolume = b.Volume; double aCost = a.GetCost(); double bCost = b.GetCost(); double aProperity = Math.Abs(a.GetCost() - s.Volume); double cProperity = Math.Abs(b.GetCost() - s.Volume); double sVolume = s.Volume; //decider bool IsAMoreProper = aProperity < cProperity; // if (aVolume <= 0) { if (bVolume <= 0) { if (IsAMoreProper) { return(-1); } return(1); } if (bCost >= sVolume) { return(1); } else { if (IsAMoreProper) { return(-1); } return(1); } } else { if (bVolume <= 0) { if (aCost >= sVolume) { return(-1); } else { if (IsAMoreProper) { return(-1); } return(1); } } if (aCost <= sVolume) { if (bCost <= sVolume) { if (IsAMoreProper) { return(-1); } return(1); } if (aCost * nearDecidingRate >= sVolume) { return(-1); } return(1); } if (bCost <= sVolume) { if (bCost * nearDecidingRate >= sVolume) { return(1); } return(-1); } if (IsAMoreProper) { return(-1); } return(1); } }