Coder Social home page Coder Social logo

Comments (6)

therealansh avatar therealansh commented on May 11, 2024

Hey @breandan , I am new to Kotlin and would like to learn more of it. Can i try on this one? Do this project have any slack or discord?

from kotlingrad.

breandan avatar breandan commented on May 11, 2024

Hi @therealansh, welcome to the Kotlin community! PRs are certainly welcome. You might have a look at the Rewriter.kt or PrefAttach.kt demos in Kaliningraph and try to reproduce it using the Kotlin∇ computation graph. We don't have a dedicated Slack or Discord, but I try to be responsive on GitHub and often hang out on the #mathematics channel of the Kotlin Slack. Feel free to ping me wherever if you have any questions.

from kotlingrad.

therealansh avatar therealansh commented on May 11, 2024

Hey @breandan where should I implement these files? Any specific directory?

from kotlingrad.

breandan avatar breandan commented on May 11, 2024

You will need to make changes to the core API. In particular, when DEBUG mode (cf. EAGER mode) is enabled, each recursive call to df() and apply(vararg xs: Fun<X>) could pause execution, append toGraph() to the debugger stack and await the key to be pressed. If pausing execution is too complicated, I would just write the intermediate graphs to a stack and return immediately.

You could add a demo for the debugger to samples, e.g. something like this:

fun main() {
  DEBUG = true
  val x by DReal.Var()
  val y by DReal.Var()
  val f = x * (-sin(x * y) + y) * 4
  f(x to 0, y to 1) // This should open a browser window with the debugger stack navigable using ←/→ keys
}

If you're feeling ambitious, it would be nice to improve the graph visualization algorithm somehow, instead of just displaying the static graph, it would be nice to see edges labeled with values flowing across them (e.g. see the reduction semantics). For that, you may need to modify Kaliningraph's implementation to make UnlabeledEdge a LabeledEdge and update render().

Again, feel free to ping me if you have questions about any of this. Thanks!

from kotlingrad.

therealansh avatar therealansh commented on May 11, 2024

Hey @breandan So i have a couple of questions. So as i can see in the PrefAttach and Rewrite there is a animate function which seems to be missing in main but present in test which actually opens the web using KWeb. Do we have to re-implement this function in KotlinGrad api or should we also implement this in Kaliningraph main src.
Also what i have understood is that we have to call toGraph() in the function as

fun apply(vararg xs: Fun<X>): SFun<X>{
    if(EAGER){stack??.push(toGraph()}
    when (op) {
      Monad.id -> this
      Monad.sin -> (xs[0] as SFun<X>).sin()
      Monad.cos -> (xs[0] as SFun<X>).cos()
      Monad.tan -> (xs[0] as SFun<X>).tan()
      Monad.`-` -> -(xs[0] as SFun<X>)
    }
}

Similar with the df() recursive call. Here how can we access the debugger stack by getStackTrace() ? or it will be just an empty stack when we initialise the function. Thanks for helping in advance i am new to this big codebase so might take a few days to get along.

from kotlingrad.

breandan avatar breandan commented on May 11, 2024

Yep, that’s a good point. We separated the Kweb dependency from the main library to avoid dependency bloat. If you want to use Kweb for your debugger implementation, you can just add a testImplementation instance to the dependencies section of core/build.gradle.kts and implement your animate functionality in the test directory.

I guess the simplest debugger implementation would just accumulate intermediate graphs in a mutable variable, which could be read asynchronously. If you want to define a custom function debugApply which is called when the DEBUG flag is set, that would also probably work. A better solution would be to make it functional, i.e. your solution would need to return a Pair<SFun<X>, List<SFun<X>>> instead of writing to some separate data structure.

from kotlingrad.

Related Issues (20)

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.