File: ExtensionField.hs

package info (click to toggle)
haskell-sbv 10.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,148 kB
  • sloc: haskell: 31,176; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 1,594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-----------------------------------------------------------------------------
-- |
-- Module    : TestSuite.Optimization.ExtensionField
-- Copyright : (c) Levent Erkok
-- License   : BSD3
-- Maintainer: erkokl@gmail.com
-- Stability : experimental
--
-- Test suite for optimization routines, extension field
-----------------------------------------------------------------------------

{-# OPTIONS_GHC -Wall -Werror #-}

module TestSuite.Optimization.ExtensionField(tests) where

import Utils.SBVTestFramework

-- Test suite
tests :: TestTree
tests =
  testGroup "Optimization.ExtensionField"
    [ goldenVsStringShow "optExtField1" (optimize Lexicographic optExtField1)
    , goldenVsStringShow "optExtField2" (optimize Lexicographic optExtField2)
    , goldenVsStringShow "optExtField3" (optimize Lexicographic optExtField3)
    ]

optExtField1 :: ConstraintSet
optExtField1 = do x <- sInteger "x"
                  y <- sInteger "y"

                  constrain $ x .< 4
                  constrain $ y - x .> 1

                  maximize "x_plus_y" $ x+y

optExtField2 :: ConstraintSet
optExtField2 = do x <- sInteger "x"
                  y <- sInteger "y"

                  constrain $ x .< 4
                  constrain $ y - x .< 1
                  constrain $ y .< 1

                  minimize "x_plus_y" $ x+y

optExtField3 :: ConstraintSet
optExtField3 = do x <- sReal "x"
                  y <- sReal "y"

                  constrain $ x .<= 4
                  constrain $ y .<= 5

                  maximize "x_plus_y" $ x + y

{- HLint ignore module "Reduce duplication" -}