Giter Club home page Giter Club logo

monadiccp's Introduction

monadiccp Build Status

Acknowledgments

  • Thanks to Chris Mears for a patch to get the package to compile against GHC 7.4.1.
  • Thanks to Nicholas Tung for a patch to get the package to compile against GHC 7.2.2.

monadiccp's People

Contributors

jtiko avatar jwaldmann avatar letmaik avatar nathanhowell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

monadiccp's Issues

Exception on unnecessary inequality

-- throws Exception: Cannot process EGBoolValue BoolConst True
model :: FDModel
model = exists $ \col -> do
  [a,b] <- colList col 2
  xsum col @= 2
  a @>= 0
  b @>= 1
  2 @<= 1 -- this causes the exception
  return col

refutable patterns require MonadFail

(with ghc-9.0.1-alpha1) when compiling

model :: ExampleModel ()
model _ = exists $ \col -> do
  [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10] <- colList col 10
  ...

I am seeing

examples/Olympic.hs:40:3: error:
    • Could not deduce (MonadFail m)
        arising from a do statement 
        with the failable pattern ‘[x1,  ...
      from the context: (Show (Control.CP.FD.FD.FDIntTerm s), FDSolver s,
                         Control.CP.SearchTree.MonadTree m,
                         Control.CP.SearchTree.TreeSolver m ~ FDInstance s)
...

the suggested fix seems impossible (there is no m)

      Possible fix:
        add (MonadFail m) to the context of
          the type signature for:
            model :: ExampleModel ()

But still, someone needs to get a MonadFail instance.

Exception when using "or"

-- throws Exception: Cannot process EGLess True
model :: FDModel
model = exists $ \col -> do
  [x1,x2,x3,x4] <- colList col 4
  allin col (cte 0,cte 5)
  x1 @<= x2
  x3 @>= x4
  x3 @>= x2 @|| x4 @<= x1 -- this causes the exception
  return col

I haven't tested it in other situations, this might be a corner case.

where is the Gecode backend?

Hi. I was searching for an Haskell API to Gecode, and found this project. I made some obvious changes so that it can be compiled with a recent ghc (8.2). But I found that there is no Gecode. E.g., it's commented out here:

src/Control/CP/FD/Solvers.hs:-- import Control.CP.FD.Gecode.CodegenSolver

Add straight-forward introduction example

At the moment, the existing examples all rely on the Control.CP.FD.Example module which is OK for running the examples but on the other side it is quite hard to understand and to use for creating own code with monadiccp.

The two files MonadicCpExample.hs and MonadicCpHelper.hs from the adp-multi-monadiccp project which use the OvertonFD solver might be a good starting point.

Build failure with ghc 7.8.2

The latest version of monadiccp fails to build with ghc 7.8.2 with the error message below:

[21 of 63] Compiling Control.Search.Generator ( Control/Search/Generator.hs, dist/build/Control/Search/Generator.o )

Control/Search/Generator.hs:732:70:
    Overlapping instances for Monad (t' ((:>) t2 IdT m))
      arising from a use of `mapE'
    Matching instances:
      instance [overlap ok] (Monad m, MonadT t) => Monad (t m)
        -- Defined at Control/Monatron/AutoInstances.hs:11:10
      instance Monad m => Monad (Control.Applicative.WrappedMonad m)
        -- Defined in `Control.Applicative'
    (The choice depends on the instantiation of `t2, t', m'
     To pick the first instance above, use IncoherentInstances
     when compiling the other instance declarations)
    In the first argument of `liftM', namely `(mapE (mmap L . runL))'
    In the first argument of `(.)', namely
      `liftM (mapE (mmap L . runL))'
    In the `mapper' field of a record

Control/Search/Generator.hs:741:73:
    Overlapping instances for Monad (t' ((:>) t2 (t1 :> t3) m))
      arising from a use of `mapE'
    Matching instances:
      instance [overlap ok] (Monad m, MonadT t) => Monad (t m)
        -- Defined at Control/Monatron/AutoInstances.hs:11:10
      instance Monad m => Monad (Control.Applicative.WrappedMonad m)
        -- Defined in `Control.Applicative'
    (The choice depends on the instantiation of `t2, t1, t3, t', m'
     To pick the first instance above, use IncoherentInstances
     when compiling the other instance declarations)
    In the first argument of `liftM', namely `(mapE (mmap L . runL))'
    In the first argument of `(.)', namely
      `liftM (mapE (mmap L . runL))'
    In the `mapper' field of a record

Control/Search/Generator.hs:752:44:
    Overlapping instances for Monad (t' ((:>) t0 (t1 :> t2) m))
      arising from a use of `mapE'
    Matching instances:
      instance [overlap ok] (Monad m, MonadT t) => Monad (t m)
        -- Defined at Control/Monatron/AutoInstances.hs:11:10
      instance Monad m => Monad (Control.Applicative.WrappedMonad m)
        -- Defined in `Control.Applicative'
    (The choice depends on the instantiation of `t1, t2, t0, t', m'
     To pick the first instance above, use IncoherentInstances
     when compiling the other instance declarations)
    In the first argument of `liftM', namely `(mapE (mmap L . runL))'
    In the first argument of `(.)', namely
      `liftM (mapE (mmap L . runL))'
    In the `mapper' field of a record

Control/Search/Generator.hs:752:50:
    Overlapping instances for Monad (t0 ((:>) t1 t2 m))
      arising from a use of `mmap'
    Matching instances:
      instance [overlap ok] (Monad m, MonadT t) => Monad (t m)
        -- Defined at Control/Monatron/AutoInstances.hs:11:10
      instance Monad m => Monad (Control.Applicative.WrappedMonad m)
        -- Defined in `Control.Applicative'
    (The choice depends on the instantiation of `t1, t2, t0, m'
     To pick the first instance above, use IncoherentInstances
     when compiling the other instance declarations)
    In the first argument of `(.)', namely `mmap L'
    In the first argument of `mapE', namely `(mmap L . runL)'
    In the first argument of `liftM', namely `(mapE (mmap L . runL))'

Control/Search/Generator.hs:752:82:
    Overlapping instances for Monad (t0 ((:>) t1 t2 m))
      arising from a use of `mmap'
    Matching instances:
      instance [overlap ok] (Monad m, MonadT t) => Monad (t m)
        -- Defined at Control/Monatron/AutoInstances.hs:11:10
      instance Monad m => Monad (Control.Applicative.WrappedMonad m)
        -- Defined in `Control.Applicative'
    (The choice depends on the instantiation of `t1, t2, t0, m'
     To pick the first instance above, use IncoherentInstances
     when compiling the other instance declarations)
    In the second argument of `(.)', namely `mmap runL'
    In the first argument of `mapE', namely `(L . mmap runL)'
    In the second argument of `(.)', namely `mapE (L . mmap runL)'

build with ghc-8.10.2

for 0.7.7 branch, with ghc-8.10.2 and stackage nightly-2020-10-31

monadiccp       > [ 7 of 63] Compiling Control.CP.SearchTree
monadiccp       >      
monadiccp       > /tmp/stack-3aa44fdabb3e7b1a/monadiccp-0.7.7/src/Control/CP/SearchTree.hs:203:10: error:
monadiccp       >     • Illegal nested constraint ‘Solver (TreeSolver m)’
monadiccp       >       (Use UndecidableInstances to permit this)
monadiccp       >     • In the instance declaration for ‘MonadTree (ContT r m)’
monadiccp       >     |
monadiccp       > 203 | instance (MonadTree m, Solver (TreeSolver m)) => MonadTree (ContT r m) where
monadiccp       >     |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Divergence When Using @/=

This might qualify more as a question than a bug report. I tried writing the following model, which creates two variables ranging over {1,2} and constrains them with @/= so that it is not the case that (a,b) = (1,2). Then it branches on the values of the first variable.
When I evaluate solve_not_12, the program diverges -- when compiled with GHC 7.6.3 -O2, it doesn't finish and allocates up to at least 700MB.
However, if I evaluate solve_not_12', which states the constraint in a slightly different way, it succeeds and returns (10,[[1,1]]).
Is this a bug or am I something wrong? I'm using monadiccp-0.7.6 compiled without any special flags (i.e. just cabal install monadiccp).

not_12 :: Tree (FDInstance OvertonFD) [Int]
not_12 =
    exist 2 $ \[a,b] -> do
      a @: (cte 1, cte 2)
      b @: (cte 1, cte 2)
      a @/= b - 1
      a @= 1 \/ a @= 2
      assignments [a,b]
solve_not_12 = solve dfs fs not_12

not_12' :: Tree (FDInstance OvertonFD) [Int]
not_12' =
    exist 2 $ \[a,b] -> do
      a @: (cte 1, cte 2)
      b @: (cte 1, cte 2)
      a + 1 @/= b
      a @= 1 \/ a @= 2
      assignments [a,b]
solve_not_12' = solve dfs fs not_12'

Maintainer needed

I haven't been and won't be able to maintain this package to a reasonable level. Anyone who is using this package and wants to take over maintenance and/or ownership, please shout.

Create a test suite

At the moment, the CI test only checks if monadiccp can be compiled. It would be useful to actually do some unit/property tests.

For the beginning, the existing examples could be used in unit tests to check against known results.

wanted: more/easier automated tests

Both as documentation for newcomers (= my students), and for quality assurance, I'd want more automated tests (mentionend in the cabal file, so they will be run under CI).

I put one example there already (Olympic) but I needed to patch the source (set the solver to use)

main = withArgs ["overton_run"] $ example_sat_main_void model

This "overton_run" seems to be the only solver available? https://github.com/letmaik/monadiccp/blob/master/src/Control/CP/FD/Example.hs#L79

When I try to run other examples, I am getting a variety of errors, e.g.,

stack exec -- runghc examples/Domino.hs overton_run
Domino.hs: Prelude.head: empty list

I can guess that it needs a command line argument, but then

stack exec -- runghc examples/Domino.hs overton_run 3
Domino.hs: constant collections not yet supported by overton interface

I think it would be good to

  • convert tests so that they also work without arguments (if they need some input,
    then there should be a default) (it is impossible to specify test arguments in a cabal file)
  • mark those tests that are supposed to work (with the given back-end), and run them in CI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.