Terminate iteration when reach infinite weight