Browse Source

[research/lotterysim] handle 0 premint divin by zero case]

ertosns 3 năm trước cách đây
mục cha
commit
3aaf7e466c

+ 2 - 2
script/research/lotterysim/metrics.py

@@ -3,7 +3,7 @@ import config
 
 def percent_change(start, end):
     difference = end - start
-    change = (difference / start) * 100
+    change = (difference / start) * 100 if start!=0 else 0
     return change
 
 #def slot_number_at_target(count, supply, target_reached):
@@ -24,7 +24,7 @@ def percent_change(start, end):
 #    days = count / slots_per_day
 #    months = count / slots_per_month
 #    years = count / slots_per_year
-#    
+#
 #    print("Target supply of", str(target), "DRK was achieved after: ",
 #          str(count), "slots", str(days), "(D)", str(months), "(M)",
 #          str(years), "(Y)")

+ 2 - 2
script/research/lotterysim/vesting.py

@@ -24,8 +24,8 @@ def vesting_instance(vesting, running_time):
         airdrop = 0
         for darkie in darkies:
             airdrop+=darkie.stake
-        print("initial airdrop: {}/{}% on {} nodes".format(airdrop, airdrop/native_drk*100, len(darkies)))
-        print('total predistribution: {}/{}%'.format(total_vesting, total_vesting/native_drk*100))
+        print("initial airdrop: {}/{}% on {} nodes".format(airdrop, airdrop/native_drk*100 if native_drk!=0 else 0 , len(darkies)))
+        print('total predistribution: {}/{}%'.format(total_vesting, total_vesting/native_drk*100 if native_drk !=0 else 0))
         dt = DarkfiTable(airdrop, running_time, kp=-0.010399999999938556, ki=-0.0365999996461878, kd=0.03840000000000491,  r_kp=-2.53, r_ki=29.5, r_kd=53.77)
         for darkie in darkies:
             dt.add_darkie(darkie)