Giter Club home page Giter Club logo

aivika's People

Contributors

dsorokin avatar larskuhtz 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aivika's Issues

Mutability Question

Do you see a reason why you have to use IO, instead of wrapping the mutations inside a pure abstraction, e.g., ST? An example of a use case would be to execute memoization. What would be the concerns with swapping the abstraction?

Performance question

I hope it is okay to ask a question here, but I could not find an Aivika forum. Feel free to direct me elsewhere.

I ran the TimeOutInt example (with spcStopTime = 100000.0) and returned the number of messages along with the actual result and measured the time. I got 254254 messages in 1.350 seconds. This is apx 5.3 sec per million msgs.

Some time ago I had started to write a DES in Smalltalk. There I simulated an infinitely fast Item "source" connected to a "throttle" which is connected to an infinitley fast "sink". I counted the events and took the timeToRun and got 500,000 Events in 0.468 seconds. This is apx. 0.92 sec per million events.

This came as a surprise, because I was expecting the compiled haskell version to be much faster than the Smalltalk version, but the Smalltalk version appears to be faster by a factor of 5.

What do you think? Am I comparing apples with oranges (i.e. messages with events). One thing I noticed is that Aivika seems to speed up the larger I set spcStopTime. With 1000000.0 I get 3.8 sec per million msgs. This may be attributed to the time to startup the program. Can you think of anything else?

Inaccurate version bounds in cabal file / compile failure

I'm currently working on the next generation of http://matrix.hackage.haskell.org/ (which is not yet reachable publicly, hence the screenshot & pasted error messages) when alvika caught my eye...

The build-dependencies have inaccurate versions bounds. Please be aware that accurate version bounds are mandated by the PVP, and adherence to the PVP is expected as part of the Hackage guidelines. This has various knock off consequences, such as Hackage possibly not being able to generate Haddock documentation for your package, install-plans degrading over time, as well generally resulting in a poor experience for users since they'll run into the same compilation errors.

The cabal gen-bounds command can be used to help infer an initial set of version bounds, see Cabal User Guide | Generating dependency version bounds for more details.

If you have any questions, please let me know!

Specifically, I've noticed the following compile error

Configuring component lib from aivika-distributed-0.3
Preprocessing library aivika-distributed-0.3...
[ 1 of 25] Compiling Simulation.Aivika.Distributed.Optimistic.Internal.TimeWarp ( Simulation/Aivika/Distributed/Optimistic/Internal/TimeWarp.hs, /tmp/matrix-worker/1480228864/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-distributed-0.3/build/Simulation/Aivika/Distributed/Optimistic/Internal/TimeWarp.o )
[ 2 of 25] Compiling Simulation.Aivika.Distributed.Optimistic.Internal.Channel ( Simulation/Aivika/Distributed/Optimistic/Internal/Channel.hs, /tmp/matrix-worker/1480228864/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-distributed-0.3/build/Simulation/Aivika/Distributed/Optimistic/Internal/Channel.o )
[ 3 of 25] Compiling Simulation.Aivika.Distributed.Optimistic.Internal.Priority ( Simulation/Aivika/Distributed/Optimistic/Internal/Priority.hs, /tmp/matrix-worker/1480228864/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-distributed-0.3/build/Simulation/Aivika/Distributed/Optimistic/Internal/Priority.o )

Simulation/Aivika/Distributed/Optimistic/Internal/Priority.hs:34:46:
    Can't make a derived instance of ‘Typeable Priority’:
      You need DeriveDataTypeable to derive an instance for this class
    In the data declaration for ‘Priority’

alvika

There's similiar problems in the other alvika-* packages; e.g. in aivika-transformers:

Configuring component lib from aivika-transformers-4.6
Preprocessing library aivika-transformers-4.6...
[ 1 of 90] Compiling Simulation.Aivika.Trans.Table ( Simulation/Aivika/Trans/Table.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Table.o )
[ 2 of 90] Compiling Simulation.Aivika.Trans.Generator.Primitive ( Simulation/Aivika/Trans/Generator/Primitive.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Generator/Primitive.o )
[ 3 of 90] Compiling Simulation.Aivika.Trans.Array ( Simulation/Aivika/Trans/Array.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Array.o )
[ 4 of 90] Compiling Simulation.Aivika.Trans.Statistics ( Simulation/Aivika/Trans/Statistics.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Statistics.o )
[ 5 of 90] Compiling Simulation.Aivika.Trans.Observable ( Simulation/Aivika/Trans/Observable.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Observable.o )
[ 6 of 90] Compiling Simulation.Aivika.Trans.Generator ( Simulation/Aivika/Trans/Generator.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Generator.o )
[ 7 of 90] Compiling Simulation.Aivika.Trans.Internal.Types ( Simulation/Aivika/Trans/Internal/Types.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Types.o )
[ 8 of 90] Compiling Simulation.Aivika.Trans.QueueStrategy ( Simulation/Aivika/Trans/QueueStrategy.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/QueueStrategy.o )
[ 9 of 90] Compiling Simulation.Aivika.Trans.Ref.Base ( Simulation/Aivika/Trans/Ref/Base.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Ref/Base.o )
[10 of 90] Compiling Simulation.Aivika.Trans.Internal.Specs ( Simulation/Aivika/Trans/Internal/Specs.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Specs.o )
[11 of 90] Compiling Simulation.Aivika.Trans.Specs ( Simulation/Aivika/Trans/Specs.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Specs.o )
[12 of 90] Compiling Simulation.Aivika.IO.Ref.Base ( Simulation/Aivika/IO/Ref/Base.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/IO/Ref/Base.o )
[13 of 90] Compiling Simulation.Aivika.IO.Generator ( Simulation/Aivika/IO/Generator.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/IO/Generator.o )
[14 of 90] Compiling Simulation.Aivika.Trans.Exception ( Simulation/Aivika/Trans/Exception.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Exception.o )
[15 of 90] Compiling Simulation.Aivika.IO.Exception ( Simulation/Aivika/IO/Exception.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/IO/Exception.o )
[16 of 90] Compiling Simulation.Aivika.Trans.Comp ( Simulation/Aivika/Trans/Comp.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Comp.o )
[17 of 90] Compiling Simulation.Aivika.Trans.DES ( Simulation/Aivika/Trans/DES.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/DES.o )
[18 of 90] Compiling Simulation.Aivika.Trans.Internal.Parameter ( Simulation/Aivika/Trans/Internal/Parameter.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Parameter.o )
[19 of 90] Compiling Simulation.Aivika.Trans.Parameter ( Simulation/Aivika/Trans/Parameter.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Parameter.o )
[20 of 90] Compiling Simulation.Aivika.Trans.Internal.Simulation ( Simulation/Aivika/Trans/Internal/Simulation.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Simulation.o )
[21 of 90] Compiling Simulation.Aivika.Trans.Simulation ( Simulation/Aivika/Trans/Simulation.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Simulation.o )
[22 of 90] Compiling Simulation.Aivika.Trans.Internal.Dynamics ( Simulation/Aivika/Trans/Internal/Dynamics.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Dynamics.o )
[23 of 90] Compiling Simulation.Aivika.Trans.Dynamics ( Simulation/Aivika/Trans/Dynamics.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Dynamics.o )
[24 of 90] Compiling Simulation.Aivika.Trans.Dynamics.Extra ( Simulation/Aivika/Trans/Dynamics/Extra.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Dynamics/Extra.o )
[25 of 90] Compiling Simulation.Aivika.Trans.Dynamics.Memo ( Simulation/Aivika/Trans/Dynamics/Memo.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Dynamics/Memo.o )
[26 of 90] Compiling Simulation.Aivika.Trans.Dynamics.Memo.Unboxed ( Simulation/Aivika/Trans/Dynamics/Memo/Unboxed.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Dynamics/Memo/Unboxed.o )
[27 of 90] Compiling Simulation.Aivika.Trans.Parameter.Random ( Simulation/Aivika/Trans/Parameter/Random.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Parameter/Random.o )
[28 of 90] Compiling Simulation.Aivika.Trans.SD ( Simulation/Aivika/Trans/SD.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/SD.o )
[29 of 90] Compiling Simulation.Aivika.Trans.Dynamics.Random ( Simulation/Aivika/Trans/Dynamics/Random.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Dynamics/Random.o )
[30 of 90] Compiling Simulation.Aivika.Trans.Internal.Event ( Simulation/Aivika/Trans/Internal/Event.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Internal/Event.o )
[31 of 90] Compiling Simulation.Aivika.Trans.Event ( Simulation/Aivika/Trans/Event.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/Event.o )
[32 of 90] Compiling Simulation.Aivika.Trans.DoubleLinkedList ( Simulation/Aivika/Trans/DoubleLinkedList.hs, /tmp/matrix-worker/1480240675/dist-newstyle/build/x86_64-linux/ghc-7.8.4/aivika-transformers-4.6/build/Simulation/Aivika/Trans/DoubleLinkedList.o )

