Advertisement
Guest User

MRO Emission

a guest
May 27th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.59 KB | None | 0 0
  1. function [  ] = cni( years, ms )
  2.  
  3. %% Parameters
  4. MSupply = 2^64 - 1;                         % Maximum atomic units
  5.  
  6. block_rate = 60;                            % 30 in BCN, 60 in MRO
  7. bit_shift = 2^20;                           % >>18 in BCN, >>20 in MRO
  8. decimal_shift = 1e12;                       % 10^8 in BCN, 10^12 in MRO
  9. minimum_subsidy = ms * decimal_shift;       % lower limit of block rewards
  10.  
  11. blocks_per_year = 365 * 24 * block_rate;    % block generation per year
  12. height = years * blocks_per_year;           % block number at final year
  13.  
  14. %% Initialize
  15. A = zeros(height,1);
  16. BaseReward = zeros(height,1);
  17. Daily = zeros(height,1);
  18. minimum_flag = 1;
  19.  
  20. %% Main Loop
  21. for i = 1:1:height
  22.    
  23.     BaseReward(i) = (MSupply - A(i)) ./ bit_shift;
  24.  
  25.     if((BaseReward(i) <= minimum_subsidy) && minimum_flag)
  26.         BaseReward(i) = minimum_subsidy;
  27.     end
  28.    
  29.     Daily(i) = 24*60*BaseReward(i);
  30.     A(i+1) = A(i) + BaseReward(i);
  31.    
  32. end
  33.  
  34. %% Plotting
  35.  
  36. inflation = 100 .* blocks_per_year .* BaseReward ./ A(1:end-1);
  37. BaseReward_adjusted = BaseReward./decimal_shift;
  38. A_adjusted = A./decimal_shift;
  39. Daily_adjusted = Daily./decimal_shift;
  40.  
  41. x_axis = linspace(0,years,height+1);
  42.  
  43. figure(1)
  44. plot(x_axis(1:end-1), BaseReward_adjusted, '-b', 'LineWidth', 2)
  45. set(gcf, 'PaperPositionMode', 'auto','color','w');
  46. set(gca, 'FontSize', 20);
  47. xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
  48. ylabel('Block Reward','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
  49. set(get(gca,'YLabel'),'Rotation',90);
  50.  
  51. figure(2)
  52. plot(x_axis, A_adjusted, '-b', 'LineWidth', 2)
  53. hold on
  54. plot(x_axis, 18.446e6 .* ones(height+1,1), '--k', 'LineWidth', 2)
  55. hold off
  56. set(gcf, 'PaperPositionMode', 'auto','color','w');
  57. set(gca, 'FontSize', 20);
  58. xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
  59. ylabel('Circulation','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
  60. set(get(gca,'YLabel'),'Rotation',90);
  61.  
  62. figure(3)
  63. plot(x_axis(1:end-1), inflation, '-r', 'LineWidth', 2)
  64. ylim([0,10])
  65. xlim([0,years])
  66. set(gcf, 'PaperPositionMode', 'auto','color','w');
  67. set(gca, 'FontSize', 20);
  68. xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
  69. ylabel('Inflation','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
  70. set(get(gca,'YLabel'),'Rotation',90);
  71.  
  72. figure(4)
  73. plot(x_axis(1:end-1), Daily_adjusted, '-r', 'LineWidth', 2)
  74. ylim([0,18*24*60])
  75. xlim([0,years])
  76. set(gcf, 'PaperPositionMode', 'auto','color','w');
  77. set(gca, 'FontSize', 20);
  78. xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
  79. ylabel('Daily Production','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
  80. set(get(gca,'YLabel'),'Rotation',90);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement