Try to fix the NaN and Inf problem on branch simulate, need test.