mirror of
https://github.com/logos-co/scratch.git
synced 2025-02-23 11:48:33 +00:00
SUMMARIZE-ALL all files in a directory
This commit is contained in:
parent
d9c0eeebc6
commit
650b26d495
@ -1,35 +1,12 @@
|
|||||||
(in-package glacier)
|
(in-package glacier)
|
||||||
|
|
||||||
(defun json-parameters ()
|
|
||||||
`($.consensus_settings.glacier.evidence_alpha
|
|
||||||
0.8 ;;4/5
|
|
||||||
$.consensus_settings.glacier.evidence_alpha_2
|
|
||||||
0.4 ;;2/5
|
|
||||||
$.consensus_settings.glacier.confidence_beta
|
|
||||||
1
|
|
||||||
$.consensus_settings.glacier.look_ahead
|
|
||||||
997
|
|
||||||
$.consensus_settings.glacier.query.initial_query_size
|
|
||||||
100
|
|
||||||
$.consensus_settings.glacier.query.query_multiplier
|
|
||||||
2
|
|
||||||
$.consensus_settings.glacier.query.max_multiplier
|
|
||||||
1
|
|
||||||
$.byzantine_settings.total_size
|
|
||||||
,(expt 10 4)
|
|
||||||
$.byzantine_settings.distribution.honest
|
|
||||||
1
|
|
||||||
$.distribution.yes
|
|
||||||
0.5 ;;1/2
|
|
||||||
$.distribution.no
|
|
||||||
0.5))
|
|
||||||
|
|
||||||
(defparameter +consensus-simulations+
|
(defparameter +consensus-simulations+
|
||||||
(merge-pathnames
|
(merge-pathnames
|
||||||
"work/consensus-prototypes/target/release-opt/consensus-simulations"
|
"work/consensus-prototypes/target/release-opt/consensus-simulations"
|
||||||
(user-homedir-pathname)))
|
(user-homedir-pathname)))
|
||||||
|
|
||||||
(defun jsown-template ()
|
(defun jsown-template ()
|
||||||
|
"Return the json template in jsown format used for each run"
|
||||||
'(:OBJ
|
'(:OBJ
|
||||||
("consensus_settings"
|
("consensus_settings"
|
||||||
:OBJ
|
:OBJ
|
||||||
@ -48,21 +25,10 @@
|
|||||||
("wards" (:OBJ ("time_to_finality" :OBJ ("ttf_threshold" . 100))))
|
("wards" (:OBJ ("time_to_finality" :OBJ ("ttf_threshold" . 100))))
|
||||||
("network_modifiers" (:OBJ ("random_drop" :OBJ ("drop_rate" . 0))))))
|
("network_modifiers" (:OBJ ("random_drop" :OBJ ("drop_rate" . 0))))))
|
||||||
|
|
||||||
(defun grind ()
|
|
||||||
(let* ((template
|
|
||||||
(probe-file "~/work/consensus-prototypes/etc/glacier.json"))
|
|
||||||
(json
|
|
||||||
(alexandria:read-file-into-string template))
|
|
||||||
(result
|
|
||||||
(jsown:parse json)))
|
|
||||||
;; TODO set the template based on the parameters
|
|
||||||
(values
|
|
||||||
result
|
|
||||||
template)))
|
|
||||||
|
|
||||||
;;; N.b. assumes that all JSON keys are 1) lowercase, and 2) unique
|
;;; N.b. assumes that all JSON keys are 1) lowercase, and 2) unique
|
||||||
(defun encode-parameters (jsown)
|
(defun encode-parameters (jsown)
|
||||||
"Encode the Glacier parameters specfied by the JSOWN settings as a string suitable for use in a filename."
|
"Encode the Glacier parameters specfied by the JSOWN settings as a string suitable for use in a filename"
|
||||||
|
;; TODO write the inverse of this function to parse parameters from a filename
|
||||||
(let* ((key-json-paths
|
(let* ((key-json-paths
|
||||||
(loop :for (json-path _) :on (json-parameters) :by #'cddr
|
(loop :for (json-path _) :on (json-parameters) :by #'cddr
|
||||||
:collecting json-path))
|
:collecting json-path))
|
||||||
@ -91,6 +57,7 @@
|
|||||||
&key
|
&key
|
||||||
parameters
|
parameters
|
||||||
(jsown (jsown-template)))
|
(jsown (jsown-template)))
|
||||||
|
"Run the Glacier simulation TRIALS times for PARAMETERS"
|
||||||
(when parameters
|
(when parameters
|
||||||
(loop :for (path value) :in parameters
|
(loop :for (path value) :in parameters
|
||||||
:doing
|
:doing
|
||||||
@ -148,6 +115,7 @@
|
|||||||
base)))
|
base)))
|
||||||
|
|
||||||
(defun search-parameters ()
|
(defun search-parameters ()
|
||||||
|
"A parameter search run"
|
||||||
;; not exactly sure why something like
|
;; not exactly sure why something like
|
||||||
;; (loop :for yes :from 0.4 :to 0.6 :by 0.05… has rounding problems
|
;; (loop :for yes :from 0.4 :to 0.6 :by 0.05… has rounding problems
|
||||||
;;
|
;;
|
||||||
@ -163,3 +131,41 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;; unused
|
||||||
|
(defun json-parameters ()
|
||||||
|
`($.consensus_settings.glacier.evidence_alpha
|
||||||
|
0.8 ;;4/5
|
||||||
|
$.consensus_settings.glacier.evidence_alpha_2
|
||||||
|
0.4 ;;2/5
|
||||||
|
$.consensus_settings.glacier.confidence_beta
|
||||||
|
1
|
||||||
|
$.consensus_settings.glacier.look_ahead
|
||||||
|
997
|
||||||
|
$.consensus_settings.glacier.query.initial_query_size
|
||||||
|
100
|
||||||
|
$.consensus_settings.glacier.query.query_multiplier
|
||||||
|
2
|
||||||
|
$.consensus_settings.glacier.query.max_multiplier
|
||||||
|
1
|
||||||
|
$.byzantine_settings.total_size
|
||||||
|
,(expt 10 4)
|
||||||
|
$.byzantine_settings.distribution.honest
|
||||||
|
1
|
||||||
|
$.distribution.yes
|
||||||
|
0.5 ;;1/2
|
||||||
|
$.distribution.no
|
||||||
|
0.5))
|
||||||
|
|
||||||
|
;;; unused
|
||||||
|
(defun grind ()
|
||||||
|
(let* ((template
|
||||||
|
(probe-file "~/work/consensus-prototypes/etc/glacier.json"))
|
||||||
|
(json
|
||||||
|
(alexandria:read-file-into-string template))
|
||||||
|
(result
|
||||||
|
(jsown:parse json)))
|
||||||
|
;; TODO set the template based on the parameters
|
||||||
|
(values
|
||||||
|
result
|
||||||
|
template)))
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
(defpackage glacier
|
(defpackage glacier
|
||||||
(:use :cl)
|
(:use :cl)
|
||||||
(:export
|
(:export
|
||||||
|
#:summarize
|
||||||
|
#:summarize-all
|
||||||
#:run
|
#:run
|
||||||
#:grind))
|
#:search-parameters))
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
(in-package :glacier)
|
(in-package :glacier)
|
||||||
|
|
||||||
(defun summarize (file)
|
(defun summarize (file)
|
||||||
|
"Summarize the contents of polars FILE as per round undecided, no, and yes votes"
|
||||||
(let* ((s
|
(let* ((s
|
||||||
(alexandria:read-file-into-string file))
|
(alexandria:read-file-into-string file))
|
||||||
(j
|
(j
|
||||||
@ -22,4 +23,13 @@
|
|||||||
(lambda (x) (= 2 x))
|
(lambda (x) (= 2 x))
|
||||||
round))))))
|
round))))))
|
||||||
|
|
||||||
|
(defun summarize-all (&key (directory #p"~/var/"))
|
||||||
|
"Summarize all data files in DIRECTORY"
|
||||||
|
(let ((files (directory (merge-pathnames "*.out" directory))))
|
||||||
|
(dolist (file files)
|
||||||
|
(format *standard-output* "~&~a~&~a~%" file (summarize file)))
|
||||||
|
(format *standard-output* "~&Summarized ~d files." (length files))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user