Simulation/Aivika/Trans/DoubleLinkedList.hs:191:18:
    Could not deduce (Functor m) arising from a use of ‘fmap’
    from the context (Eq a, MonadRef m)
      bound by the type signature for
                 listRemove :: (Eq a, MonadRef m) =>
                               DoubleLinkedList m a -> a -> Event m Bool
      at Simulation/Aivika/Trans/DoubleLinkedList.hs:189:15-77
    Possible fix:
      add (Functor m) to the context of
        the type signature for
          listRemove :: (Eq a, MonadRef m) =>
                        DoubleLinkedList m a -> a -> Event m Bool
    In the expression: fmap isJust
    In the expression: fmap isJust $ listRemoveBy x (== v)
    In an equation for ‘listRemove’:
        listRemove x v = fmap isJust $ listRemoveBy x (== v)

Simulation/Aivika/Trans/DoubleLinkedList.hs:227:20:
    Could not deduce (Functor m) arising from a use of ‘fmap’
    from the context (Eq a, MonadRef m)
      bound by the type signature for
                 listContains :: (Eq a, MonadRef m) =>
                                 DoubleLinkedList m a -> a -> Event m Bool
      at Simulation/Aivika/Trans/DoubleLinkedList.hs:225:17-79
    Possible fix:
      add (Functor m) to the context of
        the type signature for
          listContains :: (Eq a, MonadRef m) =>
                          DoubleLinkedList m a -> a -> Event m Bool
    In the expression: fmap isJust
    In the expression: fmap isJust $ listContainsBy x (== v)
    In an equation for ‘listContains’:
        listContains x v = fmap isJust $ listContainsBy x (== v)

or in aivika-4.6 with GHC 7.4.2:

Configuring component lib from aivika-4.6
Preprocessing library aivika-4.6...

[ 1 of 73] Compiling Simulation.Aivika.Table ( Simulation/Aivika/Table.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Table.o )
[ 2 of 73] Compiling Simulation.Aivika.Vector ( Simulation/Aivika/Vector.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Vector.o )
[ 3 of 73] Compiling Simulation.Aivika.PriorityQueue.Pure ( Simulation/Aivika/PriorityQueue/Pure.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/PriorityQueue/Pure.o )
[ 4 of 73] Compiling Simulation.Aivika.PriorityQueue ( Simulation/Aivika/PriorityQueue.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/PriorityQueue.o )
[ 5 of 73] Compiling Simulation.Aivika.Unboxed ( Simulation/Aivika/Unboxed.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Unboxed.o )
[ 6 of 73] Compiling Simulation.Aivika.Vector.Unboxed ( Simulation/Aivika/Vector/Unboxed.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Vector/Unboxed.o )
[ 7 of 73] Compiling Simulation.Aivika.DoubleLinkedList ( Simulation/Aivika/DoubleLinkedList.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/DoubleLinkedList.o )
[ 8 of 73] Compiling Simulation.Aivika.Statistics ( Simulation/Aivika/Statistics.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Statistics.o )
[ 9 of 73] Compiling Simulation.Aivika.Generator ( Simulation/Aivika/Generator.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Generator.o )
[10 of 73] Compiling Simulation.Aivika.Internal.Specs ( Simulation/Aivika/Internal/Specs.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Internal/Specs.o )
[11 of 73] Compiling Simulation.Aivika.Specs ( Simulation/Aivika/Specs.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Specs.o )
[12 of 73] Compiling Simulation.Aivika.Internal.Parameter ( Simulation/Aivika/Internal/Parameter.hs, /tmp/matrix-worker/1480240550/dist-newstyle/build/x86_64-linux/ghc-7.4.2/aivika-4.6/build/Simulation/Aivika/Internal/Parameter.o )

Simulation/Aivika/Internal/Parameter.hs:214:18:
    parse error on input `<-'

Simulation stops without an event at the end

Hi @dsorokin, thank you for your beautiful package.

I am puzzled by the following behaviour. Without the runEventInStopTime then simulation stops after showing "t = 0.0 doing xyz" once. With the runEventInStopTime the simulation keeps printing "doing xyz" at every second, which is what I would have expected. Would you be able to explain the origin of this behaviour? Thanks in advance.

import Simulation.Aivika

specs :: Specs
specs =
    Specs
        { spcStartTime = 0.0
        , spcStopTime = 10.0
        , spcDT = 0.1
        , spcMethod = RungeKutta4
        , spcGeneratorType = SimpleGenerator
        }

test :: IO ()
test = runSimulation model specs

model :: Simulation ()
model = do
  let myProcess = traceProcess "doing xyz" (holdProcess 1) >> myProcess

  runProcessInStartTime myProcess

  -- without the following line the process doesn't resume after `holdProcess`
  -- runEventInStopTime $ return ()

edit:

I had originally written traceProcess "doing xyz" $ holdProcess 1 >> myProcess which has the wrong meaning. The described beavhour has not changed.

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.