Skip to content

Releases: brianguenter/FastDifferentiation.jl

v0.4.2

02 Nov 00:10
Compare
Choose a tag to compare

FastDifferentiation v0.4.2

Diff since v0.4.1

fixed bug which was causing enormous asymptotic slowdowns in evaluation of FD expressions. For modest size graphs, 1e4 nodes, should be approximately 100x faster. Speed improvement increases as graph size increases so for very large graphs, 1e6 nodes, speed improvement should be at least 1000x.

Merged pull requests:

  • update ci.yml to use latest julia checkout (#97) (@brianguenter)
  • fixed bug in is_variable. Was recursing through the graph for each call. Asymptotically slower than it should have been. (#101) (@brianguenter)

Closed issues:

  • TypeError: non-boolean (FastDifferentiation.Node) used in boolean context (#91)
  • update ci.yml to use latest julia checkout (#96)

v0.4.1

19 Sep 18:24
bebc4dc
Compare
Choose a tag to compare

FastDifferentiation v0.4.1

Diff since v0.4.0

This is a patch to fix two bugs, one introduced in 0.3.17 and one introduced in 0.4.0 when conditionals were added as a feature. These bugs caused derivative(x^y) to fail. Other less commonly used functions were also affected. Neither 0.3.17 nor 0.4.0 should be used.

This release makes it possible to do two things:

Create an FD function that contains conditionals: f = if_else(x<y,x,y) where x,y are both FD variables.

Take derivatives of functions whose derivative definitions use conditionals. For example, the derivative definition for mod2pi is now

DiffRules.@define_diffrule Base.mod2pi(x) = :(if_else(isinteger($x / $DiffRules.twoΟ€), oftype(float($x), NaN), one(float($x))))
Example: derivative of mod2pi
julia> @variables x 
x

julia> f = mod2pi(x)
mod2pi(x)

julia> derivative([f],x)
1-element Vector{FastDifferentiation.Node}:
 (if_else  isinteger((x / twoΟ€)) NaN 1)

julia> g = derivative([f],x)
1-element Vector{FastDifferentiation.Node}:
 (if_else  isinteger((x / twoΟ€)) NaN 1)

julia> h = make_function(g,[x])
RuntimeGeneratedFunction(#=in FastDifferentiation=#, #=using FastDifferentiation=#, :((input_variables,)->begin
          #= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:229 =#
          #= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:229 =# @inbounds begin
                  #= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:230 =#
                  begin
                      result_element_type = promote_type(Float64, eltype(input_variables))
                      result = Array{result_element_type}(undef, (1,))
                      var"##227" = input_variables[1] / twoΟ€
                      var"##226" = isinteger(var"##227")
                      var"##225" = if var"##226"
                              #= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:58 =#
                              begin
                                  var"##s#228" = NaN
                              end
                          else
                              #= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:60 =#
                              begin
                                  var"##s#229" = 1
                              end
                          end
                      result[1] = var"##225"
                      return result
                  end
              end
      end))

julia> h(2*pi)
1-element Vector{Float64}:
 NaN

You cannot (yet) take derivatives of a function which contains conditionals. This will come in a future PR.

julia> f = if_else(x<y,x,y)
(if_else  (x < y) x y)

julia> derivative([f],x)
ERROR: Your expression contained a if_else expression. FastDifferentiation does not yet support differentiation through this function)

Merged pull requests:

Closed issues:

  • Yank version 0.4.0? (#92)

v0.4.0

27 Aug 23:23
d225d72
Compare
Choose a tag to compare

FastDifferentiation v0.4.0

WARNING: version 0.4.0 is broken. Revert to 0.3.17 until a patch release is made. Look here for details

Diff since v0.3.17

Adds support for conditional expressions so you can write expresssions like ifelse(x<y,x,y) where x,y are FD nodes. Does not yet support differentiation through conditionals. This will come in another PR.

This may be a breaking change for some users since the meaning of x==y has changed from previous versions of FD.

Previously x==y returned Bool. If you were storing FD Node objects in a Dict then == would have been used to determine if two entries were identical.
In the new version this code would no longer work because x==y returns and FD Node object.
Instead of Dict you should use IDict which uses === to test for identical elements.
There are undoubtedly other data structures where similar problems might arise.

Merged pull requests:

Closed issues:

  • Code to switch between BitVector and Set (#5)
  • add pseudovector so don't have to create and populate vectors of variables (#7)
  • add complex numbers (#34)
  • Support for conditionals (#35)
  • Add conditionals (#89)

v0.3.17

01 Aug 02:35
Compare
Choose a tag to compare

FastDifferentiation v0.3.17

Diff since v0.3.16

0.3.16 didn't pick up the patch to make Node <: Real. This is an attempt to fix the problem.

v0.3.16

31 Jul 22:39
Compare
Choose a tag to compare

FastDifferentiation v0.3.16

Diff since v0.3.15

Before this patch FastDifferentiation expressions were a subtype of Number. Many Julia packages only worked with number types <: Real so they wouldn't work with FD expressions. This patch fixes this problem so now FD expressions <: Real. This should make FD more compatible with the Julia ecosystem.

Merged pull requests:

  • would it make sense to have FastDifferentiation.Node <: Real? (#88) (@brianguenter)

Closed issues:

  • would it make sense to have FastDifferentiation.Node <: Real? (#73)
  • Minor release for new Base methods (#86)

v0.3.15

02 Jul 18:35
Compare
Choose a tag to compare

FastDifferentiation v0.3.15

Diff since v0.3.14

added Base methods to make type promotion work properly #85 (comment)

Merged pull requests:

Closed issues:

  • Support for AbstractDifferentiation.jl / DifferentiationInterface.jl (#37)

v0.3.14

29 May 17:49
Compare
Choose a tag to compare

FastDifferentiation v0.3.14

Diff since v0.3.13

patch update to fix unbound variables problem #83 (comment) and eliminate unnecessary dependencies #82 (comment)

Merged pull requests:

  • project: delete highly undesirable unused strong deps (#82) (@nsajko)
  • methods with unbound static parameters (#84) (@brianguenter)

Closed issues:

  • methods with unbound static parameters (#83)

v0.3.13

22 May 22:41
Compare
Choose a tag to compare

FastDifferentiation v0.3.13

Diff since v0.3.12

Merged pull requests:

Closed issues:

  • subgraph factorization order incorrect (#80)

v0.3.12

22 May 03:06
Compare
Choose a tag to compare

FastDifferentiation v0.3.12

Diff since v0.3.11

Merged pull requests:

v0.3.11

25 Apr 18:13
Compare
Choose a tag to compare

FastDifferentiation v0.3.11

Diff since v0.3.10

Patch to fix problems caused by edges to constant nodes in derivative graph.

Edges in the derivative graph which lead to constant nodes can cause incorrect reachability results in other edges in the graph. This causes an error of the form "there is more than 1 path from root i to variable j".

This fixes the bug by deleting edges to constant nodes upon derivative graph construction. These edges play no part in the derivative evaluation anyway so it is unnecessary to keep them.

Merged pull requests:

Closed issues:

  • Non-unique path assertion in follow_path (#40)