The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

56 lines
1.4 KiB

4 weeks ago
  1. //Randomised Consensus Protocol
  2. mdp
  3. const double p1; // in [0.2 , 0.8]
  4. const double p2; // in [0.2 , 0.8]
  5. const int N=2;
  6. const int K=2;
  7. const int range = 2*(K+1)*N;
  8. const int counter_init = (K+1)*N;
  9. const int left = N;
  10. const int right = 2*(K+1)*N - N;
  11. // shared coin
  12. global counter : [0..range] init counter_init;
  13. module process1
  14. // program counter
  15. pc1 : [0..3];
  16. // 0 - flip
  17. // 1 - write
  18. // 2 - check
  19. // 3 - finished
  20. // local coin
  21. coin1 : [0..1];
  22. // flip coin
  23. [] (pc1=0) -> p1 : (coin1'=0) & (pc1'=1) + 1 - p1 : (coin1'=1) & (pc1'=1);
  24. // write tails -1 (reset coin to add regularity)
  25. [] (pc1=1) & (coin1=0) & (counter>0) -> (counter'=counter-1) & (pc1'=2) & (coin1'=0);
  26. // write heads +1 (reset coin to add regularity)
  27. [] (pc1=1) & (coin1=1) & (counter<range) -> (counter'=counter+1) & (pc1'=2) & (coin1'=0);
  28. // check
  29. // decide tails
  30. [] (pc1=2) & (counter<=left) -> (pc1'=3) & (coin1'=0);
  31. // decide heads
  32. [] (pc1=2) & (counter>=right) -> (pc1'=3) & (coin1'=1);
  33. // flip again
  34. [] (pc1=2) & (counter>left) & (counter<right) -> (pc1'=0);
  35. // loop (all loop together when done)
  36. [done] (pc1=3) -> (pc1'=3);
  37. endmodule
  38. module process2 = process1[pc1=pc2,coin1=coin2,p1=p2] endmodule
  39. label "finished" = pc1=3 &pc2=3 ;
  40. label "all_coins_equal_1" = coin1=1 &coin2=1 ;
  41. rewards "steps"
  42. true : 1;
  43. endrewards