Coder Social home page Coder Social logo

fixedpointacceleration.jl's Introduction

FixedPointAcceleration.jl

Build Coverage Documentation
Build status codecov docs-latest-img

This package implements similar functionality to https://cran.r-project.org/web/packages/FixedPoint/index.html. The key differences are:

  • This package makes use of Julia's type system and is generally typed in a more stable and extendible way. FixedPoint results are always output in a FixedPointResults struct. All algorithms are specified by an enum.
  • This package does not include the plotting capability of the R package. This is not essential for the functionality of the package and since fixed_point calls can be chained together you can easily do whatever plotting you want pretty easily where necessary.

Included Acceleration algorithms.

There are 8 acceleration algorithms included in this package. A more extensive explanation is available in the documentation. A very brief description however is:

  • Simple - This takes the output of the previous iterate and uses it as the next guess.

In addition the following three scalar algorithms can be used (they are elementwise for vectors):

  • Aitken - This considers the sequence p, f(p), f(f(p)), ... convergences at a constant rate to the fixed point. After each two iterates it estimates the rate and jumps to the anticipated fixed point;
  • Newton - This uses a Newtonian rootfinder to solve for the root of f(x) - x;
  • SEA - or Scalar Epsilon Algorithm. This uses an epsilon algorithm for finding a fixed point where an elementwise inverse is taken;

In addition the following four algorithms are specialised for vectors of arbitrary length:

  • VEA - or Vector Epsilon Algorithm. This uses an epsilon algorithm for finding a fixed point where an Moore-Penrose Pseudoinverse is used for vectors. This is done after every "ExtrapolationPeriod" number off iterates which is 7 by default;
  • MPE - or Minimal Polynomial Extrapolation uses a linear combination of previous iterates for the next guess. This is done after every "ExtrapolationPeriod" number off iterates which is 7 by default;
  • RRE - or Reduced Rank Extrapolation uses a linear combination of previous iterates for the next guess. This is done after every "ExtrapolationPeriod" number off iterates which is 7 by default;
  • Anderson (default) - This takes a linear combination of previous iterates (it gets weights from an OLS regression). Unlike RRE, MPE,VEA this linear combination does not need to be of sequential simple iterates but can be any previous iterates. At maximum "MaxM" previous iterates are used but fewer may be used for numerical stability reasons if a certain matrix used in an OLS regression has a condition number above "ConditionNumberThreshold".

Using FixedPointAcceleration

We can first use FixedPointAcceleration to find the fixed point of the 1d function cos(x) with the Anderson method.

using FixedPointAcceleration
cos_func(x) = cos.(x)
Inputs = 1.1
fp_anderson = fixed_point(cos_func, Inputs; Algorithm = :Anderson)
# And we can see the fixed point by looking at
fp_anderson.FixedPoint_

Two important issues are important to highlight here:

  • All input functions must take and return Vector{<:Real} types. When solving for the fixedpoint of a scalar function use of the dot syntax - cos.(x) instead of cos(x) - might be useful for this.
  • fp_anderson.FixedPoint_ in this case may be missing. This occurs whenever a fixedpoint was not found that is correct to the specified ConvergenceMetric and ConvergenceMetricThreshold. In this case the fp_anderson.Outputs_ array will probably contain something close to a fixed point in its rightmost column.

For more examples and information see the documentation.

fixedpointacceleration.jl's People

Contributors

s-baumann 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

Watchers

 avatar  avatar

fixedpointacceleration.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Question: Can the function fixed_point also be applied to a function with many inputs, where I only want to find the fixed point as regards one input?

For example, I have the function:

function pricing_eq(dt_m, price, xi, nu_alpha, nu_p, nu_xr, nu_xm, nu_xj)
    new_price = pricing_contraction(dt_m, init_price, xi,  nu_alpha, nu_p, nu_xr, nu_xm, nu_xj)
    return new_price
end

I am interested in finding the fixed point as regards 'price', the second argument. I have tried doing something like this:

FP_price = fixed_point((x -> pricing_eq(dt_m, x, xi[:,1], nu_alpha, nu_p, nu_xr, nu_xm, nu_xj)), init_price; Algorithm = :simple)

init_price is Vector{Float64}. Moreover, if I run:

pricing_eq(dt_m, init_price, xi[:,1], nu_alpha, nu_p, nu_xr, nu_xm, nu_xj)

it works, so the problem cannot be in my function. What am I doing wrong?

Problem with linear system solve

Hi,
A very similar code works in Matlab, with Julia I run into type problems.
Could you please give me a hand with

using FixedPointAcceleration
n = 5
A = randn(n,n)
b = randn(n,1)
function fun(x) 
    y = x + A*x - b
end
x = zeros(n,1)
fixed_point(fun, x; Algorithm = :Anderson)

Thx

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.