Constraint Solver Part 9: Recap video

Series: Constraint Solver in Julia

This is part 9 of the series about: How to build a Constraint Programming solver?

We did a lot already in very small steps sometimes and maybe not all of you read everything. Special thanks to those who did!

If you’re interested in this project but don’t have time to read through all of it: Bookmark the website and return back later 😉

In this post I mostly mention the video I made about this series:

The main goal of this video is to show you the overall structure of the code which might be hard to follow in the blog version.

Additionally in the last couple of minutes I also give a coding session on how to integrate your own constraint. In the post it’s the very simple equal constraint.

I don’t explain the constraints in the video so if you want to read that again I would suggest:

Part Four: Alldifferent constraint and Part Eight: UI Refactoring. In the latter I gave a simple explanation of the sum constraint which I failed to give before.

If you wonder about the Variable Type which isn’t explained in the video you should check out:

Part Five: Better data structure

Unfortunately the quality of the video/microphone isn’t that good but I hope it’s still watchable and reasonable. If you’re interested in more stuff like this and maybe live coding of a constraint or something please comment. Comment as well if you think I should just keep blogging 😉

Stay tuned 😉

And as always:

Thanks for reading and special thanks to my first three patrons!

List of patrons paying more than 2$ per month:

  • Site Wang

If you want to have early access to the next posts as well and enjoy the blog in general please consider a donation via Patreon to keep this project running.

For a donation of a single dollar per month you get early access to the posts. Try it out for a the last two weeks of October for free and if you don’t enjoy it just cancel your subscription.

If you have any questions, comments or improvements on the way I code or write please comment here and or write me a mail [email protected] and for code feel free to open a PR on GitHub ConstraintSolver.jl

I’ll keep you updated on Twitter OpenSourcES as well as my more personal one:
Twitter Wikunia_de

A Collection of Jacobian Sparsity Acceleration Tools for Julia

By: Christopher Rackauckas

Re-posted from: http://www.stochasticlifestyle.com/a-collection-of-jacobian-sparsity-acceleration-tools-for-julia/

Over the summer there have been a whole suite of sparsity acceleration tools for Julia. These are encoded in the packages:

The toolchain is showcased in the following blog post by Pankaj Mishra, the student who build a lot of the Jacobian coloring and decompression framework. Langwen Huang setup the fast paths for structured matrices (tridiagonal, banded, and block-banded matrices) and also integrated these tools with DifferentialEquations.jl. Shashi Gowda then setup a mechanism for automatically detecting the sparsity of Julia programs (!!!).

A tutorial using this workflow together is described in the SparseDiffTools.jl README. In summary, to use the tools you have the following flow:

  1. Find your sparsity pattern, Jacobian structure (i.e. Jacobian type), or automatically detect it with SparsityDetection.jl.
  2. Call `matrix_colors(A)` from SparseDiffTools.jl to get the `colorvec` for A. This is the vector that the differentiation tools need to have to exploit sparsity and reduce the total cost of generating the Jacobian.
  3. When calling `forwarddiff_color_jacobian` from SparseDiffTools.jl for sparse AD or `finite_difference_jacobian` from DiffEqDiffTools.jl for sparse finite differencing, pass the `colorvec` and `sparsity` (the sparsity pattern by either passing the sparse matrix or the structured matrix), then the differentiation tools will automatically accelerate to be fast for that kind of matrix
  4. When building the ODEFunction for the DifferentialEquations.jl ODE solver, pass the `colorvec` and `jac_prototype` and all internal functions will automatically specialize on the sparsity pattern and accelerate. If you pass a structured matrix, like a BandedMatrix, the color vector will be determined automatically, making those accelerations free.

Thus together the chain is: get the sparsity, get the colorvec, pass it to packages and boom you’re faster!

The Math of Sparsity

If you’re interested in how this all works, please take a look at the lecture notes for my course 18.337:

  1. Forward-Mode AD via High Dimensional Algebras (necessary backstory)
  2. Solving Stiff Ordinary Differential Equations (which explains the sparse AD story)

Additionally, take a look at this paper for an explanation of how you can do automatic sparsity detection of Julia packages.

Conclusion

It will be interesting to see how having an integrated platform for acceleration via sparsity effects a high level language, especially the automatic sparsity detection. It is fitting for Julia to have these tools since, given the focus on performance, this is the piece of math that is required to make your performance work really matter! This is a pervasive mechanism which lets you accelerate differentiation on your own, or directly give the differential equation solvers these to utilize (and it works with ODEs, SDEs, DAEs, DDEs, hybrid equations, etc.). We hope to integrate this with NLsolve.jl, and get the Hessian tools finished for Optim.jl and JuMP.jl. Also, JuMP.jl is getting a new and improved NLP interface which will utilize a lot of this behind the scenes automatically. Stay tuned.

The post A Collection of Jacobian Sparsity Acceleration Tools for Julia appeared first on Stochastic Lifestyle.

Developing Julia Packages

By: Christopher Rackauckas

Re-posted from: http://www.stochasticlifestyle.com/developing-julia-packages/

Have you ever wanted to develop your own package for the Julia programming language? Have you ever wanted to contribute a bug fix? Then this tutorial is for you! I will walk you through getting the community resources (Discourse and Slack) so that you can get help, get the Juno and GitKraken development environments going, and show all of the steps of building a package. In this video you will learn how to use modules, how to interactively update a package without recompiling, how to setup continuous integration testing, and how to get your package registered. In addition, I show how to “dev” a package to get a local copy to work on, and use this to give a bug fix to open a pull-request to fix an issue on an existing package.

Note: After “]dev”ing a package, the local version of “using Package” uses the package in your “~/.julia/dev/Package” folder!

The post Developing Julia Packages appeared first on Stochastic Lifestyle.