Skip to content

Commit

Permalink
Add an optimization order test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorawee committed Aug 9, 2023
1 parent d0dcd5f commit 148fd79
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/all-rosette-tests.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"base/distinct.rkt"
"base/generics.rkt"
"base/push-pop.rkt"
"base/optimize-order.rkt"
"base/reflect.rkt"
"base/decode.rkt"
"query/solve.rkt"
Expand Down
27 changes: 27 additions & 0 deletions test/base/optimize-order.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#lang rosette

;; This test is taken from https://www.philipzucker.com/z3-rise4fun/optimization.html

(require rackunit rackunit/text-ui racket/generator
rosette/lib/roseunit)

(current-bitwidth #f)
(define-symbolic x y z integer?)

(define (check-model sol m)
(check-pred sat? sol)
(check-equal? (model sol) m))

(define optimization-order-tests
(test-suite+ "Tests for the optimization order"
#:features '(optimize)

(define solver (current-solver))

(solver-assert solver (list (< x z) (< y z) (< z 5) (not (= x y))))
(solver-maximize solver (list x))
(solver-maximize solver (list y))
(check-model (solver-check solver) (hash x 3 y 2 z 4))))

(module+ test
(time (run-tests optimization-order-tests)))

0 comments on commit 148fd79

Please sign in to comment.