Skip to content

Commit

Permalink
Render cost
Browse files Browse the repository at this point in the history
  • Loading branch information
bksaiki committed Nov 17, 2020
1 parent e0c61fb commit c370331
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/pareto.rkt
Expand Up @@ -20,9 +20,11 @@
(define total-area (* (- high-score low-score) (- high-cost low-cost)))
(define scores* (map (curryr - low-score) (remove-ends scores)))
(define costs* (map (curryr - low-cost) (remove-ends costs)))
(for/fold ([area 0] [cost0 0] #:result (/ area total-area))
([cost costs*] [score scores*])
(values (+ area (* (- cost cost0) score)) cost)))
(if (zero? total-area)
0.0
(for/fold ([area 0] [cost0 0] #:result (/ area total-area))
([cost costs*] [score scores*])
(values (+ area (* (- cost cost0) score)) cost))))

(define (paired-less? elem1 elem2)
(let ([c1 (car elem1)] [c2 (car elem2)])
Expand Down
7 changes: 5 additions & 2 deletions src/sandbox.rkt
Expand Up @@ -17,7 +17,7 @@
(struct test-success test-result
(start-alt end-alt points exacts start-est-error end-est-error
newpoints newexacts start-error end-error target-error
baseline-error oracle-error other-alts other-errors all-alts))
baseline-error oracle-error other-alts other-errors all-alts costs))
(struct test-failure test-result (exn))
(struct test-timeout test-result ())

Expand Down Expand Up @@ -104,6 +104,8 @@

(define-values (points exacts) (get-p&es context))
(define-values (newpoints newexacts) (get-p&es newcontext))
(define costs (map alt-cost alts))

(test-success test
(bf-precision)
(- (current-inexact-milliseconds) start-time)
Expand All @@ -120,7 +122,8 @@
baseline-errs
oracle-errs
other-alts other-errs
(*all-alts*)))))
(*all-alts*)
costs))))

(define (on-exception start-time e)
(parameterize ([*timeline-disabled* false])
Expand Down
11 changes: 7 additions & 4 deletions src/web/make-graph.rkt
Expand Up @@ -52,7 +52,8 @@
(test-success test bits time timeline warnings
start-alt end-alt points exacts start-est-error end-est-error
newpoints newexacts start-error end-error target-error
baseline-error oracle-error other-alts other-errors all-alts)
baseline-error oracle-error other-alts other-errors
all-alts costs)
result)
(define repr (test-output-repr test))

Expand Down Expand Up @@ -92,7 +93,8 @@
(format-bits (apply max (map ulps->bits start-error)) #:unit #f)
(format-bits (apply max (map ulps->bits end-error)) #:unit #f)))
,(render-large "Time" (format-time time))
,(render-large "Precision" `(kbd ,(~a (representation-name repr)))))
,(render-large "Precision" `(kbd ,(~a (representation-name repr))))
,(render-large "Cost" (format-bits (car costs) #:unit #f)))

,(render-warnings warnings)

Expand Down Expand Up @@ -142,13 +144,14 @@
"\\]"))
"")

,@(for/list ([alt other-alts] [errs other-errors] [idx (in-naturals 1)])
,@(for/list ([alt other-alts] [cost (cdr costs)] [errs other-errors] [idx (in-naturals 1)])
(define name (format "Alternative ~a" idx))
`(section ([id "alternatives"] [style "margin: 2em 0;"])
,(if (zero? idx) `(h1 "Alternatives") "")
(table
(tr (th ([style "font-weight:bold"]) ,name))
(tr (th "Accuracy") (td ,(format-bits (errors-score errs)))))
(tr (th "Accuracy") (td ,(format-bits (errors-score errs))))
(tr (th "Cost") (td ,(format-bits cost))))
(div ([class "math"]) "\\[" ,(core->tex
(program->fpcore
(resugar-program (alt-program alt) repr)))
Expand Down
6 changes: 3 additions & 3 deletions src/web/report.css
Expand Up @@ -8,7 +8,7 @@ figure { margin: 0; }

#large { margin: 2em 0; text-align: center; }
#large div { margin: 0 1em; display: inline-block; vertical-align: top; }
#large .number { font-size: 3em; display: block; }
#large .number { font-size: 2.5em; display: block; }
@media print { #large { margin-top: 0; }}

/* Arrow chart */
Expand Down Expand Up @@ -280,9 +280,9 @@ pre.shell code:before { content: "$ "; font-weight: bold; }

/* Alternatives */

#alternatives table { width: 300px; display: inline-table; vertical-align: top; }
#alternatives table { width: 275px; display: inline-table; vertical-align: top; }
#alternatives table th { text-align: left; font-weight: normal; }
#alternatives table td { text-align: left; }
#alternatives table td { text-align: left; width: 75px; }
#alternatives div { display: inline-block; width: 500px; }

/* Formatting backtraces */
Expand Down

0 comments on commit c370331

Please sign in to comment.