Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Automatic commit at Thu May 2 12:00:01 MDT 2013
Browse files Browse the repository at this point in the history
  • Loading branch information
jeapostrophe committed May 2, 2013
1 parent 691effb commit 98f6597
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions persona/p4g/optimize.rkt
Expand Up @@ -62,7 +62,8 @@
(define next
(for*/fold ([this persona->plan])
([(l lp) (in-hash persona->plan)]
[(r rp) (in-hash persona->plan)])
[(r rp) (in-hash persona->plan)]
#:unless (equal? l r))
(cond
[(double-fusion l r)
=>
Expand Down Expand Up @@ -105,29 +106,37 @@
(for/list ([(p pl) (in-hash p->p)])
(linearize-one! p pl)))

(define lplan-format
(match-lambda
(define (lplan-format res? lp)
(match lp
[(ldouble res l r)
(format "[~a@(~a x ~a)]"
(if res?
(format "[~a@~a]"
res
(lplan-format l)
(lplan-format r))]
(lplan-format #f lp))
(format "(~a x ~a)"
(lplan-format #t l)
(lplan-format #t r)))]
[(lbuy res c)
(format "B(~a)" res)]))
res]))

(define (display-plans p->p)
(define lps
(define lps
(sort (filter ldouble?
(linearize p->p))
<
#:key lplan-cost
#:cache-keys? #t))
(define max-len
(apply max (map (compose string-length lplan-res) lps)))
(for ([lp (in-list lps)]
[i (in-range 10)])
(printf "~a [~a] <= ~a\n"
(lplan-res lp)
(lplan-cost lp)
(lplan-format lp))))
(displayln
(~a (~a #:min-width max-len
(lplan-res lp))
" ["
(lplan-cost lp)
"] <= "
(lplan-format #f lp)))))

(module+ main
(require "current.rkt")
Expand Down

0 comments on commit 98f6597

Please sign in to comment.