Skip to content

Commit

Permalink
bug related to overflows/underflows and lower bound
Browse files Browse the repository at this point in the history
  • Loading branch information
AYadrov committed Nov 22, 2024
1 parent f06ccf6 commit 7e398e5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ doc/
infra/points.json
out.html
profile.json
*~

16 changes: 15 additions & 1 deletion eval/adjust.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
; Step 3. Repeating precisions check + Assigning if a operation should be computed again at all
; vrepeats[i] = #t if the node has the same precision as an iteration before and children have #t flag as well
; vrepeats[i] = #f if the node doesn't have the same precision as an iteration before or at least one child has #f flag
(define any-false? #f)
(for ([instr (in-vector ivec)]
[useful? (in-vector vuseful)]
[prec-old (in-vector (if (equal? 1 current-iter) vstart-precs vprecs))]
Expand All @@ -67,10 +68,23 @@
(or (not useful?)
(and (<= prec-new prec-old)
(andmap (lambda (x) (or (< x varc) (vector-ref vrepeats (- x varc)))) (cdr instr)))))
(set! any-false? (or any-false? (not repeat)))
(vector-set! vrepeats n repeat))

; Step 4. Copying new precisions into vprecs
(vector-copy! vprecs 0 vprecs-new))
(vector-copy! vprecs 0 vprecs-new)

; Step 5. If precisions have not changed but the point didn't converge. A problem exists - add slack to every op
(unless any-false?
(set-rival-machine-bumps! machine (add1 bumps))
(define slack (get-slack))
(for ([prec (in-vector vprecs)]
[n (in-range (vector-length vprecs))])
(define prec* (min (*rival-max-precision*) (+ prec slack)))
(when (equal? prec* (*rival-max-precision*))
(*last-iteration* #t))
(vector-set! vprecs n prec*))
(vector-fill! vrepeats #f)))

; This function goes through ivec and vregs and calculates (+ ampls base-precisions) for each operator in ivec
; Roughly speaking, the upper precision bound is calculated as:
Expand Down
2 changes: 1 addition & 1 deletion eval/machine.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(define *rival-max-precision* (make-parameter 10000))
(define *rival-min-precision* (make-parameter 20))
(define *rival-profile-executions* (make-parameter 1000))
(define *lower-bound-early-stopping* (make-parameter #f))
(define *lower-bound-early-stopping* (make-parameter #t))

(struct discretization (target convert distance))

Expand Down
25 changes: 13 additions & 12 deletions time.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,19 @@

; -------------------------------- Combining results ----------------------------------------
; When all the machines have compiled and produced results - write the results to outcomes
(point-bucketing timeline
rival-status
rival-apply-time
rival-exs
baseline-status
baseline-apply-time
baseline-exs
sollya-status
sollya-apply-time
sollya-exs
baseline-precision
rival-iter)
(when (> (*sampling-timeout*) sollya-apply-time)
(point-bucketing timeline
rival-status
rival-apply-time
rival-exs
baseline-status
baseline-apply-time
baseline-exs
sollya-status
sollya-apply-time
sollya-exs
baseline-precision
rival-iter))

(when (<= (*sampling-timeout*) sollya-apply-time)
(*sollya-timeout* (add1 (*sollya-timeout*))))
Expand Down

0 comments on commit 7e398e5

Please sign in to comment.